From df5d67e86b638a7e1034d2ece81621da1953adfd Mon Sep 17 00:00:00 2001 From: vincenttran-msft <101599632+vincenttran-msft@users.noreply.github.com> Date: Wed, 16 Nov 2022 16:07:08 -0800 Subject: [PATCH 1/7] [Storage] Change algorithm used to sort headers (#26991) * Draft * Adjusted tcase * Completely fleshed out, 99.99% match with service sort * Add to async, refactor sort, add except to sort * PR feedback, comment on test about err, method sig & naming * Propagate to other packages, adjust weights * Trailing whitespace --- .../storage/blob/_shared/authentication.py | 35 +++++- ...t_header_metadata_sort_in_upload_blob.json | 92 ++++++++++++++ ...er_metadata_sort_in_upload_blob_fails.json | 115 ++++++++++++++++++ ...t_header_metadata_sort_in_upload_blob.json | 90 ++++++++++++++ ...er_metadata_sort_in_upload_blob_fails.json | 113 +++++++++++++++++ .../tests/test_blob_access_conditions.py | 54 ++++++++ .../test_blob_access_conditions_async.py | 57 ++++++++- .../filedatalake/_shared/authentication.py | 27 +++- .../fileshare/_shared/authentication.py | 27 +++- .../storage/queue/_shared/authentication.py | 28 ++++- 10 files changed, 627 insertions(+), 11 deletions(-) create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.pyTestStorageBlobAccessConditionstest_header_metadata_sort_in_upload_blob.json create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.pyTestStorageBlobAccessConditionstest_header_metadata_sort_in_upload_blob_fails.json create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.pyTestStorageBlobAccessConditionsAsynctest_header_metadata_sort_in_upload_blob.json create mode 100644 sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.pyTestStorageBlobAccessConditionsAsynctest_header_metadata_sort_in_upload_blob_fails.json diff --git a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py index adf64c7485b6..3a471a233a15 100644 --- a/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py +++ b/sdk/storage/azure-storage-blob/azure/storage/blob/_shared/authentication.py @@ -7,12 +7,13 @@ import logging import re import sys +from typing import List, Tuple try: from urllib.parse import urlparse, unquote except ImportError: - from urlparse import urlparse # type: ignore - from urllib2 import unquote # type: ignore + from urlparse import urlparse # type: ignore + from urllib2 import unquote # type: ignore try: from yarl import URL @@ -29,11 +30,9 @@ from . import sign_string - logger = logging.getLogger(__name__) - # wraps a given exception with the desired exception type def _wrap_exception(ex, desired_type): msg = "" @@ -48,6 +47,30 @@ def _wrap_exception(ex, desired_type): # TODO: In the future we will log the trace return desired_type('{}: {}'.format(ex.__class__.__name__, msg)) +# This method attempts to emulate the sorting done by the service +def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str, str]]: + # Define the custom alphabet for weights + custom_weights = "-!#$%&*.^_|~+\"\'(),/`~0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz{}" + + # Build dict of tuples and list of keys + header_dict = dict() + header_keys = [] + for k, v in input_headers: + header_dict[k] = v + header_keys.append(k) + + # Sort according to custom defined weights + try: + header_keys = sorted(header_keys, key=lambda word: [custom_weights.index(c) for c in word]) + except ValueError: + raise ValueError("Illegal character encountered when sorting headers.") + + # Build list of sorted tuples + sorted_headers = [] + for key in header_keys: + sorted_headers.append((key, header_dict.get(key))) + return sorted_headers + class AzureSigningError(ClientAuthenticationError): """ @@ -96,7 +119,7 @@ def _get_canonicalized_headers(request): for name, value in request.http_request.headers.items(): if name.startswith('x-ms-'): x_ms_headers.append((name.lower(), value)) - x_ms_headers.sort() + x_ms_headers = _storage_header_sort(x_ms_headers) for name, value in x_ms_headers: if value is not None: string_to_sign += ''.join([name, ':', value, '\n']) @@ -140,7 +163,7 @@ def on_request(self, request): self._get_canonicalized_resource_query(request) self._add_authorization_header(request, string_to_sign) - #logger.debug("String_to_sign=%s", string_to_sign) + # logger.debug("String_to_sign=%s", string_to_sign) class StorageHttpChallenge(object): diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.pyTestStorageBlobAccessConditionstest_header_metadata_sort_in_upload_blob.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.pyTestStorageBlobAccessConditionstest_header_metadata_sort_in_upload_blob.json new file mode 100644 index 000000000000..5bf0c3be417a --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.pyTestStorageBlobAccessConditionstest_header_metadata_sort_in_upload_blob.json @@ -0,0 +1,92 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer20123a37?restype=container", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)", + "x-ms-date": "Thu, 27 Oct 2022 21:29:05 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Thu, 27 Oct 2022 21:29:05 GMT", + "ETag": "\u00220x8DAB862469A3D01\u0022", + "Last-Modified": "Thu, 27 Oct 2022 21:29:05 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer20123a37/blob1", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "11", + "Content-Type": "application/octet-stream", + "If-None-Match": "*", + "User-Agent": "azsdk-python-storage-blob/12.14.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)", + "x-ms-blob-type": "BlockBlob", + "x-ms-date": "Thu, 27 Oct 2022 21:29:05 GMT", + "x-ms-meta-a0": "a", + "x-ms-meta-a1": "a", + "x-ms-meta-a2": "a", + "x-ms-meta-a3": "a", + "x-ms-meta-a4": "a", + "x-ms-meta-a5": "a", + "x-ms-meta-a6": "a", + "x-ms-meta-a7": "a", + "x-ms-meta-a8": "a", + "x-ms-meta-a9": "a", + "x-ms-meta-a_": "a", + "x-ms-meta-a__": "a", + "x-ms-meta-b": "a", + "x-ms-meta-c": "a", + "x-ms-meta-F": "a", + "x-ms-meta-F_": "a", + "x-ms-meta-y": "a", + "x-ms-meta-z": "z_", + "x-ms-meta-_": "a", + "x-ms-meta-_a": "a", + "x-ms-meta-_a_": "a", + "x-ms-meta-_F": "a", + "x-ms-meta-_F_": "a", + "x-ms-meta-_z": "a", + "x-ms-meta-__": "a", + "x-ms-meta-__a": "a", + "x-ms-meta-__F": "a", + "x-ms-version": "2021-08-06" + }, + "RequestBody": "aGVsbG8gd29ybGQ=", + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Content-MD5": "XrY7u\u002BAe7tCTyyK7j1rNww==", + "Date": "Thu, 27 Oct 2022 21:29:05 GMT", + "ETag": "\u00220x8DAB86246AFF22E\u0022", + "Last-Modified": "Thu, 27 Oct 2022 21:29:05 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-content-crc64": "vo7q9sPVKY0=", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.pyTestStorageBlobAccessConditionstest_header_metadata_sort_in_upload_blob_fails.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.pyTestStorageBlobAccessConditionstest_header_metadata_sort_in_upload_blob_fails.json new file mode 100644 index 000000000000..d41001eeb3da --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions.pyTestStorageBlobAccessConditionstest_header_metadata_sort_in_upload_blob_fails.json @@ -0,0 +1,115 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer8a613ca5?restype=container", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)", + "x-ms-date": "Thu, 27 Oct 2022 21:28:50 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Thu, 27 Oct 2022 21:28:49 GMT", + "ETag": "\u00220x8DAB8623DC9963F\u0022", + "Last-Modified": "Thu, 27 Oct 2022 21:28:50 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer8a613ca5/blob1", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "11", + "Content-Type": "application/octet-stream", + "If-None-Match": "*", + "User-Agent": "azsdk-python-storage-blob/12.14.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)", + "x-ms-blob-type": "BlockBlob", + "x-ms-date": "Thu, 27 Oct 2022 21:28:51 GMT", + "x-ms-meta-!": "a", + "x-ms-meta-#": "a", + "x-ms-meta-$": "a", + "x-ms-meta-%": "a", + "x-ms-meta-\u0026": "a", + "x-ms-meta-*": "a", + "x-ms-meta-\u002B": "a", + "x-ms-meta--": "a", + "x-ms-meta-.": "a", + "x-ms-meta-0": "a", + "x-ms-meta-1": "a", + "x-ms-meta-2": "a", + "x-ms-meta-3": "a", + "x-ms-meta-4": "a", + "x-ms-meta-5": "a", + "x-ms-meta-6": "a", + "x-ms-meta-7": "a", + "x-ms-meta-8": "a", + "x-ms-meta-9": "a", + "x-ms-meta-a": "a", + "x-ms-meta-b": "a", + "x-ms-meta-c": "a", + "x-ms-meta-d": "a", + "x-ms-meta-e": "a", + "x-ms-meta-f": "a", + "x-ms-meta-g": "a", + "x-ms-meta-h": "a", + "x-ms-meta-i": "a", + "x-ms-meta-j": "a", + "x-ms-meta-k": "a", + "x-ms-meta-l": "a", + "x-ms-meta-m": "a", + "x-ms-meta-n": "a", + "x-ms-meta-o": "a", + "x-ms-meta-p": "a", + "x-ms-meta-q": "a", + "x-ms-meta-r": "a", + "x-ms-meta-s": "a", + "x-ms-meta-t": "a", + "x-ms-meta-u": "a", + "x-ms-meta-v": "a", + "x-ms-meta-w": "a", + "x-ms-meta-x": "a", + "x-ms-meta-y": "a", + "x-ms-meta-z": "a", + "x-ms-meta-^": "a", + "x-ms-meta-_": "a", + "x-ms-meta-|": "a", + "x-ms-meta-~": "a", + "x-ms-version": "2021-08-06" + }, + "RequestBody": "aGVsbG8gd29ybGQ=", + "StatusCode": 400, + "ResponseHeaders": { + "Content-Length": "260", + "Content-Type": "application/xml", + "Date": "Thu, 27 Oct 2022 21:28:51 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-error-code": "InvalidMetadata", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": [ + "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CError\u003E\u003CCode\u003EInvalidMetadata\u003C/Code\u003E\u003CMessage\u003EThe metadata specified is invalid. It has characters that are not permitted.\n", + "RequestId:e12165f9-901e-0066-244b-eab901000000\n", + "Time:2022-10-27T21:28:51.0513253Z\u003C/Message\u003E\u003C/Error\u003E" + ] + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.pyTestStorageBlobAccessConditionsAsynctest_header_metadata_sort_in_upload_blob.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.pyTestStorageBlobAccessConditionsAsynctest_header_metadata_sort_in_upload_blob.json new file mode 100644 index 000000000000..baf199b524f5 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.pyTestStorageBlobAccessConditionsAsynctest_header_metadata_sort_in_upload_blob.json @@ -0,0 +1,90 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainerccf33eb2?restype=container", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)", + "x-ms-date": "Thu, 27 Oct 2022 21:29:49 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Thu, 27 Oct 2022 21:29:49 GMT", + "ETag": "\u00220x8DAB86261019864\u0022", + "Last-Modified": "Thu, 27 Oct 2022 21:29:50 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainerccf33eb2/blob1", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "11", + "Content-Type": "application/octet-stream", + "If-None-Match": "*", + "User-Agent": "azsdk-python-storage-blob/12.14.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)", + "x-ms-blob-type": "BlockBlob", + "x-ms-date": "Thu, 27 Oct 2022 21:29:50 GMT", + "x-ms-meta-a0": "a", + "x-ms-meta-a1": "a", + "x-ms-meta-a2": "a", + "x-ms-meta-a3": "a", + "x-ms-meta-a4": "a", + "x-ms-meta-a5": "a", + "x-ms-meta-a6": "a", + "x-ms-meta-a7": "a", + "x-ms-meta-a8": "a", + "x-ms-meta-a9": "a", + "x-ms-meta-a_": "a", + "x-ms-meta-a__": "a", + "x-ms-meta-b": "a", + "x-ms-meta-c": "a", + "x-ms-meta-F": "a", + "x-ms-meta-F_": "a", + "x-ms-meta-y": "a", + "x-ms-meta-z": "z_", + "x-ms-meta-_": "a", + "x-ms-meta-_a": "a", + "x-ms-meta-_a_": "a", + "x-ms-meta-_F": "a", + "x-ms-meta-_F_": "a", + "x-ms-meta-_z": "a", + "x-ms-meta-__": "a", + "x-ms-meta-__a": "a", + "x-ms-meta-__F": "a", + "x-ms-version": "2021-08-06" + }, + "RequestBody": "aGVsbG8gd29ybGQ=", + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Content-MD5": "XrY7u\u002BAe7tCTyyK7j1rNww==", + "Date": "Thu, 27 Oct 2022 21:29:49 GMT", + "ETag": "\u00220x8DAB86261127126\u0022", + "Last-Modified": "Thu, 27 Oct 2022 21:29:50 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-content-crc64": "vo7q9sPVKY0=", + "x-ms-request-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.pyTestStorageBlobAccessConditionsAsynctest_header_metadata_sort_in_upload_blob_fails.json b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.pyTestStorageBlobAccessConditionsAsynctest_header_metadata_sort_in_upload_blob_fails.json new file mode 100644 index 000000000000..1724c34a04e8 --- /dev/null +++ b/sdk/storage/azure-storage-blob/tests/recordings/test_blob_access_conditions_async.pyTestStorageBlobAccessConditionsAsynctest_header_metadata_sort_in_upload_blob_fails.json @@ -0,0 +1,113 @@ +{ + "Entries": [ + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer52334120?restype=container", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "0", + "User-Agent": "azsdk-python-storage-blob/12.14.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)", + "x-ms-date": "Thu, 27 Oct 2022 21:29:36 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 201, + "ResponseHeaders": { + "Content-Length": "0", + "Date": "Thu, 27 Oct 2022 21:29:36 GMT", + "ETag": "\u00220x8DAB862592BC403\u0022", + "Last-Modified": "Thu, 27 Oct 2022 21:29:36 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://storagename.blob.core.windows.net/utcontainer52334120/blob1", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Content-Length": "11", + "Content-Type": "application/octet-stream", + "If-None-Match": "*", + "User-Agent": "azsdk-python-storage-blob/12.14.1 Python/3.10.2 (Windows-10-10.0.19044-SP0)", + "x-ms-blob-type": "BlockBlob", + "x-ms-date": "Thu, 27 Oct 2022 21:29:37 GMT", + "x-ms-meta-!": "a", + "x-ms-meta-#": "a", + "x-ms-meta-$": "a", + "x-ms-meta-%": "a", + "x-ms-meta-\u0026": "a", + "x-ms-meta-*": "a", + "x-ms-meta-\u002B": "a", + "x-ms-meta--": "a", + "x-ms-meta-.": "a", + "x-ms-meta-0": "a", + "x-ms-meta-1": "a", + "x-ms-meta-2": "a", + "x-ms-meta-3": "a", + "x-ms-meta-4": "a", + "x-ms-meta-5": "a", + "x-ms-meta-6": "a", + "x-ms-meta-7": "a", + "x-ms-meta-8": "a", + "x-ms-meta-9": "a", + "x-ms-meta-a": "a", + "x-ms-meta-b": "a", + "x-ms-meta-c": "a", + "x-ms-meta-d": "a", + "x-ms-meta-e": "a", + "x-ms-meta-f": "a", + "x-ms-meta-g": "a", + "x-ms-meta-h": "a", + "x-ms-meta-i": "a", + "x-ms-meta-j": "a", + "x-ms-meta-k": "a", + "x-ms-meta-l": "a", + "x-ms-meta-m": "a", + "x-ms-meta-n": "a", + "x-ms-meta-o": "a", + "x-ms-meta-p": "a", + "x-ms-meta-q": "a", + "x-ms-meta-r": "a", + "x-ms-meta-s": "a", + "x-ms-meta-t": "a", + "x-ms-meta-u": "a", + "x-ms-meta-v": "a", + "x-ms-meta-w": "a", + "x-ms-meta-x": "a", + "x-ms-meta-y": "a", + "x-ms-meta-z": "a", + "x-ms-meta-^": "a", + "x-ms-meta-_": "a", + "x-ms-meta-|": "a", + "x-ms-meta-~": "a", + "x-ms-version": "2021-08-06" + }, + "RequestBody": "aGVsbG8gd29ybGQ=", + "StatusCode": 400, + "ResponseHeaders": { + "Content-Length": "260", + "Content-Type": "application/xml", + "Date": "Thu, 27 Oct 2022 21:29:36 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "x-ms-error-code": "InvalidMetadata", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": [ + "\uFEFF\u003C?xml version=\u00221.0\u0022 encoding=\u0022utf-8\u0022?\u003E\u003CError\u003E\u003CCode\u003EInvalidMetadata\u003C/Code\u003E\u003CMessage\u003EThe metadata specified is invalid. It has characters that are not permitted.\n", + "RequestId:7641d680-401e-0007-6e4b-ea9a42000000\n", + "Time:2022-10-27T21:29:37.0102272Z\u003C/Message\u003E\u003C/Error\u003E" + ] + } + ], + "Variables": {} +} diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py index c92ff9f74b84..18fbae7ef491 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions.py @@ -3069,5 +3069,59 @@ def test_append_blob_from_bytes_with_if_none_match_fail(self, **kwargs): assert StorageErrorCode.condition_not_met == e.value.error_code + @BlobPreparer() + @recorded_by_proxy + def test_header_metadata_sort_in_upload_blob_fails(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + + self._setup() + data = b'hello world' + bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key) + try: + container_client = bsc.create_container(self.container_name) + except: + container_client = bsc.get_container_client(self.container_name) + blob_client = container_client.get_blob_client('blob1') + + # Relevant ASCII characters (excluding 'Bad Request' values) + ascii_subset = "!#$%&*+.-^_~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz|~" + + # Build out metadata + metadata = dict() + for c in ascii_subset: + metadata[c] = 'a' + + # Act + # If we hit invalid metadata error, that means we have successfully sorted headers properly to pass auth error + with pytest.raises(HttpResponseError) as e: + blob_client.upload_blob(data, length=len(data), metadata=metadata) + + # Assert + assert StorageErrorCode.invalid_metadata == e.value.error_code + + @BlobPreparer() + @recorded_by_proxy + def test_header_metadata_sort_in_upload_blob(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + + self._setup() + data = b'hello world' + bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key) + try: + container_client = bsc.create_container(self.container_name) + except: + container_client = bsc.get_container_client(self.container_name) + blob_client = container_client.get_blob_client('blob1') + + # Hand-picked metadata examples as Python & service don't sort '_' with the same weight + metadata = {'a0': 'a', 'a1': 'a', 'a2': 'a', 'a3': 'a', 'a4': 'a', 'a5': 'a', 'a6': 'a', 'a7': 'a', 'a8': 'a', + 'a9': 'a', '_': 'a', '_a': 'a', 'a_': 'a', '__': 'a', '_a_': 'a', 'b': 'a', 'c': 'a', 'y': 'a', + 'z': 'z_', '_z': 'a', '_F': 'a', 'F': 'a', 'F_': 'a', '_F_': 'a', '__F': 'a', '__a': 'a', 'a__': 'a' + } + + # Act + blob_client.upload_blob(data, length=len(data), metadata=metadata) # ------------------------------------------------------------------------------ diff --git a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py index 117d5635b8e6..2b21f444f00c 100644 --- a/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py +++ b/sdk/storage/azure-storage-blob/tests/test_blob_access_conditions_async.py @@ -1,5 +1,3 @@ -# coding: utf-8 - # ------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for @@ -3039,4 +3037,59 @@ async def test_apnd_blob_from_bytes_if_none_match_fail(self, **kwargs): assert StorageErrorCode.condition_not_met == e.value.error_code + @BlobPreparer() + @recorded_by_proxy_async + async def test_header_metadata_sort_in_upload_blob_fails(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + + self._setup() + data = b'hello world' + bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key) + try: + container_client = await bsc.create_container(self.container_name) + except: + container_client = bsc.get_container_client(self.container_name) + blob_client = container_client.get_blob_client('blob1') + + # Relevant ASCII characters (excluding 'Bad Request' values) + ascii_subset = "!#$%&*+.-^_~0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz|~" + + # Build out metadata + metadata = dict() + for c in ascii_subset: + metadata[c] = 'a' + + # Act + # If we hit invalid metadata error, that means we have successfully sorted headers properly to pass auth error + with pytest.raises(HttpResponseError) as e: + await blob_client.upload_blob(data, length=len(data), metadata=metadata) + + # Assert + assert StorageErrorCode.invalid_metadata == e.value.error_code + + @BlobPreparer() + @recorded_by_proxy_async + async def test_header_metadata_sort_in_upload_blob(self, **kwargs): + storage_account_name = kwargs.pop("storage_account_name") + storage_account_key = kwargs.pop("storage_account_key") + + self._setup() + data = b'hello world' + bsc = BlobServiceClient(self.account_url(storage_account_name, "blob"), storage_account_key) + try: + container_client = await bsc.create_container(self.container_name) + except: + container_client = bsc.get_container_client(self.container_name) + blob_client = container_client.get_blob_client('blob1') + + # Hand-picked metadata examples as Python & service don't sort '_' with the same weight + metadata = {'a0': 'a', 'a1': 'a', 'a2': 'a', 'a3': 'a', 'a4': 'a', 'a5': 'a', 'a6': 'a', 'a7': 'a', 'a8': 'a', + 'a9': 'a', '_': 'a', '_a': 'a', 'a_': 'a', '__': 'a', '_a_': 'a', 'b': 'a', 'c': 'a', 'y': 'a', + 'z': 'z_', '_z': 'a', '_F': 'a', 'F': 'a', 'F_': 'a', '_F_': 'a', '__F': 'a', '__a': 'a', 'a__': 'a' + } + + # Act + await blob_client.upload_blob(data, length=len(data), metadata=metadata) + # ------------------------------------------------------------------------------ diff --git a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py index d04c1e4fb539..4605f3c4334a 100644 --- a/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py +++ b/sdk/storage/azure-storage-file-datalake/azure/storage/filedatalake/_shared/authentication.py @@ -6,6 +6,7 @@ import logging import sys +from typing import List, Tuple try: from urllib.parse import urlparse, unquote @@ -47,6 +48,30 @@ def _wrap_exception(ex, desired_type): # TODO: In the future we will log the trace return desired_type('{}: {}'.format(ex.__class__.__name__, msg)) +# This method attempts to emulate the sorting done by the service +def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str, str]]: + # Define the custom alphabet for weights + custom_weights = "-!#$%&*.^_|~+\"\'(),/`~0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz{}" + + # Build dict of tuples and list of keys + header_dict = dict() + header_keys = [] + for k, v in input_headers: + header_dict[k] = v + header_keys.append(k) + + # Sort according to custom defined weights + try: + header_keys = sorted(header_keys, key=lambda word: [custom_weights.index(c) for c in word]) + except ValueError: + raise ValueError("Illegal character encountered when sorting headers.") + + # Build list of sorted tuples + sorted_headers = [] + for key in header_keys: + sorted_headers.append((key, header_dict.get(key))) + return sorted_headers + class AzureSigningError(ClientAuthenticationError): """ @@ -95,7 +120,7 @@ def _get_canonicalized_headers(request): for name, value in request.http_request.headers.items(): if name.startswith('x-ms-'): x_ms_headers.append((name.lower(), value)) - x_ms_headers.sort() + x_ms_headers = _storage_header_sort(x_ms_headers) for name, value in x_ms_headers: if value is not None: string_to_sign += ''.join([name, ':', value, '\n']) diff --git a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py index d04c1e4fb539..4605f3c4334a 100644 --- a/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py +++ b/sdk/storage/azure-storage-file-share/azure/storage/fileshare/_shared/authentication.py @@ -6,6 +6,7 @@ import logging import sys +from typing import List, Tuple try: from urllib.parse import urlparse, unquote @@ -47,6 +48,30 @@ def _wrap_exception(ex, desired_type): # TODO: In the future we will log the trace return desired_type('{}: {}'.format(ex.__class__.__name__, msg)) +# This method attempts to emulate the sorting done by the service +def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str, str]]: + # Define the custom alphabet for weights + custom_weights = "-!#$%&*.^_|~+\"\'(),/`~0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz{}" + + # Build dict of tuples and list of keys + header_dict = dict() + header_keys = [] + for k, v in input_headers: + header_dict[k] = v + header_keys.append(k) + + # Sort according to custom defined weights + try: + header_keys = sorted(header_keys, key=lambda word: [custom_weights.index(c) for c in word]) + except ValueError: + raise ValueError("Illegal character encountered when sorting headers.") + + # Build list of sorted tuples + sorted_headers = [] + for key in header_keys: + sorted_headers.append((key, header_dict.get(key))) + return sorted_headers + class AzureSigningError(ClientAuthenticationError): """ @@ -95,7 +120,7 @@ def _get_canonicalized_headers(request): for name, value in request.http_request.headers.items(): if name.startswith('x-ms-'): x_ms_headers.append((name.lower(), value)) - x_ms_headers.sort() + x_ms_headers = _storage_header_sort(x_ms_headers) for name, value in x_ms_headers: if value is not None: string_to_sign += ''.join([name, ':', value, '\n']) diff --git a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py index 64c6f722c823..86c1c7497751 100644 --- a/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py +++ b/sdk/storage/azure-storage-queue/azure/storage/queue/_shared/authentication.py @@ -5,6 +5,7 @@ # -------------------------------------------------------------------------- import logging +from typing import List, Tuple try: from urllib.parse import urlparse, unquote @@ -39,6 +40,31 @@ def _wrap_exception(ex, desired_type): msg = ex.args[0] return desired_type(msg) +# This method attempts to emulate the sorting done by the service +def _storage_header_sort(input_headers: List[Tuple[str, str]]) -> List[Tuple[str, str]]: + # Define the custom alphabet for weights + custom_weights = "-!#$%&*.^_|~+\"\'(),/`~0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]abcdefghijklmnopqrstuvwxyz{}" + + # Build dict of tuples and list of keys + header_dict = dict() + header_keys = [] + for k, v in input_headers: + header_dict[k] = v + header_keys.append(k) + + # Sort according to custom defined weights + try: + header_keys = sorted(header_keys, key=lambda word: [custom_weights.index(c) for c in word]) + except ValueError: + raise ValueError("Illegal character encountered when sorting headers.") + + # Build list of sorted tuples + sorted_headers = [] + for key in header_keys: + sorted_headers.append((key, header_dict.get(key))) + return sorted_headers + + class AzureSigningError(ClientAuthenticationError): """ Represents a fatal error when attempting to sign a request. @@ -86,7 +112,7 @@ def _get_canonicalized_headers(request): for name, value in request.http_request.headers.items(): if name.startswith('x-ms-'): x_ms_headers.append((name.lower(), value)) - x_ms_headers.sort() + x_ms_headers = _storage_header_sort(x_ms_headers) for name, value in x_ms_headers: if value is not None: string_to_sign += ''.join([name, ':', value, '\n']) From 3e4d0f092cc1f35597fdfc62e8d04b0663ced927 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 16 Nov 2022 21:11:31 -0500 Subject: [PATCH 2/7] [AutoRelease] t2-iothubprovisioningservices-2022-11-15-83563(can only be merged by SDK owner) (#27495) * code and test * Update CHANGELOG.md * Update _version.py Co-authored-by: PythonSdkPipelines Co-authored-by: zhenbiao wei <424401670@qq.com> --- .../CHANGELOG.md | 6 + .../MANIFEST.in | 1 + .../_meta.json | 12 +- .../iothubprovisioningservices/__init__.py | 18 +- .../_configuration.py | 55 +- .../_iot_dps_client.py | 25 +- .../iothubprovisioningservices/_metadata.json | 104 - .../mgmt/iothubprovisioningservices/_patch.py | 2 +- .../_serialization.py | 1970 +++++++++++++ .../iothubprovisioningservices/_vendor.py | 6 +- .../iothubprovisioningservices/_version.py | 2 +- .../aio/__init__.py | 18 +- .../aio/_configuration.py | 57 +- .../aio/_iot_dps_client.py | 25 +- .../iothubprovisioningservices/aio/_patch.py | 2 +- .../aio/operations/__init__.py | 12 +- .../operations/_dps_certificate_operations.py | 676 +++-- .../_iot_dps_resource_operations.py | 1679 ++++++++---- .../aio/operations/_operations.py | 116 +- .../aio/operations/_patch.py | 20 + .../models/__init__.py | 124 +- .../models/_iot_dps_client_enums.py | 64 +- .../models/_models_py3.py | 932 +++---- .../models/_patch.py | 20 + .../operations/__init__.py | 12 +- .../operations/_dps_certificate_operations.py | 1016 ++++--- .../_iot_dps_resource_operations.py | 2425 ++++++++++------- .../operations/_operations.py | 157 +- .../operations/_patch.py | 20 + .../generated_samples/dps_check_name.py | 40 + .../generated_samples/dps_create.py | 47 + .../dps_create_or_update_certificate.py | 43 + .../generated_samples/dps_delete.py | 41 + .../dps_delete_certificate.py | 43 + .../dps_generate_verification_code.py | 43 + .../generated_samples/dps_get.py | 41 + .../generated_samples/dps_get_certificate.py | 42 + .../generated_samples/dps_get_certificates.py | 41 + .../generated_samples/dps_get_key.py | 42 + .../dps_get_operation_result.py | 42 + .../generated_samples/dps_get_valid_sku.py | 42 + .../dps_list_by_resource_group.py | 41 + .../dps_list_by_subscription.py | 39 + .../generated_samples/dps_list_keys.py | 42 + .../generated_samples/dps_operations.py | 39 + .../dps_verify_certificate.py | 44 + ...te_endpoint_connection_create_or_update.py | 50 + .../private_endpoint_connection_delete.py | 42 + .../private_endpoint_connection_get.py | 42 + .../private_endpoint_connections_list.py | 41 + .../private_link_resources_list.py | 41 + .../setup.py | 8 +- shared_requirements.txt | 1 + 53 files changed, 7593 insertions(+), 2920 deletions(-) delete mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_metadata.json create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_serialization.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_patch.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_check_name.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_create.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_create_or_update_certificate.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_delete.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_delete_certificate.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_generate_verification_code.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_certificate.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_certificates.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_key.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_operation_result.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_valid_sku.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_by_resource_group.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_by_subscription.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_keys.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_operations.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_verify_certificate.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_create_or_update.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_delete.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_get.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connections_list.py create mode 100644 sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_link_resources_list.py diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/CHANGELOG.md b/sdk/iothub/azure-mgmt-iothubprovisioningservices/CHANGELOG.md index 0e238c69fd27..a1101fbecc61 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/CHANGELOG.md +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.2.0b1 (2022-11-15) + +### Features Added + + - Added model ErrorMessage + ## 1.1.0 (2022-02-07) **Features** diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/MANIFEST.in b/sdk/iothub/azure-mgmt-iothubprovisioningservices/MANIFEST.in index ae40ab69e601..9648960b3612 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/MANIFEST.in +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/MANIFEST.in @@ -1,5 +1,6 @@ include _meta.json recursive-include tests *.py *.json +recursive-include samples *.py *.md include *.md include azure/__init__.py include azure/mgmt/__init__.py diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/_meta.json b/sdk/iothub/azure-mgmt-iothubprovisioningservices/_meta.json index 1fb827bbaeab..f29625a5dc73 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/_meta.json +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "commit": "38995aeb1e63c781ae7c2cd176ea444480638093", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.12.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.2.1", + "@autorest/modelerfour@4.24.3" ], - "commit": "1134038a45bd1e65b1f6d77351b17df3617388f1", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/deviceprovisioningservices/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/deviceprovisioningservices/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.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/deviceprovisioningservices/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/__init__.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/__init__.py index ae180a5867e1..03c3f8b22200 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/__init__.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['IotDpsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "IotDpsClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_configuration.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_configuration.py index 56f64e498d4e..da27149d106f 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,30 +15,35 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential -class IotDpsClientConfiguration(Configuration): +class IotDpsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotDpsClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-02-05". 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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotDpsClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-02-05") # type: Literal["2022-02-05"] + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +51,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-10-15" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothubprovisioningservices/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothubprovisioningservices/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_iot_dps_client.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_iot_dps_client.py index a628fc94cabc..3c7add4259e0 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_iot_dps_client.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_iot_dps_client.py @@ -7,21 +7,22 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import IotDpsClientConfiguration +from ._serialization import Deserializer, Serializer from .operations import DpsCertificateOperations, IotDpsResourceOperations, Operations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class IotDpsClient: + +class IotDpsClient: # pylint: disable=client-accepts-api-version-keyword """API for using the Azure IoT Hub Device Provisioning Service features. :ivar operations: Operations operations @@ -32,12 +33,15 @@ class IotDpsClient: :ivar iot_dps_resource: IotDpsResourceOperations operations :vartype iot_dps_resource: azure.mgmt.iothubprovisioningservices.operations.IotDpsResourceOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-02-05". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -60,12 +64,7 @@ def __init__( self.dps_certificate = DpsCertificateOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_dps_resource = IotDpsResourceOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +73,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_metadata.json b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_metadata.json deleted file mode 100644 index e993676a8c68..000000000000 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_metadata.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "chosen_version": "2021-10-15", - "total_api_version_list": ["2021-10-15"], - "client": { - "name": "IotDpsClient", - "filename": "_iot_dps_client", - "description": "API for using the Azure IoT Hub Device Provisioning Service features.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotDpsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotDpsClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The subscription identifier.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The subscription identifier.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "operations": "Operations", - "dps_certificate": "DpsCertificateOperations", - "iot_dps_resource": "IotDpsResourceOperations" - } -} \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_patch.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_patch.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_serialization.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_serialization.py new file mode 100644 index 000000000000..7c1dedb5133d --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # 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 + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # 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("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + 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) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **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) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + 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: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, 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:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_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:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + 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=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + 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"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_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) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + 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: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + 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) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + 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) + else: + return date_obj diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_vendor.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_vendor.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_version.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_version.py index 59deb8c7263b..58920e6942de 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_version.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0" +VERSION = "1.2.0b1" diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/__init__.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/__init__.py index c8929d76b8ae..0cd79bfedc12 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._iot_dps_client import IotDpsClient -__all__ = ['IotDpsClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "IotDpsClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_configuration.py index 66c5084c7e5f..2a118cc09e97 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,30 +15,35 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential -class IotDpsClientConfiguration(Configuration): +class IotDpsClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for IotDpsClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-02-05". 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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(IotDpsClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-02-05") # type: Literal["2022-02-05"] + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +51,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-10-15" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-iothubprovisioningservices/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-iothubprovisioningservices/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_iot_dps_client.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_iot_dps_client.py index f82d1c38896d..f31ea70bfb6e 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_iot_dps_client.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_iot_dps_client.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from .._serialization import Deserializer, Serializer from ._configuration import IotDpsClientConfiguration from .operations import DpsCertificateOperations, IotDpsResourceOperations, Operations @@ -21,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class IotDpsClient: + +class IotDpsClient: # pylint: disable=client-accepts-api-version-keyword """API for using the Azure IoT Hub Device Provisioning Service features. :ivar operations: Operations operations @@ -32,12 +33,15 @@ class IotDpsClient: :ivar iot_dps_resource: IotDpsResourceOperations operations :vartype iot_dps_resource: azure.mgmt.iothubprovisioningservices.aio.operations.IotDpsResourceOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The subscription identifier. + :param subscription_id: The subscription identifier. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-02-05". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -60,12 +64,7 @@ def __init__( self.dps_certificate = DpsCertificateOperations(self._client, self._config, self._serialize, self._deserialize) self.iot_dps_resource = IotDpsResourceOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +73,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_patch.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_patch.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/__init__.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/__init__.py index 6d426f86fd28..2e94c2e6fa16 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._dps_certificate_operations import DpsCertificateOperations from ._iot_dps_resource_operations import IotDpsResourceOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DpsCertificateOperations', - 'IotDpsResourceOperations', + "Operations", + "DpsCertificateOperations", + "IotDpsResourceOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_dps_certificate_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_dps_certificate_operations.py index cc88345014b9..8aec7dada1af 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_dps_certificate_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_dps_certificate_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,44 +7,61 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request -from ...operations._dps_certificate_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_request, build_verify_certificate_request -T = TypeVar('T') +from ...operations._dps_certificate_operations import ( + build_create_or_update_request, + build_delete_request, + build_generate_verification_code_request, + build_get_request, + build_list_request, + build_verify_certificate_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class DpsCertificateOperations: - """DpsCertificateOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class DpsCertificateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothubprovisioningservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothubprovisioningservices.aio.IotDpsClient`'s + :attr:`dps_certificate` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( @@ -53,42 +71,57 @@ async def get( provisioning_service_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateResponse": + ) -> _models.CertificateResponse: """Get the certificate from the provisioning service. - :param certificate_name: Name of the certificate to retrieve. + :param certificate_name: Name of the certificate to retrieve. Required. :type certificate_name: str - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str :param provisioning_service_name: Name of the provisioning service the certificate is - associated with. + associated with. Required. :type provisioning_service_name: str - :param if_match: ETag of the certificate. + :param if_match: ETag of the certificate. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResponse, or the result of cls(response) + :return: CertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResponse] - request = build_get_request( certificate_name=certificate_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -96,15 +129,87 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResponse', pipeline_response) + deserialized = self._deserialize("CertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + provisioning_service_name: str, + certificate_name: str, + certificate_description: _models.CertificateResponse, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateResponse: + """Upload the certificate to the provisioning service. + + Add new certificate or update an existing certificate. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: The name of the provisioning service. Required. + :type provisioning_service_name: str + :param certificate_name: The name of the certificate create or update. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: + ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse + :param if_match: ETag of the certificate. This is required to update an existing certificate, + and ignored while creating a brand new certificate. Default value is None. + :type if_match: str + :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: CertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def create_or_update( + self, + resource_group_name: str, + provisioning_service_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateResponse: + """Upload the certificate to the provisioning service. + + Add new certificate or update an existing certificate. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: The name of the provisioning service. Required. + :type provisioning_service_name: str + :param certificate_name: The name of the certificate create or update. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the certificate. This is required to update an existing certificate, + and ignored while creating a brand new certificate. 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: CertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def create_or_update( @@ -112,55 +217,81 @@ async def create_or_update( resource_group_name: str, provisioning_service_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateResponse, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateResponse": + ) -> _models.CertificateResponse: """Upload the certificate to the provisioning service. Add new certificate or update an existing certificate. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param provisioning_service_name: The name of the provisioning service. + :param provisioning_service_name: The name of the provisioning service. Required. :type provisioning_service_name: str - :param certificate_name: The name of the certificate create or update. + :param certificate_name: The name of the certificate create or update. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: - ~azure.mgmt.iothubprovisioningservices.models.CertificateBodyDescription + ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse or IO :param if_match: ETag of the certificate. This is required to update an existing certificate, - and ignored while creating a brand new certificate. + and ignored while creating a brand new certificate. 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: CertificateResponse, or the result of cls(response) + :return: CertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResponse] - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateResponse") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -168,27 +299,26 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResponse', pipeline_response) + deserialized = self._deserialize("CertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( + async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, if_match: str, provisioning_service_name: str, certificate_name: str, certificate_name1: Optional[str] = None, - certificate_raw_bytes: Optional[bytearray] = None, + certificate_raw_bytes: Optional[bytes] = None, certificate_is_verified: Optional[bool] = None, - certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, certificate_created: Optional[datetime.datetime] = None, certificate_last_updated: Optional[datetime.datetime] = None, certificate_has_private_key: Optional[bool] = None, @@ -199,50 +329,63 @@ async def delete( Deletes the specified certificate associated with the Provisioning Service. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param if_match: ETag of the certificate. + :param if_match: ETag of the certificate. Required. :type if_match: str - :param provisioning_service_name: The name of the provisioning service. + :param provisioning_service_name: The name of the provisioning service. Required. :type provisioning_service_name: str :param certificate_name: This is a mandatory field, and is the logical name of the certificate - that the provisioning service will access by. + that the provisioning service will access by. Required. :type certificate_name: str :param certificate_name1: This is optional, and it is the Common Name of the certificate. + Default value is None. :type certificate_name1: str - :param certificate_raw_bytes: Raw data within the certificate. - :type certificate_raw_bytes: bytearray + :param certificate_raw_bytes: Raw data within the certificate. Default value is None. + :type certificate_raw_bytes: bytes :param certificate_is_verified: Indicates if certificate has been verified by owner of the - private key. + private key. Default value is None. :type certificate_is_verified: bool - :param certificate_purpose: A description that mentions the purpose of the certificate. + :param certificate_purpose: A description that mentions the purpose of the certificate. Known + values are: "clientAuthentication" and "serverAuthentication". Default value is None. :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose - :param certificate_created: Time the certificate is created. + :param certificate_created: Time the certificate is created. Default value is None. :type certificate_created: ~datetime.datetime - :param certificate_last_updated: Time the certificate is last updated. + :param certificate_last_updated: Time the certificate is last updated. Default value is None. :type certificate_last_updated: ~datetime.datetime :param certificate_has_private_key: Indicates if the certificate contains a private key. + Default value is None. :type certificate_has_private_key: bool - :param certificate_nonce: Random number generated to indicate Proof of Possession. + :param certificate_nonce: Random number generated to indicate Proof of Possession. Default + value is None. :type certificate_nonce: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, certificate_name1=certificate_name1, certificate_raw_bytes=certificate_raw_bytes, @@ -252,12 +395,18 @@ async def delete( certificate_last_updated=certificate_last_updated, certificate_has_private_key=certificate_has_private_key, certificate_nonce=certificate_nonce, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -268,44 +417,56 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}"} # type: ignore @distributed_trace_async async def list( - self, - resource_group_name: str, - provisioning_service_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, provisioning_service_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get all the certificates tied to the provisioning service. - :param resource_group_name: Name of resource group. + :param resource_group_name: Name of resource group. Required. :type resource_group_name: str :param provisioning_service_name: Name of provisioning service to retrieve certificates for. + Required. :type provisioning_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -313,15 +474,14 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates"} # type: ignore @distributed_trace_async async def generate_verification_code( @@ -331,62 +491,74 @@ async def generate_verification_code( resource_group_name: str, provisioning_service_name: str, certificate_name1: Optional[str] = None, - certificate_raw_bytes: Optional[bytearray] = None, + certificate_raw_bytes: Optional[bytes] = None, certificate_is_verified: Optional[bool] = None, - certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, certificate_created: Optional[datetime.datetime] = None, certificate_last_updated: Optional[datetime.datetime] = None, certificate_has_private_key: Optional[bool] = None, certificate_nonce: Optional[str] = None, **kwargs: Any - ) -> "_models.VerificationCodeResponse": + ) -> _models.VerificationCodeResponse: """Generate verification code for Proof of Possession. :param certificate_name: The mandatory logical name of the certificate, that the provisioning - service uses to access. + service uses to access. Required. :type certificate_name: str :param if_match: ETag of the certificate. This is required to update an existing certificate, - and ignored while creating a brand new certificate. + and ignored while creating a brand new certificate. Required. :type if_match: str - :param resource_group_name: name of resource group. + :param resource_group_name: name of resource group. Required. :type resource_group_name: str - :param provisioning_service_name: Name of provisioning service. + :param provisioning_service_name: Name of provisioning service. Required. :type provisioning_service_name: str - :param certificate_name1: Common Name for the certificate. + :param certificate_name1: Common Name for the certificate. Default value is None. :type certificate_name1: str - :param certificate_raw_bytes: Raw data of certificate. - :type certificate_raw_bytes: bytearray + :param certificate_raw_bytes: Raw data of certificate. Default value is None. + :type certificate_raw_bytes: bytes :param certificate_is_verified: Indicates if the certificate has been verified by owner of the - private key. + private key. Default value is None. :type certificate_is_verified: bool - :param certificate_purpose: Description mentioning the purpose of the certificate. + :param certificate_purpose: Description mentioning the purpose of the certificate. Known values + are: "clientAuthentication" and "serverAuthentication". Default value is None. :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose - :param certificate_created: Certificate creation time. + :param certificate_created: Certificate creation time. Default value is None. :type certificate_created: ~datetime.datetime - :param certificate_last_updated: Certificate last updated time. + :param certificate_last_updated: Certificate last updated time. Default value is None. :type certificate_last_updated: ~datetime.datetime - :param certificate_has_private_key: Indicates if the certificate contains private key. + :param certificate_has_private_key: Indicates if the certificate contains private key. Default + value is None. :type certificate_has_private_key: bool - :param certificate_nonce: Random number generated to indicate Proof of Possession. + :param certificate_nonce: Random number generated to indicate Proof of Possession. Default + value is None. :type certificate_nonce: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VerificationCodeResponse, or the result of cls(response) + :return: VerificationCodeResponse or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VerificationCodeResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VerificationCodeResponse] - request = build_generate_verification_code_request( certificate_name=certificate_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, if_match=if_match, certificate_name1=certificate_name1, certificate_raw_bytes=certificate_raw_bytes, @@ -396,12 +568,18 @@ async def generate_verification_code( certificate_last_updated=certificate_last_updated, certificate_has_private_key=certificate_has_private_key, certificate_nonce=certificate_nonce, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -409,15 +587,146 @@ async def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VerificationCodeResponse', pipeline_response) + deserialized = self._deserialize("VerificationCodeResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + @overload + async def verify_certificate( + self, + certificate_name: str, + if_match: str, + resource_group_name: str, + provisioning_service_name: str, + request: _models.VerificationCodeRequest, + certificate_name1: Optional[str] = None, + certificate_raw_bytes: Optional[bytes] = None, + certificate_is_verified: Optional[bool] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, + certificate_created: Optional[datetime.datetime] = None, + certificate_last_updated: Optional[datetime.datetime] = None, + certificate_has_private_key: Optional[bool] = None, + certificate_nonce: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateResponse: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param certificate_name: The mandatory logical name of the certificate, that the provisioning + service uses to access. Required. + :type certificate_name: str + :param if_match: ETag of the certificate. Required. + :type if_match: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param provisioning_service_name: Provisioning service name. Required. + :type provisioning_service_name: str + :param request: The name of the certificate. Required. + :type request: ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeRequest + :param certificate_name1: Common Name for the certificate. Default value is None. + :type certificate_name1: str + :param certificate_raw_bytes: Raw data of certificate. Default value is None. + :type certificate_raw_bytes: bytes + :param certificate_is_verified: Indicates if the certificate has been verified by owner of the + private key. Default value is None. + :type certificate_is_verified: bool + :param certificate_purpose: Describe the purpose of the certificate. Known values are: + "clientAuthentication" and "serverAuthentication". Default value is None. + :type certificate_purpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :param certificate_created: Certificate creation time. Default value is None. + :type certificate_created: ~datetime.datetime + :param certificate_last_updated: Certificate last updated time. Default value is None. + :type certificate_last_updated: ~datetime.datetime + :param certificate_has_private_key: Indicates if the certificate contains private key. Default + value is None. + :type certificate_has_private_key: bool + :param certificate_nonce: Random number generated to indicate Proof of Possession. Default + value is None. + :type certificate_nonce: str + :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: CertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def verify_certificate( + self, + certificate_name: str, + if_match: str, + resource_group_name: str, + provisioning_service_name: str, + request: IO, + certificate_name1: Optional[str] = None, + certificate_raw_bytes: Optional[bytes] = None, + certificate_is_verified: Optional[bool] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, + certificate_created: Optional[datetime.datetime] = None, + certificate_last_updated: Optional[datetime.datetime] = None, + certificate_has_private_key: Optional[bool] = None, + certificate_nonce: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateResponse: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param certificate_name: The mandatory logical name of the certificate, that the provisioning + service uses to access. Required. + :type certificate_name: str + :param if_match: ETag of the certificate. Required. + :type if_match: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param provisioning_service_name: Provisioning service name. Required. + :type provisioning_service_name: str + :param request: The name of the certificate. Required. + :type request: IO + :param certificate_name1: Common Name for the certificate. Default value is None. + :type certificate_name1: str + :param certificate_raw_bytes: Raw data of certificate. Default value is None. + :type certificate_raw_bytes: bytes + :param certificate_is_verified: Indicates if the certificate has been verified by owner of the + private key. Default value is None. + :type certificate_is_verified: bool + :param certificate_purpose: Describe the purpose of the certificate. Known values are: + "clientAuthentication" and "serverAuthentication". Default value is None. + :type certificate_purpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :param certificate_created: Certificate creation time. Default value is None. + :type certificate_created: ~datetime.datetime + :param certificate_last_updated: Certificate last updated time. Default value is None. + :type certificate_last_updated: ~datetime.datetime + :param certificate_has_private_key: Indicates if the certificate contains private key. Default + value is None. + :type certificate_has_private_key: bool + :param certificate_nonce: Random number generated to indicate Proof of Possession. Default + value is None. + :type certificate_nonce: 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: CertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def verify_certificate( @@ -426,74 +735,93 @@ async def verify_certificate( if_match: str, resource_group_name: str, provisioning_service_name: str, - request: "_models.VerificationCodeRequest", + request: Union[_models.VerificationCodeRequest, IO], certificate_name1: Optional[str] = None, - certificate_raw_bytes: Optional[bytearray] = None, + certificate_raw_bytes: Optional[bytes] = None, certificate_is_verified: Optional[bool] = None, - certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, certificate_created: Optional[datetime.datetime] = None, certificate_last_updated: Optional[datetime.datetime] = None, certificate_has_private_key: Optional[bool] = None, certificate_nonce: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateResponse": + ) -> _models.CertificateResponse: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. :param certificate_name: The mandatory logical name of the certificate, that the provisioning - service uses to access. + service uses to access. Required. :type certificate_name: str - :param if_match: ETag of the certificate. + :param if_match: ETag of the certificate. Required. :type if_match: str - :param resource_group_name: Resource group name. + :param resource_group_name: Resource group name. Required. :type resource_group_name: str - :param provisioning_service_name: Provisioning service name. + :param provisioning_service_name: Provisioning service name. Required. :type provisioning_service_name: str - :param request: The name of the certificate. - :type request: ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeRequest - :param certificate_name1: Common Name for the certificate. + :param request: The name of the certificate. Is either a model type or a IO type. Required. + :type request: ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeRequest or IO + :param certificate_name1: Common Name for the certificate. Default value is None. :type certificate_name1: str - :param certificate_raw_bytes: Raw data of certificate. - :type certificate_raw_bytes: bytearray + :param certificate_raw_bytes: Raw data of certificate. Default value is None. + :type certificate_raw_bytes: bytes :param certificate_is_verified: Indicates if the certificate has been verified by owner of the - private key. + private key. Default value is None. :type certificate_is_verified: bool - :param certificate_purpose: Describe the purpose of the certificate. + :param certificate_purpose: Describe the purpose of the certificate. Known values are: + "clientAuthentication" and "serverAuthentication". Default value is None. :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose - :param certificate_created: Certificate creation time. + :param certificate_created: Certificate creation time. Default value is None. :type certificate_created: ~datetime.datetime - :param certificate_last_updated: Certificate last updated time. + :param certificate_last_updated: Certificate last updated time. Default value is None. :type certificate_last_updated: ~datetime.datetime - :param certificate_has_private_key: Indicates if the certificate contains private key. + :param certificate_has_private_key: Indicates if the certificate contains private key. Default + value is None. :type certificate_has_private_key: bool - :param certificate_nonce: Random number generated to indicate Proof of Possession. + :param certificate_nonce: Random number generated to indicate Proof of Possession. Default + value is None. :type certificate_nonce: 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: CertificateResponse, or the result of cls(response) + :return: CertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - _json = self._serialize.body(request, 'VerificationCodeRequest') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(request, (IO, bytes)): + _content = request + else: + _json = self._serialize.body(request, "VerificationCodeRequest") request = build_verify_certificate_request( certificate_name=certificate_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, - json=_json, certificate_name1=certificate_name1, certificate_raw_bytes=certificate_raw_bytes, certificate_is_verified=certificate_is_verified, @@ -502,12 +830,21 @@ async def verify_certificate( certificate_last_updated=certificate_last_updated, certificate_has_private_key=certificate_has_private_key, certificate_nonce=certificate_nonce, - template_url=self.verify_certificate.metadata['url'], + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.verify_certificate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -515,12 +852,11 @@ async def verify_certificate( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResponse', pipeline_response) + deserialized = self._deserialize("CertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify'} # type: ignore - + verify_certificate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_iot_dps_resource_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_iot_dps_resource_operations.py index 86225427c2de..05f27c722fc3 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_iot_dps_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_iot_dps_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,86 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, List, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._iot_dps_resource_operations import build_check_provisioning_service_name_availability_request, build_create_or_update_private_endpoint_connection_request_initial, build_create_or_update_request_initial, build_delete_private_endpoint_connection_request_initial, build_delete_request_initial, build_get_operation_result_request, build_get_private_endpoint_connection_request, build_get_private_link_resources_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_keys_for_key_name_request, build_list_keys_request, build_list_private_endpoint_connections_request, build_list_private_link_resources_request, build_list_valid_skus_request, build_update_request_initial -T = TypeVar('T') +from ...operations._iot_dps_resource_operations import ( + build_check_provisioning_service_name_availability_request, + build_create_or_update_private_endpoint_connection_request, + build_create_or_update_request, + build_delete_private_endpoint_connection_request, + build_delete_request, + build_get_operation_result_request, + build_get_private_endpoint_connection_request, + build_get_private_link_resources_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_keys_for_key_name_request, + build_list_keys_request, + build_list_private_endpoint_connections_request, + build_list_private_link_resources_request, + build_list_valid_skus_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class IotDpsResourceOperations: - """IotDpsResourceOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotDpsResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothubprovisioningservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothubprovisioningservices.aio.IotDpsClient`'s + :attr:`iot_dps_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async async def get( - self, - provisioning_service_name: str, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ProvisioningServiceDescription": + self, provisioning_service_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.ProvisioningServiceDescription: """Get the non-security related metadata of the provisioning service. Get the metadata of the provisioning service without SAS keys. - :param provisioning_service_name: Name of the provisioning service to retrieve. + :param provisioning_service_name: Name of the provisioning service to retrieve. Required. :type provisioning_service_name: str - :param resource_group_name: Resource group name. + :param resource_group_name: Resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProvisioningServiceDescription, or the result of cls(response) + :return: ProvisioningServiceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescription] - request = build_get_request( provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -92,86 +134,113 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, provisioning_service_name: str, - iot_dps_description: "_models.ProvisioningServiceDescription", + iot_dps_description: Union[_models.ProvisioningServiceDescription, IO], **kwargs: Any - ) -> "_models.ProvisioningServiceDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] + ) -> _models.ProvisioningServiceDescription: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_dps_description, 'ProvisioningServiceDescription') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_dps_description, (IO, bytes)): + _content = iot_dps_description + else: + _json = self._serialize.body(iot_dps_description, "ProvisioningServiceDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create_or_update( self, resource_group_name: str, provisioning_service_name: str, - iot_dps_description: "_models.ProvisioningServiceDescription", + iot_dps_description: _models.ProvisioningServiceDescription, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.ProvisioningServiceDescription"]: + ) -> AsyncLROPoller[_models.ProvisioningServiceDescription]: """Create or update the metadata of the provisioning service. Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve the provisioning service metadata and security metadata, and then combine them with the modified values in a new body to update the provisioning service. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param provisioning_service_name: Name of provisioning service to create or update. + :param provisioning_service_name: Name of provisioning service to create or update. Required. :type provisioning_service_name: str :param iot_dps_description: Description of the provisioning service to create or update. + Required. :type iot_dps_description: ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription + :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 @@ -184,115 +253,307 @@ async def begin_create_or_update( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + provisioning_service_name: str, + iot_dps_description: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ProvisioningServiceDescription]: + """Create or update the metadata of the provisioning service. + + Create or update the metadata of the provisioning service. The usual pattern to modify a + property is to retrieve the provisioning service metadata and security metadata, and then + combine them with the modified values in a new body to update the provisioning service. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service to create or update. Required. + :type provisioning_service_name: str + :param iot_dps_description: Description of the provisioning service to create or update. + Required. + :type iot_dps_description: IO + :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 ProvisioningServiceDescription or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + provisioning_service_name: str, + iot_dps_description: Union[_models.ProvisioningServiceDescription, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.ProvisioningServiceDescription]: + """Create or update the metadata of the provisioning service. + + Create or update the metadata of the provisioning service. The usual pattern to modify a + property is to retrieve the provisioning service metadata and security metadata, and then + combine them with the modified values in a new body to update the provisioning service. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service to create or update. Required. + :type provisioning_service_name: str + :param iot_dps_description: Description of the provisioning service to create or update. Is + either a model type or a IO type. Required. + :type iot_dps_description: + ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription 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. + :return: An instance of AsyncLROPoller that returns either ProvisioningServiceDescription or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, iot_dps_description=iot_dps_description, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore async def _update_initial( self, resource_group_name: str, provisioning_service_name: str, - provisioning_service_tags: "_models.TagsResource", + provisioning_service_tags: Union[_models.TagsResource, IO], **kwargs: Any - ) -> "_models.ProvisioningServiceDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] + ) -> _models.ProvisioningServiceDescription: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(provisioning_service_tags, 'TagsResource') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(provisioning_service_tags, (IO, bytes)): + _content = provisioning_service_tags + else: + _json = self._serialize.body(provisioning_service_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + provisioning_service_name: str, + provisioning_service_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ProvisioningServiceDescription]: + """Update an existing provisioning service's tags. + + Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate + method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service to create or update. Required. + :type provisioning_service_name: str + :param provisioning_service_tags: Updated tag information to set into the provisioning service + instance. Required. + :type provisioning_service_tags: ~azure.mgmt.iothubprovisioningservices.models.TagsResource + :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 ProvisioningServiceDescription or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + provisioning_service_name: str, + provisioning_service_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.ProvisioningServiceDescription]: + """Update an existing provisioning service's tags. + + Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate + method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service to create or update. Required. + :type provisioning_service_name: str + :param provisioning_service_tags: Updated tag information to set into the provisioning service + instance. Required. + :type provisioning_service_tags: IO + :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 ProvisioningServiceDescription or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, provisioning_service_name: str, - provisioning_service_tags: "_models.TagsResource", + provisioning_service_tags: Union[_models.TagsResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.ProvisioningServiceDescription"]: + ) -> AsyncLROPoller[_models.ProvisioningServiceDescription]: """Update an existing provisioning service's tags. Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param provisioning_service_name: Name of provisioning service to create or update. + :param provisioning_service_name: Name of provisioning service to create or update. Required. :type provisioning_service_name: str :param provisioning_service_tags: Updated tag information to set into the provisioning service - instance. - :type provisioning_service_tags: ~azure.mgmt.iothubprovisioningservices.models.TagsResource + instance. Is either a model type or a IO type. Required. + :type provisioning_service_tags: ~azure.mgmt.iothubprovisioningservices.models.TagsResource 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 @@ -305,99 +566,114 @@ async def begin_update( the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, provisioning_service_tags=provisioning_service_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore - async def _delete_initial( - self, - provisioning_service_name: str, - resource_group_name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, provisioning_service_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - provisioning_service_name: str, - resource_group_name: str, - **kwargs: Any + self, provisioning_service_name: str, resource_group_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the Provisioning Service. Deletes the Provisioning Service. - :param provisioning_service_name: Name of provisioning service to delete. + :param provisioning_service_name: Name of provisioning service to delete. Required. :type provisioning_service_name: str - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_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. @@ -409,83 +685,108 @@ async def begin_delete( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore provisioning_service_name=provisioning_service_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ProvisioningServiceDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.ProvisioningServiceDescription"]: """Get all the provisioning services in a subscription. List all the provisioning services for a given subscription id. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProvisioningServiceDescriptionListResult or the - result of cls(response) + :return: An iterator like instance of either ProvisioningServiceDescription or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescriptionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescriptionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -499,7 +800,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -509,54 +812,70 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.ProvisioningServiceDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ProvisioningServiceDescription"]: """Get a list of all provisioning services in the given resource group. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. 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 ProvisioningServiceDescriptionListResult or the - result of cls(response) + :return: An iterator like instance of either ProvisioningServiceDescription or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescriptionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescriptionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -570,7 +889,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -580,11 +901,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices"} # type: ignore @distributed_trace_async async def get_operation_result( @@ -594,45 +913,60 @@ async def get_operation_result( provisioning_service_name: str, asyncinfo: str = "true", **kwargs: Any - ) -> "_models.AsyncOperationResult": + ) -> _models.AsyncOperationResult: """Gets the status of a long running operation, such as create, update or delete a provisioning service. :param operation_id: Operation id corresponding to long running operation. Use this to poll for - the status. + the status. Required. :type operation_id: str - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str :param provisioning_service_name: Name of provisioning service that the operation is running - on. + on. Required. :type provisioning_service_name: str :param asyncinfo: Async header used to poll on the status of the operation, obtained while - creating the long running operation. + creating the long running operation. Default value is "true". :type asyncinfo: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AsyncOperationResult] - request = build_get_operation_result_request( operation_id=operation_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, asyncinfo=asyncinfo, - template_url=self.get_operation_result.metadata['url'], + api_version=api_version, + template_url=self.get_operation_result.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -640,65 +974,79 @@ async def get_operation_result( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_operation_result.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}'} # type: ignore - + get_operation_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}"} # type: ignore @distributed_trace def list_valid_skus( - self, - provisioning_service_name: str, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.IotDpsSkuDefinitionListResult"]: + self, provisioning_service_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.IotDpsSkuDefinition"]: """Get the list of valid SKUs for a provisioning service. Gets the list of valid SKUs and tiers for a provisioning service. - :param provisioning_service_name: Name of provisioning service. + :param provisioning_service_name: Name of provisioning service. Required. :type provisioning_service_name: str - :param resource_group_name: Name of resource group. + :param resource_group_name: Name of resource group. 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 IotDpsSkuDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either IotDpsSkuDefinition or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotDpsSkuDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotDpsSkuDefinitionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_valid_skus_request( provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_valid_skus_request( - provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -712,7 +1060,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -722,51 +1072,114 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus'} # type: ignore + list_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus"} # type: ignore - @distributed_trace_async + @overload async def check_provisioning_service_name_availability( - self, - arguments: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.NameAvailabilityInfo": + self, arguments: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityInfo: """Check if a provisioning service name is available. Check if a provisioning service name is available. This will validate if the name is syntactically valid and if the name is usable. :param arguments: Set the name parameter in the OperationInputs structure to the name of the - provisioning service to check. + provisioning service to check. Required. :type arguments: ~azure.mgmt.iothubprovisioningservices.models.OperationInputs + :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: NameAvailabilityInfo, or the result of cls(response) + :return: NameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.NameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + async def check_provisioning_service_name_availability( + self, arguments: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityInfo: + """Check if a provisioning service name is available. + + Check if a provisioning service name is available. This will validate if the name is + syntactically valid and if the name is usable. + + :param arguments: Set the name parameter in the OperationInputs structure to the name of the + provisioning service to check. Required. + :type arguments: IO + :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: NameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.NameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ - _json = self._serialize.body(arguments, 'OperationInputs') + @distributed_trace_async + async def check_provisioning_service_name_availability( + self, arguments: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.NameAvailabilityInfo: + """Check if a provisioning service name is available. + + Check if a provisioning service name is available. This will validate if the name is + syntactically valid and if the name is usable. + + :param arguments: Set the name parameter in the OperationInputs structure to the name of the + provisioning service to check. Is either a model type or a IO type. Required. + :type arguments: ~azure.mgmt.iothubprovisioningservices.models.OperationInputs 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 + :return: NameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.NameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(arguments, (IO, bytes)): + _content = arguments + else: + _json = self._serialize.body(arguments, "OperationInputs") request = build_check_provisioning_service_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_provisioning_service_name_availability.metadata['url'], + content=_content, + template_url=self.check_provisioning_service_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -774,66 +1187,81 @@ async def check_provisioning_service_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("NameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_provisioning_service_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability'} # type: ignore - + check_provisioning_service_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability"} # type: ignore @distributed_trace def list_keys( - self, - provisioning_service_name: str, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, provisioning_service_name: str, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription"]: """Get the security metadata for a provisioning service. List the primary and secondary keys for a provisioning service. :param provisioning_service_name: The provisioning service name to get the shared access keys - for. + for. Required. :type provisioning_service_name: str - :param resource_group_name: resource group name. + :param resource_group_name: resource group name. 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 SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either + SharedAccessSignatureAuthorizationRuleAccessRightsDescription or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -847,7 +1275,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -857,56 +1287,67 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys"} # type: ignore @distributed_trace_async async def list_keys_for_key_name( - self, - provisioning_service_name: str, - key_name: str, - resource_group_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription": + self, provisioning_service_name: str, key_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription: """Get a shared access policy by name from a provisioning service. List primary and secondary keys for a specific key name. - :param provisioning_service_name: Name of the provisioning service. + :param provisioning_service_name: Name of the provisioning service. Required. :type provisioning_service_name: str - :param key_name: Logical key name to get key-values for. + :param key_name: Logical key name to get key-values for. Required. :type key_name: str :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRuleAccessRightsDescription, or the result of + :return: SharedAccessSignatureAuthorizationRuleAccessRightsDescription or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop( + "cls", None + ) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] - request = build_list_keys_for_key_name_request( provisioning_service_name=provisioning_service_name, key_name=key_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -914,54 +1355,67 @@ async def list_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleAccessRightsDescription', pipeline_response) + deserialized = self._deserialize( + "SharedAccessSignatureAuthorizationRuleAccessRightsDescription", pipeline_response + ) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys'} # type: ignore - + list_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys"} # type: ignore @distributed_trace_async async def list_private_link_resources( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given provisioning service. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_private_link_resources.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -969,58 +1423,68 @@ async def list_private_link_resources( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources'} # type: ignore - + list_private_link_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace_async async def get_private_link_resources( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given provisioning service. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get_private_link_resources.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1028,54 +1492,65 @@ async def get_private_link_resources( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get_private_link_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}"} # type: ignore @distributed_trace_async async def list_private_endpoint_connections( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_private_endpoint_connections_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_private_endpoint_connections.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_endpoint_connections.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1083,58 +1558,68 @@ async def list_private_endpoint_connections( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_private_endpoint_connections.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections'} # type: ignore - + list_private_endpoint_connections.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get_private_endpoint_connection( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_private_endpoint_connection_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get_private_endpoint_connection.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_endpoint_connection.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1142,90 +1627,117 @@ async def get_private_endpoint_connection( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _create_or_update_private_endpoint_connection_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_create_or_update_private_endpoint_connection_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_private_endpoint_connection_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_private_endpoint_connection_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_private_endpoint_connection_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_private_endpoint_connection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _create_or_update_private_endpoint_connection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create_or_update_private_endpoint_connection( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Create or update private endpoint connection. Create or update the status of a private endpoint connection with the specified name. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection + :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 @@ -1238,115 +1750,220 @@ async def begin_create_or_update_private_endpoint_connection( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + async def begin_create_or_update_private_endpoint_connection( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Create or update private endpoint connection. + + Create or update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the provisioning + service. Required. + :type resource_group_name: str + :param resource_name: The name of the provisioning service. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :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.iothubprovisioningservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_or_update_private_endpoint_connection( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: + """Create or update private endpoint connection. + + Create or update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the provisioning + service. Required. + :type resource_group_name: str + :param resource_name: The name of the provisioning service. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection 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. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_private_endpoint_connection_initial( + raw_result = await self._create_or_update_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_create_or_update_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore async def _delete_private_endpoint_connection_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_private_endpoint_connection_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_private_endpoint_connection_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_private_endpoint_connection_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_private_endpoint_connection_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) return deserialized - _delete_private_endpoint_connection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_private_endpoint_connection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def begin_delete_private_endpoint_connection( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> AsyncLROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> AsyncLROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. 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. @@ -1360,44 +1977,50 @@ async def begin_delete_private_endpoint_connection( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_private_endpoint_connection_initial( + raw_result = await self._delete_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_operations.py index fab2c7bf0e5f..208172cd03cb 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,81 +6,110 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothubprovisioningservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothubprovisioningservices.aio.IotDpsClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Microsoft.Devices REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -93,7 +123,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -103,8 +135,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_patch.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/__init__.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/__init__.py index 936fe672799d..f1780f99dd92 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/__init__.py @@ -12,7 +12,7 @@ from ._models_py3 import CertificateProperties from ._models_py3 import CertificateResponse from ._models_py3 import ErrorDetails -from ._models_py3 import ErrorMesssage +from ._models_py3 import ErrorMessage from ._models_py3 import GroupIdInformation from ._models_py3 import GroupIdInformationProperties from ._models_py3 import IotDpsPropertiesDescription @@ -42,66 +42,68 @@ from ._models_py3 import VerificationCodeResponse from ._models_py3 import VerificationCodeResponseProperties - -from ._iot_dps_client_enums import ( - AccessRightsDescription, - AllocationPolicy, - CertificatePurpose, - CreatedByType, - IotDpsSku, - IpFilterActionType, - IpFilterTargetType, - NameUnavailabilityReason, - PrivateLinkServiceConnectionStatus, - PublicNetworkAccess, - State, -) +from ._iot_dps_client_enums import AccessRightsDescription +from ._iot_dps_client_enums import AllocationPolicy +from ._iot_dps_client_enums import CertificatePurpose +from ._iot_dps_client_enums import CreatedByType +from ._iot_dps_client_enums import IotDpsSku +from ._iot_dps_client_enums import IpFilterActionType +from ._iot_dps_client_enums import IpFilterTargetType +from ._iot_dps_client_enums import NameUnavailabilityReason +from ._iot_dps_client_enums import PrivateLinkServiceConnectionStatus +from ._iot_dps_client_enums import PublicNetworkAccess +from ._iot_dps_client_enums import State +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'AsyncOperationResult', - 'CertificateBodyDescription', - 'CertificateListDescription', - 'CertificateProperties', - 'CertificateResponse', - 'ErrorDetails', - 'ErrorMesssage', - 'GroupIdInformation', - 'GroupIdInformationProperties', - 'IotDpsPropertiesDescription', - 'IotDpsSkuDefinition', - 'IotDpsSkuDefinitionListResult', - 'IotDpsSkuInfo', - 'IotHubDefinitionDescription', - 'IpFilterRule', - 'NameAvailabilityInfo', - 'Operation', - 'OperationDisplay', - 'OperationInputs', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionProperties', - 'PrivateLinkResources', - 'PrivateLinkServiceConnectionState', - 'ProvisioningServiceDescription', - 'ProvisioningServiceDescriptionListResult', - 'Resource', - 'SharedAccessSignatureAuthorizationRuleAccessRightsDescription', - 'SharedAccessSignatureAuthorizationRuleListResult', - 'SystemData', - 'TagsResource', - 'VerificationCodeRequest', - 'VerificationCodeResponse', - 'VerificationCodeResponseProperties', - 'AccessRightsDescription', - 'AllocationPolicy', - 'CertificatePurpose', - 'CreatedByType', - 'IotDpsSku', - 'IpFilterActionType', - 'IpFilterTargetType', - 'NameUnavailabilityReason', - 'PrivateLinkServiceConnectionStatus', - 'PublicNetworkAccess', - 'State', + "AsyncOperationResult", + "CertificateBodyDescription", + "CertificateListDescription", + "CertificateProperties", + "CertificateResponse", + "ErrorDetails", + "ErrorMessage", + "GroupIdInformation", + "GroupIdInformationProperties", + "IotDpsPropertiesDescription", + "IotDpsSkuDefinition", + "IotDpsSkuDefinitionListResult", + "IotDpsSkuInfo", + "IotHubDefinitionDescription", + "IpFilterRule", + "NameAvailabilityInfo", + "Operation", + "OperationDisplay", + "OperationInputs", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionProperties", + "PrivateLinkResources", + "PrivateLinkServiceConnectionState", + "ProvisioningServiceDescription", + "ProvisioningServiceDescriptionListResult", + "Resource", + "SharedAccessSignatureAuthorizationRuleAccessRightsDescription", + "SharedAccessSignatureAuthorizationRuleListResult", + "SystemData", + "TagsResource", + "VerificationCodeRequest", + "VerificationCodeResponse", + "VerificationCodeResponseProperties", + "AccessRightsDescription", + "AllocationPolicy", + "CertificatePurpose", + "CreatedByType", + "IotDpsSku", + "IpFilterActionType", + "IpFilterTargetType", + "NameUnavailabilityReason", + "PrivateLinkServiceConnectionStatus", + "PublicNetworkAccess", + "State", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_iot_dps_client_enums.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_iot_dps_client_enums.py index e7c33853f1ea..cd26aec8c3b5 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_iot_dps_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_iot_dps_client_enums.py @@ -7,13 +7,11 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class AccessRightsDescription(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Rights that this key has. - """ +class AccessRightsDescription(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Rights that this key has.""" SERVICE_CONFIG = "ServiceConfig" ENROLLMENT_READ = "EnrollmentRead" @@ -22,75 +20,77 @@ class AccessRightsDescription(with_metaclass(CaseInsensitiveEnumMeta, str, Enum) REGISTRATION_STATUS_READ = "RegistrationStatusRead" REGISTRATION_STATUS_WRITE = "RegistrationStatusWrite" -class AllocationPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Allocation policy to be used by this provisioning service. - """ + +class AllocationPolicy(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allocation policy to be used by this provisioning service.""" HASHED = "Hashed" GEO_LATENCY = "GeoLatency" STATIC = "Static" -class CertificatePurpose(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class CertificatePurpose(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CertificatePurpose.""" CLIENT_AUTHENTICATION = "clientAuthentication" SERVER_AUTHENTICATION = "serverAuthentication" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class IotDpsSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Sku name. - """ + +class IotDpsSku(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Sku name.""" S1 = "S1" -class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The desired action for requests captured by this rule. - """ + +class IpFilterActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The desired action for requests captured by this rule.""" ACCEPT = "Accept" REJECT = "Reject" -class IpFilterTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Target for requests captured by this rule. - """ + +class IpFilterTargetType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Target for requests captured by this rule.""" ALL = "all" SERVICE_API = "serviceApi" DEVICE_API = "deviceApi" -class NameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """specifies the reason a name is unavailable - """ + +class NameUnavailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """specifies the reason a name is unavailable.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The status of a private endpoint connection - """ + +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of a private endpoint connection.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Whether requests from Public Network are allowed - """ + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Whether requests from Public Network are allowed.""" ENABLED = "Enabled" DISABLED = "Disabled" -class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Current state of the provisioning service. - """ + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Current state of the provisioning service.""" ACTIVATING = "Activating" ACTIVE = "Active" diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_models_py3.py index 22b9183ec996..fed2185fd916 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,47 +8,42 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization -from ._iot_dps_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class AsyncOperationResult(msrest.serialization.Model): +class AsyncOperationResult(_serialization.Model): """Result of a long running operation. :ivar status: current status of a long running operation. :vartype status: str :ivar error: Error message containing code, description and details. - :vartype error: ~azure.mgmt.iothubprovisioningservices.models.ErrorMesssage + :vartype error: ~azure.mgmt.iothubprovisioningservices.models.ErrorMessage """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorMesssage'}, + "status": {"key": "status", "type": "str"}, + "error": {"key": "error", "type": "ErrorMessage"}, } - def __init__( - self, - *, - status: Optional[str] = None, - error: Optional["ErrorMesssage"] = None, - **kwargs - ): + def __init__(self, *, status: Optional[str] = None, error: Optional["_models.ErrorMessage"] = None, **kwargs): """ :keyword status: current status of a long running operation. :paramtype status: str :keyword error: Error message containing code, description and details. - :paramtype error: ~azure.mgmt.iothubprovisioningservices.models.ErrorMesssage + :paramtype error: ~azure.mgmt.iothubprovisioningservices.models.ErrorMessage """ - super(AsyncOperationResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.error = error -class CertificateBodyDescription(msrest.serialization.Model): +class CertificateBodyDescription(_serialization.Model): """The JSON-serialized X509 Certificate. :ivar certificate: Base-64 representation of the X509 leaf certificate .cer file or just .pem @@ -59,17 +55,11 @@ class CertificateBodyDescription(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, + "certificate": {"key": "certificate", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - is_verified: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, is_verified: Optional[bool] = None, **kwargs): """ :keyword certificate: Base-64 representation of the X509 leaf certificate .cer file or just .pem file content. @@ -78,12 +68,12 @@ def __init__( proof of possession will not be required. :paramtype is_verified: bool """ - super(CertificateBodyDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate self.is_verified = is_verified -class CertificateListDescription(msrest.serialization.Model): +class CertificateListDescription(_serialization.Model): """The JSON-serialized array of Certificate objects. :ivar value: The array of Certificate objects. @@ -91,24 +81,19 @@ class CertificateListDescription(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateResponse]'}, + "value": {"key": "value", "type": "[CertificateResponse]"}, } - def __init__( - self, - *, - value: Optional[List["CertificateResponse"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.CertificateResponse"]] = None, **kwargs): """ :keyword value: The array of Certificate objects. :paramtype value: list[~azure.mgmt.iothubprovisioningservices.models.CertificateResponse] """ - super(CertificateListDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class CertificateProperties(msrest.serialization.Model): +class CertificateProperties(_serialization.Model): """The description of an X509 CA Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -123,7 +108,7 @@ class CertificateProperties(msrest.serialization.Model): :vartype is_verified: bool :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :vartype certificate: bytearray + :vartype certificate: bytes :ivar created: The certificate's creation date and time. :vartype created: ~datetime.datetime :ivar updated: The certificate's last update date and time. @@ -131,42 +116,42 @@ class CertificateProperties(msrest.serialization.Model): """ _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'certificate': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, + "subject": {"readonly": True}, + "expiry": {"readonly": True}, + "thumbprint": {"readonly": True}, + "created": {"readonly": True}, + "updated": {"readonly": True}, } _attribute_map = { - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'rfc-1123'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'certificate': {'key': 'certificate', 'type': 'bytearray'}, - 'created': {'key': 'created', 'type': 'rfc-1123'}, - 'updated': {'key': 'updated', 'type': 'rfc-1123'}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "rfc-1123"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "certificate": {"key": "certificate", "type": "bytearray"}, + "created": {"key": "created", "type": "rfc-1123"}, + "updated": {"key": "updated", "type": "rfc-1123"}, } - def __init__( - self, - **kwargs - ): + def __init__(self, *, is_verified: Optional[bool] = None, certificate: Optional[bytes] = None, **kwargs): """ + :keyword is_verified: Determines whether certificate has been verified. + :paramtype is_verified: bool + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: bytes """ - super(CertificateProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.subject = None self.expiry = None self.thumbprint = None - self.is_verified = None - self.certificate = None + self.is_verified = is_verified + self.certificate = certificate self.created = None self.updated = None -class CertificateResponse(msrest.serialization.Model): +class CertificateResponse(_serialization.Model): """The X509 Certificate. Variables are only populated by the server, and will be ignored when sending a request. @@ -186,33 +171,28 @@ class CertificateResponse(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'properties': {'key': 'properties', 'type': 'CertificateProperties'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "properties": {"key": "properties", "type": "CertificateProperties"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - *, - properties: Optional["CertificateProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.CertificateProperties"] = None, **kwargs): """ :keyword properties: properties of a certificate. :paramtype properties: ~azure.mgmt.iothubprovisioningservices.models.CertificateProperties """ - super(CertificateResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.id = None self.name = None @@ -221,7 +201,7 @@ def __init__( self.system_data = None -class ErrorDetails(msrest.serialization.Model): +class ErrorDetails(_serialization.Model): """Error details. Variables are only populated by the server, and will be ignored when sending a request. @@ -237,33 +217,29 @@ class ErrorDetails(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'http_status_code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, + "code": {"readonly": True}, + "http_status_code": {"readonly": True}, + "message": {"readonly": True}, + "details": {"readonly": True}, } _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'http_status_code': {'key': 'httpStatusCode', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "http_status_code": {"key": "httpStatusCode", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorDetails, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.http_status_code = None self.message = None self.details = None -class ErrorMesssage(msrest.serialization.Model): +class ErrorMessage(_serialization.Model): """Error response containing message and code. :ivar code: standard error code. @@ -275,18 +251,13 @@ class ErrorMesssage(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "details": {"key": "details", "type": "str"}, } def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - details: Optional[str] = None, - **kwargs + self, *, code: Optional[str] = None, message: Optional[str] = None, details: Optional[str] = None, **kwargs ): """ :keyword code: standard error code. @@ -296,13 +267,13 @@ def __init__( :keyword details: detailed summary of error. :paramtype details: str """ - super(ErrorMesssage, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.details = details -class GroupIdInformation(msrest.serialization.Model): +class GroupIdInformation(_serialization.Model): """The group information for creating a private endpoint on a provisioning service. Variables are only populated by the server, and will be ignored when sending a request. @@ -315,43 +286,38 @@ class GroupIdInformation(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties for a group information object. + :ivar properties: The properties for a group information object. Required. :vartype properties: ~azure.mgmt.iothubprovisioningservices.models.GroupIdInformationProperties """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'properties': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "properties": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'GroupIdInformationProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "GroupIdInformationProperties"}, } - def __init__( - self, - *, - properties: "GroupIdInformationProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.GroupIdInformationProperties", **kwargs): """ - :keyword properties: Required. The properties for a group information object. + :keyword properties: The properties for a group information object. Required. :paramtype properties: ~azure.mgmt.iothubprovisioningservices.models.GroupIdInformationProperties """ - super(GroupIdInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties -class GroupIdInformationProperties(msrest.serialization.Model): +class GroupIdInformationProperties(_serialization.Model): """The properties for a group information object. :ivar group_id: The group id. @@ -363,9 +329,9 @@ class GroupIdInformationProperties(msrest.serialization.Model): """ _attribute_map = { - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'requiredZoneNames', 'type': '[str]'}, + "group_id": {"key": "groupId", "type": "str"}, + "required_members": {"key": "requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "requiredZoneNames", "type": "[str]"}, } def __init__( @@ -384,23 +350,23 @@ def __init__( :keyword required_zone_names: The required DNS zones for a specific group id. :paramtype required_zone_names: list[str] """ - super(GroupIdInformationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = group_id self.required_members = required_members self.required_zone_names = required_zone_names -class IotDpsPropertiesDescription(msrest.serialization.Model): +class IotDpsPropertiesDescription(_serialization.Model): # pylint: disable=too-many-instance-attributes """the service specific properties of a provisioning service, including keys, linked iot hubs, current state, and system generated properties such as hostname and idScope. Variables are only populated by the server, and will be ignored when sending a request. - :ivar state: Current state of the provisioning service. Possible values include: "Activating", + :ivar state: Current state of the provisioning service. Known values are: "Activating", "Active", "Deleting", "Deleted", "ActivationFailed", "DeletionFailed", "Transitioning", - "Suspending", "Suspended", "Resuming", "FailingOver", "FailoverFailed". + "Suspending", "Suspended", "Resuming", "FailingOver", and "FailoverFailed". :vartype state: str or ~azure.mgmt.iothubprovisioningservices.models.State - :ivar public_network_access: Whether requests from Public Network are allowed. Possible values - include: "Enabled", "Disabled". + :ivar public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.iothubprovisioningservices.models.PublicNetworkAccess :ivar ip_filter_rules: The IP filter rules. @@ -413,8 +379,8 @@ class IotDpsPropertiesDescription(msrest.serialization.Model): :ivar iot_hubs: List of IoT hubs associated with this provisioning service. :vartype iot_hubs: list[~azure.mgmt.iothubprovisioningservices.models.IotHubDefinitionDescription] - :ivar allocation_policy: Allocation policy to be used by this provisioning service. Possible - values include: "Hashed", "GeoLatency", "Static". + :ivar allocation_policy: Allocation policy to be used by this provisioning service. Known + values are: "Hashed", "GeoLatency", and "Static". :vartype allocation_policy: str or ~azure.mgmt.iothubprovisioningservices.models.AllocationPolicy :ivar service_operations_host_name: Service endpoint for provisioning service. @@ -433,47 +399,52 @@ class IotDpsPropertiesDescription(msrest.serialization.Model): """ _validation = { - 'service_operations_host_name': {'readonly': True}, - 'device_provisioning_host_name': {'readonly': True}, - 'id_scope': {'readonly': True}, + "service_operations_host_name": {"readonly": True}, + "device_provisioning_host_name": {"readonly": True}, + "id_scope": {"readonly": True}, } _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'iot_hubs': {'key': 'iotHubs', 'type': '[IotHubDefinitionDescription]'}, - 'allocation_policy': {'key': 'allocationPolicy', 'type': 'str'}, - 'service_operations_host_name': {'key': 'serviceOperationsHostName', 'type': 'str'}, - 'device_provisioning_host_name': {'key': 'deviceProvisioningHostName', 'type': 'str'}, - 'id_scope': {'key': 'idScope', 'type': 'str'}, - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRuleAccessRightsDescription]'}, - 'enable_data_residency': {'key': 'enableDataResidency', 'type': 'bool'}, + "state": {"key": "state", "type": "str"}, + "public_network_access": {"key": "publicNetworkAccess", "type": "str"}, + "ip_filter_rules": {"key": "ipFilterRules", "type": "[IpFilterRule]"}, + "private_endpoint_connections": {"key": "privateEndpointConnections", "type": "[PrivateEndpointConnection]"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "iot_hubs": {"key": "iotHubs", "type": "[IotHubDefinitionDescription]"}, + "allocation_policy": {"key": "allocationPolicy", "type": "str"}, + "service_operations_host_name": {"key": "serviceOperationsHostName", "type": "str"}, + "device_provisioning_host_name": {"key": "deviceProvisioningHostName", "type": "str"}, + "id_scope": {"key": "idScope", "type": "str"}, + "authorization_policies": { + "key": "authorizationPolicies", + "type": "[SharedAccessSignatureAuthorizationRuleAccessRightsDescription]", + }, + "enable_data_residency": {"key": "enableDataResidency", "type": "bool"}, } def __init__( self, *, - state: Optional[Union[str, "State"]] = None, - public_network_access: Optional[Union[str, "PublicNetworkAccess"]] = None, - ip_filter_rules: Optional[List["IpFilterRule"]] = None, - private_endpoint_connections: Optional[List["PrivateEndpointConnection"]] = None, + state: Optional[Union[str, "_models.State"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + ip_filter_rules: Optional[List["_models.IpFilterRule"]] = None, + private_endpoint_connections: Optional[List["_models.PrivateEndpointConnection"]] = None, provisioning_state: Optional[str] = None, - iot_hubs: Optional[List["IotHubDefinitionDescription"]] = None, - allocation_policy: Optional[Union[str, "AllocationPolicy"]] = None, - authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRuleAccessRightsDescription"]] = None, + iot_hubs: Optional[List["_models.IotHubDefinitionDescription"]] = None, + allocation_policy: Optional[Union[str, "_models.AllocationPolicy"]] = None, + authorization_policies: Optional[ + List["_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription"] + ] = None, enable_data_residency: Optional[bool] = None, **kwargs ): """ - :keyword state: Current state of the provisioning service. Possible values include: - "Activating", "Active", "Deleting", "Deleted", "ActivationFailed", "DeletionFailed", - "Transitioning", "Suspending", "Suspended", "Resuming", "FailingOver", "FailoverFailed". + :keyword state: Current state of the provisioning service. Known values are: "Activating", + "Active", "Deleting", "Deleted", "ActivationFailed", "DeletionFailed", "Transitioning", + "Suspending", "Suspended", "Resuming", "FailingOver", and "FailoverFailed". :paramtype state: str or ~azure.mgmt.iothubprovisioningservices.models.State - :keyword public_network_access: Whether requests from Public Network are allowed. Possible - values include: "Enabled", "Disabled". + :keyword public_network_access: Whether requests from Public Network are allowed. Known values + are: "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.iothubprovisioningservices.models.PublicNetworkAccess :keyword ip_filter_rules: The IP filter rules. @@ -486,8 +457,8 @@ def __init__( :keyword iot_hubs: List of IoT hubs associated with this provisioning service. :paramtype iot_hubs: list[~azure.mgmt.iothubprovisioningservices.models.IotHubDefinitionDescription] - :keyword allocation_policy: Allocation policy to be used by this provisioning service. Possible - values include: "Hashed", "GeoLatency", "Static". + :keyword allocation_policy: Allocation policy to be used by this provisioning service. Known + values are: "Hashed", "GeoLatency", and "Static". :paramtype allocation_policy: str or ~azure.mgmt.iothubprovisioningservices.models.AllocationPolicy :keyword authorization_policies: List of authorization keys for a provisioning service. @@ -498,7 +469,7 @@ def __init__( recovery. :paramtype enable_data_residency: bool """ - super(IotDpsPropertiesDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.state = state self.public_network_access = public_network_access self.ip_filter_rules = ip_filter_rules @@ -513,32 +484,27 @@ def __init__( self.enable_data_residency = enable_data_residency -class IotDpsSkuDefinition(msrest.serialization.Model): +class IotDpsSkuDefinition(_serialization.Model): """Available SKUs of tier and units. - :ivar name: Sku name. Possible values include: "S1". + :ivar name: Sku name. "S1" :vartype name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[Union[str, "IotDpsSku"]] = None, - **kwargs - ): + def __init__(self, *, name: Optional[Union[str, "_models.IotDpsSku"]] = None, **kwargs): """ - :keyword name: Sku name. Possible values include: "S1". + :keyword name: Sku name. "S1" :paramtype name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku """ - super(IotDpsSkuDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class IotDpsSkuDefinitionListResult(msrest.serialization.Model): +class IotDpsSkuDefinitionListResult(_serialization.Model): """List of available SKUs. Variables are only populated by the server, and will be ignored when sending a request. @@ -550,72 +516,63 @@ class IotDpsSkuDefinitionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[IotDpsSkuDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[IotDpsSkuDefinition]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["IotDpsSkuDefinition"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.IotDpsSkuDefinition"]] = None, **kwargs): """ :keyword value: The list of SKUs. :paramtype value: list[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinition] """ - super(IotDpsSkuDefinitionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class IotDpsSkuInfo(msrest.serialization.Model): +class IotDpsSkuInfo(_serialization.Model): """List of possible provisioning service SKUs. Variables are only populated by the server, and will be ignored when sending a request. - :ivar name: Sku name. Possible values include: "S1". + :ivar name: Sku name. "S1" :vartype name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku :ivar tier: Pricing tier name of the provisioning service. :vartype tier: str :ivar capacity: The number of units to provision. - :vartype capacity: long + :vartype capacity: int """ _validation = { - 'tier': {'readonly': True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( - self, - *, - name: Optional[Union[str, "IotDpsSku"]] = None, - capacity: Optional[int] = None, - **kwargs + self, *, name: Optional[Union[str, "_models.IotDpsSku"]] = None, capacity: Optional[int] = None, **kwargs ): """ - :keyword name: Sku name. Possible values include: "S1". + :keyword name: Sku name. "S1" :paramtype name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku :keyword capacity: The number of units to provision. - :paramtype capacity: long + :paramtype capacity: int """ - super(IotDpsSkuInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.capacity = capacity -class IotHubDefinitionDescription(msrest.serialization.Model): +class IotHubDefinitionDescription(_serialization.Model): """Description of the IoT hub. Variables are only populated by the server, and will be ignored when sending a request. @@ -628,24 +585,24 @@ class IotHubDefinitionDescription(msrest.serialization.Model): :vartype allocation_weight: int :ivar name: Host name of the IoT hub. :vartype name: str - :ivar connection_string: Required. Connection string of the IoT hub. + :ivar connection_string: Connection string of the IoT hub. Required. :vartype connection_string: str - :ivar location: Required. ARM region of the IoT hub. + :ivar location: ARM region of the IoT hub. Required. :vartype location: str """ _validation = { - 'name': {'readonly': True}, - 'connection_string': {'required': True}, - 'location': {'required': True}, + "name": {"readonly": True}, + "connection_string": {"required": True}, + "location": {"required": True}, } _attribute_map = { - 'apply_allocation_policy': {'key': 'applyAllocationPolicy', 'type': 'bool'}, - 'allocation_weight': {'key': 'allocationWeight', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, + "apply_allocation_policy": {"key": "applyAllocationPolicy", "type": "bool"}, + "allocation_weight": {"key": "allocationWeight", "type": "int"}, + "name": {"key": "name", "type": "str"}, + "connection_string": {"key": "connectionString", "type": "str"}, + "location": {"key": "location", "type": "str"}, } def __init__( @@ -663,12 +620,12 @@ def __init__( :paramtype apply_allocation_policy: bool :keyword allocation_weight: weight to apply for a given iot h. :paramtype allocation_weight: int - :keyword connection_string: Required. Connection string of the IoT hub. + :keyword connection_string: Connection string of the IoT hub. Required. :paramtype connection_string: str - :keyword location: Required. ARM region of the IoT hub. + :keyword location: ARM region of the IoT hub. Required. :paramtype location: str """ - super(IotHubDefinitionDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.apply_allocation_policy = apply_allocation_policy self.allocation_weight = allocation_weight self.name = None @@ -676,72 +633,72 @@ def __init__( self.location = location -class IpFilterRule(msrest.serialization.Model): +class IpFilterRule(_serialization.Model): """The IP filter rules for a provisioning Service. All required parameters must be populated in order to send to Azure. - :ivar filter_name: Required. The name of the IP filter rule. + :ivar filter_name: The name of the IP filter rule. Required. :vartype filter_name: str - :ivar action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". + :ivar action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :vartype action: str or ~azure.mgmt.iothubprovisioningservices.models.IpFilterActionType - :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. + :ivar ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :vartype ip_mask: str - :ivar target: Target for requests captured by this rule. Possible values include: "all", - "serviceApi", "deviceApi". + :ivar target: Target for requests captured by this rule. Known values are: "all", "serviceApi", + and "deviceApi". :vartype target: str or ~azure.mgmt.iothubprovisioningservices.models.IpFilterTargetType """ _validation = { - 'filter_name': {'required': True}, - 'action': {'required': True}, - 'ip_mask': {'required': True}, + "filter_name": {"required": True}, + "action": {"required": True}, + "ip_mask": {"required": True}, } _attribute_map = { - 'filter_name': {'key': 'filterName', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'ip_mask': {'key': 'ipMask', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, + "filter_name": {"key": "filterName", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "ip_mask": {"key": "ipMask", "type": "str"}, + "target": {"key": "target", "type": "str"}, } def __init__( self, *, filter_name: str, - action: Union[str, "IpFilterActionType"], + action: Union[str, "_models.IpFilterActionType"], ip_mask: str, - target: Optional[Union[str, "IpFilterTargetType"]] = None, + target: Optional[Union[str, "_models.IpFilterTargetType"]] = None, **kwargs ): """ - :keyword filter_name: Required. The name of the IP filter rule. + :keyword filter_name: The name of the IP filter rule. Required. :paramtype filter_name: str - :keyword action: Required. The desired action for requests captured by this rule. Possible - values include: "Accept", "Reject". + :keyword action: The desired action for requests captured by this rule. Required. Known values + are: "Accept" and "Reject". :paramtype action: str or ~azure.mgmt.iothubprovisioningservices.models.IpFilterActionType - :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for - the rule. + :keyword ip_mask: A string that contains the IP address range in CIDR notation for the rule. + Required. :paramtype ip_mask: str - :keyword target: Target for requests captured by this rule. Possible values include: "all", - "serviceApi", "deviceApi". + :keyword target: Target for requests captured by this rule. Known values are: "all", + "serviceApi", and "deviceApi". :paramtype target: str or ~azure.mgmt.iothubprovisioningservices.models.IpFilterTargetType """ - super(IpFilterRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.filter_name = filter_name self.action = action self.ip_mask = ip_mask self.target = target -class NameAvailabilityInfo(msrest.serialization.Model): +class NameAvailabilityInfo(_serialization.Model): """Description of name availability. :ivar name_available: specifies if a name is available or not. :vartype name_available: bool - :ivar reason: specifies the reason a name is unavailable. Possible values include: "Invalid", + :ivar reason: specifies the reason a name is unavailable. Known values are: "Invalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothubprovisioningservices.models.NameUnavailabilityReason :ivar message: message containing a detailed reason name is unavailable. @@ -749,36 +706,36 @@ class NameAvailabilityInfo(msrest.serialization.Model): """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( self, *, name_available: Optional[bool] = None, - reason: Optional[Union[str, "NameUnavailabilityReason"]] = None, + reason: Optional[Union[str, "_models.NameUnavailabilityReason"]] = None, message: Optional[str] = None, **kwargs ): """ :keyword name_available: specifies if a name is available or not. :paramtype name_available: bool - :keyword reason: specifies the reason a name is unavailable. Possible values include: - "Invalid", "AlreadyExists". + :keyword reason: specifies the reason a name is unavailable. Known values are: "Invalid" and + "AlreadyExists". :paramtype reason: str or ~azure.mgmt.iothubprovisioningservices.models.NameUnavailabilityReason :keyword message: message containing a detailed reason name is unavailable. :paramtype message: str """ - super(NameAvailabilityInfo, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Provisioning Service REST API operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -790,30 +747,25 @@ class Operation(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, + "name": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: The object that represents the operation. :paramtype display: ~azure.mgmt.iothubprovisioningservices.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.display = display -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that represents the operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -827,61 +779,52 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None -class OperationInputs(msrest.serialization.Model): +class OperationInputs(_serialization.Model): """Input values for operation results call. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the Provisioning Service to check. + :ivar name: The name of the Provisioning Service to check. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The name of the Provisioning Service to check. + :keyword name: The name of the Provisioning Service to check. Required. :paramtype name: str """ - super(OperationInputs, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list provisioning service operations. It contains a list of operations and a URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. @@ -894,27 +837,23 @@ class OperationListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The private endpoint property of a private endpoint connection. Variables are only populated by the server, and will be ignored when sending a request. @@ -924,24 +863,20 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None -class PrivateEndpointConnection(msrest.serialization.Model): +class PrivateEndpointConnection(_serialization.Model): """The private endpoint connection of a provisioning service. Variables are only populated by the server, and will be ignored when sending a request. @@ -954,7 +889,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar properties: Required. The properties of a private endpoint connection. + :ivar properties: The properties of a private endpoint connection. Required. :vartype properties: ~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnectionProperties :ivar system_data: Metadata pertaining to creation and last modification of the resource. @@ -962,33 +897,28 @@ class PrivateEndpointConnection(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'properties': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "properties": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "PrivateEndpointConnectionProperties"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } - def __init__( - self, - *, - properties: "PrivateEndpointConnectionProperties", - **kwargs - ): + def __init__(self, *, properties: "_models.PrivateEndpointConnectionProperties", **kwargs): """ - :keyword properties: Required. The properties of a private endpoint connection. + :keyword properties: The properties of a private endpoint connection. Required. :paramtype properties: ~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnectionProperties """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -996,49 +926,52 @@ def __init__( self.system_data = None -class PrivateEndpointConnectionProperties(msrest.serialization.Model): +class PrivateEndpointConnectionProperties(_serialization.Model): """The properties of a private endpoint connection. All required parameters must be populated in order to send to Azure. :ivar private_endpoint: The private endpoint property of a private endpoint connection. :vartype private_endpoint: ~azure.mgmt.iothubprovisioningservices.models.PrivateEndpoint - :ivar private_link_service_connection_state: Required. The current state of a private endpoint - connection. + :ivar private_link_service_connection_state: The current state of a private endpoint + connection. Required. :vartype private_link_service_connection_state: ~azure.mgmt.iothubprovisioningservices.models.PrivateLinkServiceConnectionState """ _validation = { - 'private_link_service_connection_state': {'required': True}, + "private_link_service_connection_state": {"required": True}, } _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, + "private_endpoint": {"key": "privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, } def __init__( self, *, - private_link_service_connection_state: "PrivateLinkServiceConnectionState", - private_endpoint: Optional["PrivateEndpoint"] = None, + private_link_service_connection_state: "_models.PrivateLinkServiceConnectionState", + private_endpoint: Optional["_models.PrivateEndpoint"] = None, **kwargs ): """ :keyword private_endpoint: The private endpoint property of a private endpoint connection. :paramtype private_endpoint: ~azure.mgmt.iothubprovisioningservices.models.PrivateEndpoint - :keyword private_link_service_connection_state: Required. The current state of a private - endpoint connection. + :keyword private_link_service_connection_state: The current state of a private endpoint + connection. Required. :paramtype private_link_service_connection_state: ~azure.mgmt.iothubprovisioningservices.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state -class PrivateLinkResources(msrest.serialization.Model): +class PrivateLinkResources(_serialization.Model): """The available private link resources for a provisioning service. :ivar value: The list of available private link resources for a provisioning service. @@ -1046,76 +979,71 @@ class PrivateLinkResources(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[GroupIdInformation]'}, + "value": {"key": "value", "type": "[GroupIdInformation]"}, } - def __init__( - self, - *, - value: Optional[List["GroupIdInformation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.GroupIdInformation"]] = None, **kwargs): """ :keyword value: The list of available private link resources for a provisioning service. :paramtype value: list[~azure.mgmt.iothubprovisioningservices.models.GroupIdInformation] """ - super(PrivateLinkResources, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """The current state of a private endpoint connection. All required parameters must be populated in order to send to Azure. - :ivar status: Required. The status of a private endpoint connection. Possible values include: - "Pending", "Approved", "Rejected", "Disconnected". + :ivar status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.iothubprovisioningservices.models.PrivateLinkServiceConnectionStatus - :ivar description: Required. The description for the current state of a private endpoint - connection. + :ivar description: The description for the current state of a private endpoint connection. + Required. :vartype description: str :ivar actions_required: Actions required for a private endpoint connection. :vartype actions_required: str """ _validation = { - 'status': {'required': True}, - 'description': {'required': True}, + "status": {"required": True}, + "description": {"required": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } def __init__( self, *, - status: Union[str, "PrivateLinkServiceConnectionStatus"], + status: Union[str, "_models.PrivateLinkServiceConnectionStatus"], description: str, actions_required: Optional[str] = None, **kwargs ): """ - :keyword status: Required. The status of a private endpoint connection. Possible values - include: "Pending", "Approved", "Rejected", "Disconnected". + :keyword status: The status of a private endpoint connection. Required. Known values are: + "Pending", "Approved", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.iothubprovisioningservices.models.PrivateLinkServiceConnectionStatus - :keyword description: Required. The description for the current state of a private endpoint - connection. + :keyword description: The description for the current state of a private endpoint connection. + Required. :paramtype description: str :keyword actions_required: Actions required for a private endpoint connection. :paramtype actions_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The common properties of an Azure resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1128,41 +1056,35 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -1183,75 +1105,75 @@ class ProvisioningServiceDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :ivar location: Required. The resource location. + :ivar location: The resource location. Required. :vartype location: str - :ivar tags: A set of tags. The resource tags. + :ivar tags: The resource tags. :vartype tags: dict[str, str] :ivar etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :vartype etag: str - :ivar properties: Required. Service specific properties for a provisioning service. + :ivar properties: Service specific properties for a provisioning service. Required. :vartype properties: ~azure.mgmt.iothubprovisioningservices.models.IotDpsPropertiesDescription - :ivar sku: Required. Sku info for a provisioning Service. + :ivar sku: Sku info for a provisioning Service. Required. :vartype sku: ~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuInfo :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.iothubprovisioningservices.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'properties': {'required': True}, - 'sku': {'required': True}, - 'system_data': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True, "pattern": r"^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$"}, + "type": {"readonly": True}, + "location": {"required": True}, + "properties": {"required": True}, + "sku": {"required": True}, + "system_data": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotDpsPropertiesDescription'}, - 'sku': {'key': 'sku', 'type': 'IotDpsSkuInfo'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "properties": {"key": "properties", "type": "IotDpsPropertiesDescription"}, + "sku": {"key": "sku", "type": "IotDpsSkuInfo"}, + "system_data": {"key": "systemData", "type": "SystemData"}, } def __init__( self, *, location: str, - properties: "IotDpsPropertiesDescription", - sku: "IotDpsSkuInfo", + properties: "_models.IotDpsPropertiesDescription", + sku: "_models.IotDpsSkuInfo", tags: Optional[Dict[str, str]] = None, etag: Optional[str] = None, **kwargs ): """ - :keyword location: Required. The resource location. + :keyword location: The resource location. Required. :paramtype location: str - :keyword tags: A set of tags. The resource tags. + :keyword tags: The resource tags. :paramtype tags: dict[str, str] :keyword etag: The Etag field is *not* required. If it is provided in the response body, it must also be provided as a header per the normal ETag convention. :paramtype etag: str - :keyword properties: Required. Service specific properties for a provisioning service. + :keyword properties: Service specific properties for a provisioning service. Required. :paramtype properties: ~azure.mgmt.iothubprovisioningservices.models.IotDpsPropertiesDescription - :keyword sku: Required. Sku info for a provisioning Service. + :keyword sku: Sku info for a provisioning Service. Required. :paramtype sku: ~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuInfo """ - super(ProvisioningServiceDescription, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku self.system_data = None -class ProvisioningServiceDescriptionListResult(msrest.serialization.Model): +class ProvisioningServiceDescriptionListResult(_serialization.Model): """List of provisioning service descriptions. Variables are only populated by the server, and will be ignored when sending a request. @@ -1264,88 +1186,83 @@ class ProvisioningServiceDescriptionListResult(msrest.serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ProvisioningServiceDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ProvisioningServiceDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["ProvisioningServiceDescription"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ProvisioningServiceDescription"]] = None, **kwargs): """ :keyword value: List of provisioning service descriptions. :paramtype value: list[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] """ - super(ProvisioningServiceDescriptionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class SharedAccessSignatureAuthorizationRuleAccessRightsDescription(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleAccessRightsDescription(_serialization.Model): """Description of the shared access key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. Name of the key. + :ivar key_name: Name of the key. Required. :vartype key_name: str :ivar primary_key: Primary SAS key value. :vartype primary_key: str :ivar secondary_key: Secondary SAS key value. :vartype secondary_key: str - :ivar rights: Required. Rights that this key has. Possible values include: "ServiceConfig", - "EnrollmentRead", "EnrollmentWrite", "DeviceConnect", "RegistrationStatusRead", + :ivar rights: Rights that this key has. Required. Known values are: "ServiceConfig", + "EnrollmentRead", "EnrollmentWrite", "DeviceConnect", "RegistrationStatusRead", and "RegistrationStatusWrite". :vartype rights: str or ~azure.mgmt.iothubprovisioningservices.models.AccessRightsDescription """ _validation = { - 'key_name': {'required': True}, - 'rights': {'required': True}, + "key_name": {"required": True}, + "rights": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'rights': {'key': 'rights', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "rights": {"key": "rights", "type": "str"}, } def __init__( self, *, key_name: str, - rights: Union[str, "AccessRightsDescription"], + rights: Union[str, "_models.AccessRightsDescription"], primary_key: Optional[str] = None, secondary_key: Optional[str] = None, **kwargs ): """ - :keyword key_name: Required. Name of the key. + :keyword key_name: Name of the key. Required. :paramtype key_name: str :keyword primary_key: Primary SAS key value. :paramtype primary_key: str :keyword secondary_key: Secondary SAS key value. :paramtype secondary_key: str - :keyword rights: Required. Rights that this key has. Possible values include: "ServiceConfig", - "EnrollmentRead", "EnrollmentWrite", "DeviceConnect", "RegistrationStatusRead", + :keyword rights: Rights that this key has. Required. Known values are: "ServiceConfig", + "EnrollmentRead", "EnrollmentWrite", "DeviceConnect", "RegistrationStatusRead", and "RegistrationStatusWrite". :paramtype rights: str or ~azure.mgmt.iothubprovisioningservices.models.AccessRightsDescription """ - super(SharedAccessSignatureAuthorizationRuleAccessRightsDescription, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key self.secondary_key = secondary_key self.rights = rights -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): +class SharedAccessSignatureAuthorizationRuleListResult(_serialization.Model): """List of shared access keys. Variables are only populated by the server, and will be ignored when sending a request. @@ -1358,18 +1275,18 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRuleAccessRightsDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedAccessSignatureAuthorizationRuleAccessRightsDescription]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SharedAccessSignatureAuthorizationRuleAccessRightsDescription"]] = None, + value: Optional[List["_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription"]] = None, **kwargs ): """ @@ -1377,25 +1294,25 @@ def __init__( :paramtype value: list[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] """ - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = None -class SystemData(msrest.serialization.Model): +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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :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.iothubprovisioningservices.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.iothubprovisioningservices.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -1403,43 +1320,43 @@ class SystemData(msrest.serialization.Model): """ _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'}, + "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, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.iothubprovisioningservices.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.iothubprovisioningservices.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -1448,32 +1365,27 @@ def __init__( self.last_modified_at = last_modified_at -class TagsResource(msrest.serialization.Model): +class TagsResource(_serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on a Provisioning Service instance. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(TagsResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class VerificationCodeRequest(msrest.serialization.Model): +class VerificationCodeRequest(_serialization.Model): """The JSON-serialized leaf certificate. :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file @@ -1482,25 +1394,20 @@ class VerificationCodeRequest(msrest.serialization.Model): """ _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, + "certificate": {"key": "certificate", "type": "str"}, } - def __init__( - self, - *, - certificate: Optional[str] = None, - **kwargs - ): + def __init__(self, *, certificate: Optional[str] = None, **kwargs): """ :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. :paramtype certificate: str """ - super(VerificationCodeRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.certificate = certificate -class VerificationCodeResponse(msrest.serialization.Model): +class VerificationCodeResponse(_serialization.Model): """Description of the response of the verification code. Variables are only populated by the server, and will be ignored when sending a request. @@ -1519,32 +1426,27 @@ class VerificationCodeResponse(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, + "name": {"readonly": True}, + "etag": {"readonly": True}, + "id": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'VerificationCodeResponseProperties'}, + "name": {"key": "name", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "properties": {"key": "properties", "type": "VerificationCodeResponseProperties"}, } - def __init__( - self, - *, - properties: Optional["VerificationCodeResponseProperties"] = None, - **kwargs - ): + def __init__(self, *, properties: Optional["_models.VerificationCodeResponseProperties"] = None, **kwargs): """ :keyword properties: :paramtype properties: ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeResponseProperties """ - super(VerificationCodeResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.etag = None self.id = None @@ -1552,7 +1454,7 @@ def __init__( self.properties = properties -class VerificationCodeResponseProperties(msrest.serialization.Model): +class VerificationCodeResponseProperties(_serialization.Model): """VerificationCodeResponseProperties. :ivar verification_code: Verification code. @@ -1567,7 +1469,7 @@ class VerificationCodeResponseProperties(msrest.serialization.Model): :vartype is_verified: bool :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :vartype certificate: bytearray + :vartype certificate: bytes :ivar created: Certificate created time. :vartype created: str :ivar updated: Certificate updated time. @@ -1575,14 +1477,14 @@ class VerificationCodeResponseProperties(msrest.serialization.Model): """ _attribute_map = { - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'certificate': {'key': 'certificate', 'type': 'bytearray'}, - 'created': {'key': 'created', 'type': 'str'}, - 'updated': {'key': 'updated', 'type': 'str'}, + "verification_code": {"key": "verificationCode", "type": "str"}, + "subject": {"key": "subject", "type": "str"}, + "expiry": {"key": "expiry", "type": "str"}, + "thumbprint": {"key": "thumbprint", "type": "str"}, + "is_verified": {"key": "isVerified", "type": "bool"}, + "certificate": {"key": "certificate", "type": "bytearray"}, + "created": {"key": "created", "type": "str"}, + "updated": {"key": "updated", "type": "str"}, } def __init__( @@ -1593,7 +1495,7 @@ def __init__( expiry: Optional[str] = None, thumbprint: Optional[str] = None, is_verified: Optional[bool] = None, - certificate: Optional[bytearray] = None, + certificate: Optional[bytes] = None, created: Optional[str] = None, updated: Optional[str] = None, **kwargs @@ -1611,13 +1513,13 @@ def __init__( :paramtype is_verified: bool :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :paramtype certificate: bytearray + :paramtype certificate: bytes :keyword created: Certificate created time. :paramtype created: str :keyword updated: Certificate updated time. :paramtype updated: str """ - super(VerificationCodeResponseProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.verification_code = verification_code self.subject = subject self.expiry = expiry diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_patch.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/__init__.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/__init__.py index 6d426f86fd28..2e94c2e6fa16 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/__init__.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/__init__.py @@ -10,8 +10,14 @@ from ._dps_certificate_operations import DpsCertificateOperations from ._iot_dps_resource_operations import IotDpsResourceOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'DpsCertificateOperations', - 'IotDpsResourceOperations', + "Operations", + "DpsCertificateOperations", + "IotDpsResourceOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_dps_certificate_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_dps_certificate_operations.py index 46ef3da4a6d6..d14b76bdd4a1 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_dps_certificate_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_dps_certificate_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -6,372 +7,381 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( certificate_name: str, - subscription_id: str, resource_group_name: str, provisioning_service_name: str, + subscription_id: str, *, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - subscription_id: str, resource_group_name: str, provisioning_service_name: str, certificate_name: str, + subscription_id: str, *, - json: JSONType = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-10-15" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", + ) # 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'), - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', max_length=256, min_length=0), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str", max_length=256), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if if_match is not None: - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, resource_group_name: str, provisioning_service_name: str, certificate_name: str, + subscription_id: str, *, if_match: str, certificate_name1: Optional[str] = None, - certificate_raw_bytes: Optional[bytearray] = None, + certificate_raw_bytes: Optional[bytes] = None, certificate_is_verified: Optional[bool] = None, - certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, certificate_created: Optional[datetime.datetime] = None, certificate_last_updated: Optional[datetime.datetime] = None, certificate_has_private_key: Optional[bool] = None, certificate_nonce: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}", + ) # 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'), - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if certificate_name1 is not None: - query_parameters['certificate.name'] = _SERIALIZER.query("certificate_name1", certificate_name1, 'str') + _params["certificate.name"] = _SERIALIZER.query("certificate_name1", certificate_name1, "str") if certificate_raw_bytes is not None: - query_parameters['certificate.rawBytes'] = _SERIALIZER.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') + _params["certificate.rawBytes"] = _SERIALIZER.query("certificate_raw_bytes", certificate_raw_bytes, "bytearray") if certificate_is_verified is not None: - query_parameters['certificate.isVerified'] = _SERIALIZER.query("certificate_is_verified", certificate_is_verified, 'bool') + _params["certificate.isVerified"] = _SERIALIZER.query( + "certificate_is_verified", certificate_is_verified, "bool" + ) if certificate_purpose is not None: - query_parameters['certificate.purpose'] = _SERIALIZER.query("certificate_purpose", certificate_purpose, 'str') + _params["certificate.purpose"] = _SERIALIZER.query("certificate_purpose", certificate_purpose, "str") if certificate_created is not None: - query_parameters['certificate.created'] = _SERIALIZER.query("certificate_created", certificate_created, 'iso-8601') + _params["certificate.created"] = _SERIALIZER.query("certificate_created", certificate_created, "iso-8601") if certificate_last_updated is not None: - query_parameters['certificate.lastUpdated'] = _SERIALIZER.query("certificate_last_updated", certificate_last_updated, 'iso-8601') + _params["certificate.lastUpdated"] = _SERIALIZER.query( + "certificate_last_updated", certificate_last_updated, "iso-8601" + ) if certificate_has_private_key is not None: - query_parameters['certificate.hasPrivateKey'] = _SERIALIZER.query("certificate_has_private_key", certificate_has_private_key, 'bool') + _params["certificate.hasPrivateKey"] = _SERIALIZER.query( + "certificate_has_private_key", certificate_has_private_key, "bool" + ) if certificate_nonce is not None: - query_parameters['certificate.nonce'] = _SERIALIZER.query("certificate_nonce", certificate_nonce, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["certificate.nonce"] = _SERIALIZER.query("certificate_nonce", certificate_nonce, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( - subscription_id: str, - resource_group_name: str, - provisioning_service_name: str, - **kwargs: Any + resource_group_name: str, provisioning_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates", + ) # 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'), - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_generate_verification_code_request( certificate_name: str, - subscription_id: str, resource_group_name: str, provisioning_service_name: str, + subscription_id: str, *, if_match: str, certificate_name1: Optional[str] = None, - certificate_raw_bytes: Optional[bytearray] = None, + certificate_raw_bytes: Optional[bytes] = None, certificate_is_verified: Optional[bool] = None, - certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, certificate_created: Optional[datetime.datetime] = None, certificate_last_updated: Optional[datetime.datetime] = None, certificate_has_private_key: Optional[bool] = None, certificate_nonce: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode", + ) # pylint: disable=line-too-long path_format_arguments = { - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if certificate_name1 is not None: - query_parameters['certificate.name'] = _SERIALIZER.query("certificate_name1", certificate_name1, 'str') + _params["certificate.name"] = _SERIALIZER.query("certificate_name1", certificate_name1, "str") if certificate_raw_bytes is not None: - query_parameters['certificate.rawBytes'] = _SERIALIZER.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') + _params["certificate.rawBytes"] = _SERIALIZER.query("certificate_raw_bytes", certificate_raw_bytes, "bytearray") if certificate_is_verified is not None: - query_parameters['certificate.isVerified'] = _SERIALIZER.query("certificate_is_verified", certificate_is_verified, 'bool') + _params["certificate.isVerified"] = _SERIALIZER.query( + "certificate_is_verified", certificate_is_verified, "bool" + ) if certificate_purpose is not None: - query_parameters['certificate.purpose'] = _SERIALIZER.query("certificate_purpose", certificate_purpose, 'str') + _params["certificate.purpose"] = _SERIALIZER.query("certificate_purpose", certificate_purpose, "str") if certificate_created is not None: - query_parameters['certificate.created'] = _SERIALIZER.query("certificate_created", certificate_created, 'iso-8601') + _params["certificate.created"] = _SERIALIZER.query("certificate_created", certificate_created, "iso-8601") if certificate_last_updated is not None: - query_parameters['certificate.lastUpdated'] = _SERIALIZER.query("certificate_last_updated", certificate_last_updated, 'iso-8601') + _params["certificate.lastUpdated"] = _SERIALIZER.query( + "certificate_last_updated", certificate_last_updated, "iso-8601" + ) if certificate_has_private_key is not None: - query_parameters['certificate.hasPrivateKey'] = _SERIALIZER.query("certificate_has_private_key", certificate_has_private_key, 'bool') + _params["certificate.hasPrivateKey"] = _SERIALIZER.query( + "certificate_has_private_key", certificate_has_private_key, "bool" + ) if certificate_nonce is not None: - query_parameters['certificate.nonce'] = _SERIALIZER.query("certificate_nonce", certificate_nonce, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["certificate.nonce"] = _SERIALIZER.query("certificate_nonce", certificate_nonce, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_verify_certificate_request( certificate_name: str, - subscription_id: str, resource_group_name: str, provisioning_service_name: str, + subscription_id: str, *, if_match: str, - json: JSONType = None, - content: Any = None, certificate_name1: Optional[str] = None, - certificate_raw_bytes: Optional[bytearray] = None, + certificate_raw_bytes: Optional[bytes] = None, certificate_is_verified: Optional[bool] = None, - certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, certificate_created: Optional[datetime.datetime] = None, certificate_last_updated: Optional[datetime.datetime] = None, certificate_has_private_key: Optional[bool] = None, certificate_nonce: Optional[str] = None, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-10-15" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify", + ) # pylint: disable=line-too-long path_format_arguments = { - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] if certificate_name1 is not None: - query_parameters['certificate.name'] = _SERIALIZER.query("certificate_name1", certificate_name1, 'str') + _params["certificate.name"] = _SERIALIZER.query("certificate_name1", certificate_name1, "str") if certificate_raw_bytes is not None: - query_parameters['certificate.rawBytes'] = _SERIALIZER.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') + _params["certificate.rawBytes"] = _SERIALIZER.query("certificate_raw_bytes", certificate_raw_bytes, "bytearray") if certificate_is_verified is not None: - query_parameters['certificate.isVerified'] = _SERIALIZER.query("certificate_is_verified", certificate_is_verified, 'bool') + _params["certificate.isVerified"] = _SERIALIZER.query( + "certificate_is_verified", certificate_is_verified, "bool" + ) if certificate_purpose is not None: - query_parameters['certificate.purpose'] = _SERIALIZER.query("certificate_purpose", certificate_purpose, 'str') + _params["certificate.purpose"] = _SERIALIZER.query("certificate_purpose", certificate_purpose, "str") if certificate_created is not None: - query_parameters['certificate.created'] = _SERIALIZER.query("certificate_created", certificate_created, 'iso-8601') + _params["certificate.created"] = _SERIALIZER.query("certificate_created", certificate_created, "iso-8601") if certificate_last_updated is not None: - query_parameters['certificate.lastUpdated'] = _SERIALIZER.query("certificate_last_updated", certificate_last_updated, 'iso-8601') + _params["certificate.lastUpdated"] = _SERIALIZER.query( + "certificate_last_updated", certificate_last_updated, "iso-8601" + ) if certificate_has_private_key is not None: - query_parameters['certificate.hasPrivateKey'] = _SERIALIZER.query("certificate_has_private_key", certificate_has_private_key, 'bool') + _params["certificate.hasPrivateKey"] = _SERIALIZER.query( + "certificate_has_private_key", certificate_has_private_key, "bool" + ) if certificate_nonce is not None: - query_parameters['certificate.nonce'] = _SERIALIZER.query("certificate_nonce", certificate_nonce, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["certificate.nonce"] = _SERIALIZER.query("certificate_nonce", certificate_nonce, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class DpsCertificateOperations(object): - """DpsCertificateOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothubprovisioningservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class DpsCertificateOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothubprovisioningservices.IotDpsClient`'s + :attr:`dps_certificate` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( @@ -381,42 +391,57 @@ def get( provisioning_service_name: str, if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateResponse": + ) -> _models.CertificateResponse: """Get the certificate from the provisioning service. - :param certificate_name: Name of the certificate to retrieve. + :param certificate_name: Name of the certificate to retrieve. Required. :type certificate_name: str - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str :param provisioning_service_name: Name of the provisioning service the certificate is - associated with. + associated with. Required. :type provisioning_service_name: str - :param if_match: ETag of the certificate. + :param if_match: ETag of the certificate. Default value is None. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateResponse, or the result of cls(response) + :return: CertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResponse] - request = build_get_request( certificate_name=certificate_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -424,15 +449,87 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResponse', pipeline_response) + deserialized = self._deserialize("CertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}"} # type: ignore + @overload + def create_or_update( + self, + resource_group_name: str, + provisioning_service_name: str, + certificate_name: str, + certificate_description: _models.CertificateResponse, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateResponse: + """Upload the certificate to the provisioning service. + + Add new certificate or update an existing certificate. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: The name of the provisioning service. Required. + :type provisioning_service_name: str + :param certificate_name: The name of the certificate create or update. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: + ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse + :param if_match: ETag of the certificate. This is required to update an existing certificate, + and ignored while creating a brand new certificate. Default value is None. + :type if_match: str + :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: CertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + provisioning_service_name: str, + certificate_name: str, + certificate_description: IO, + if_match: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateResponse: + """Upload the certificate to the provisioning service. + + Add new certificate or update an existing certificate. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: The name of the provisioning service. Required. + :type provisioning_service_name: str + :param certificate_name: The name of the certificate create or update. Required. + :type certificate_name: str + :param certificate_description: The certificate body. Required. + :type certificate_description: IO + :param if_match: ETag of the certificate. This is required to update an existing certificate, + and ignored while creating a brand new certificate. 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: CertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def create_or_update( @@ -440,55 +537,81 @@ def create_or_update( resource_group_name: str, provisioning_service_name: str, certificate_name: str, - certificate_description: "_models.CertificateBodyDescription", + certificate_description: Union[_models.CertificateResponse, IO], if_match: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateResponse": + ) -> _models.CertificateResponse: """Upload the certificate to the provisioning service. Add new certificate or update an existing certificate. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param provisioning_service_name: The name of the provisioning service. + :param provisioning_service_name: The name of the provisioning service. Required. :type provisioning_service_name: str - :param certificate_name: The name of the certificate create or update. + :param certificate_name: The name of the certificate create or update. Required. :type certificate_name: str - :param certificate_description: The certificate body. + :param certificate_description: The certificate body. Is either a model type or a IO type. + Required. :type certificate_description: - ~azure.mgmt.iothubprovisioningservices.models.CertificateBodyDescription + ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse or IO :param if_match: ETag of the certificate. This is required to update an existing certificate, - and ignored while creating a brand new certificate. + and ignored while creating a brand new certificate. 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: CertificateResponse, or the result of cls(response) + :return: CertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResponse] - _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(certificate_description, (IO, bytes)): + _content = certificate_description + else: + _json = self._serialize.body(certificate_description, "CertificateResponse") request = build_create_or_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -496,27 +619,26 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResponse', pipeline_response) + deserialized = self._deserialize("CertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}"} # type: ignore @distributed_trace - def delete( + def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, if_match: str, provisioning_service_name: str, certificate_name: str, certificate_name1: Optional[str] = None, - certificate_raw_bytes: Optional[bytearray] = None, + certificate_raw_bytes: Optional[bytes] = None, certificate_is_verified: Optional[bool] = None, - certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, certificate_created: Optional[datetime.datetime] = None, certificate_last_updated: Optional[datetime.datetime] = None, certificate_has_private_key: Optional[bool] = None, @@ -527,50 +649,63 @@ def delete( Deletes the specified certificate associated with the Provisioning Service. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param if_match: ETag of the certificate. + :param if_match: ETag of the certificate. Required. :type if_match: str - :param provisioning_service_name: The name of the provisioning service. + :param provisioning_service_name: The name of the provisioning service. Required. :type provisioning_service_name: str :param certificate_name: This is a mandatory field, and is the logical name of the certificate - that the provisioning service will access by. + that the provisioning service will access by. Required. :type certificate_name: str :param certificate_name1: This is optional, and it is the Common Name of the certificate. + Default value is None. :type certificate_name1: str - :param certificate_raw_bytes: Raw data within the certificate. - :type certificate_raw_bytes: bytearray + :param certificate_raw_bytes: Raw data within the certificate. Default value is None. + :type certificate_raw_bytes: bytes :param certificate_is_verified: Indicates if certificate has been verified by owner of the - private key. + private key. Default value is None. :type certificate_is_verified: bool - :param certificate_purpose: A description that mentions the purpose of the certificate. + :param certificate_purpose: A description that mentions the purpose of the certificate. Known + values are: "clientAuthentication" and "serverAuthentication". Default value is None. :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose - :param certificate_created: Time the certificate is created. + :param certificate_created: Time the certificate is created. Default value is None. :type certificate_created: ~datetime.datetime - :param certificate_last_updated: Time the certificate is last updated. + :param certificate_last_updated: Time the certificate is last updated. Default value is None. :type certificate_last_updated: ~datetime.datetime :param certificate_has_private_key: Indicates if the certificate contains a private key. + Default value is None. :type certificate_has_private_key: bool - :param certificate_nonce: Random number generated to indicate Proof of Possession. + :param certificate_nonce: Random number generated to indicate Proof of Possession. Default + value is None. :type certificate_nonce: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, if_match=if_match, certificate_name1=certificate_name1, certificate_raw_bytes=certificate_raw_bytes, @@ -580,12 +715,18 @@ def delete( certificate_last_updated=certificate_last_updated, certificate_has_private_key=certificate_has_private_key, certificate_nonce=certificate_nonce, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -596,44 +737,56 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - provisioning_service_name: str, - **kwargs: Any - ) -> "_models.CertificateListDescription": + self, resource_group_name: str, provisioning_service_name: str, **kwargs: Any + ) -> _models.CertificateListDescription: """Get all the certificates tied to the provisioning service. - :param resource_group_name: Name of resource group. + :param resource_group_name: Name of resource group. Required. :type resource_group_name: str :param provisioning_service_name: Name of provisioning service to retrieve certificates for. + Required. :type provisioning_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CertificateListDescription, or the result of cls(response) + :return: CertificateListDescription or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateListDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateListDescription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateListDescription] - request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -641,15 +794,14 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateListDescription', pipeline_response) + deserialized = self._deserialize("CertificateListDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates'} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates"} # type: ignore @distributed_trace def generate_verification_code( @@ -659,62 +811,74 @@ def generate_verification_code( resource_group_name: str, provisioning_service_name: str, certificate_name1: Optional[str] = None, - certificate_raw_bytes: Optional[bytearray] = None, + certificate_raw_bytes: Optional[bytes] = None, certificate_is_verified: Optional[bool] = None, - certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, certificate_created: Optional[datetime.datetime] = None, certificate_last_updated: Optional[datetime.datetime] = None, certificate_has_private_key: Optional[bool] = None, certificate_nonce: Optional[str] = None, **kwargs: Any - ) -> "_models.VerificationCodeResponse": + ) -> _models.VerificationCodeResponse: """Generate verification code for Proof of Possession. :param certificate_name: The mandatory logical name of the certificate, that the provisioning - service uses to access. + service uses to access. Required. :type certificate_name: str :param if_match: ETag of the certificate. This is required to update an existing certificate, - and ignored while creating a brand new certificate. + and ignored while creating a brand new certificate. Required. :type if_match: str - :param resource_group_name: name of resource group. + :param resource_group_name: name of resource group. Required. :type resource_group_name: str - :param provisioning_service_name: Name of provisioning service. + :param provisioning_service_name: Name of provisioning service. Required. :type provisioning_service_name: str - :param certificate_name1: Common Name for the certificate. + :param certificate_name1: Common Name for the certificate. Default value is None. :type certificate_name1: str - :param certificate_raw_bytes: Raw data of certificate. - :type certificate_raw_bytes: bytearray + :param certificate_raw_bytes: Raw data of certificate. Default value is None. + :type certificate_raw_bytes: bytes :param certificate_is_verified: Indicates if the certificate has been verified by owner of the - private key. + private key. Default value is None. :type certificate_is_verified: bool - :param certificate_purpose: Description mentioning the purpose of the certificate. + :param certificate_purpose: Description mentioning the purpose of the certificate. Known values + are: "clientAuthentication" and "serverAuthentication". Default value is None. :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose - :param certificate_created: Certificate creation time. + :param certificate_created: Certificate creation time. Default value is None. :type certificate_created: ~datetime.datetime - :param certificate_last_updated: Certificate last updated time. + :param certificate_last_updated: Certificate last updated time. Default value is None. :type certificate_last_updated: ~datetime.datetime - :param certificate_has_private_key: Indicates if the certificate contains private key. + :param certificate_has_private_key: Indicates if the certificate contains private key. Default + value is None. :type certificate_has_private_key: bool - :param certificate_nonce: Random number generated to indicate Proof of Possession. + :param certificate_nonce: Random number generated to indicate Proof of Possession. Default + value is None. :type certificate_nonce: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: VerificationCodeResponse, or the result of cls(response) + :return: VerificationCodeResponse or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.VerificationCodeResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.VerificationCodeResponse] - request = build_generate_verification_code_request( certificate_name=certificate_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, if_match=if_match, certificate_name1=certificate_name1, certificate_raw_bytes=certificate_raw_bytes, @@ -724,12 +888,18 @@ def generate_verification_code( certificate_last_updated=certificate_last_updated, certificate_has_private_key=certificate_has_private_key, certificate_nonce=certificate_nonce, - template_url=self.generate_verification_code.metadata['url'], + api_version=api_version, + template_url=self.generate_verification_code.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -737,15 +907,146 @@ def generate_verification_code( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('VerificationCodeResponse', pipeline_response) + deserialized = self._deserialize("VerificationCodeResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + generate_verification_code.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode"} # type: ignore + @overload + def verify_certificate( + self, + certificate_name: str, + if_match: str, + resource_group_name: str, + provisioning_service_name: str, + request: _models.VerificationCodeRequest, + certificate_name1: Optional[str] = None, + certificate_raw_bytes: Optional[bytes] = None, + certificate_is_verified: Optional[bool] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, + certificate_created: Optional[datetime.datetime] = None, + certificate_last_updated: Optional[datetime.datetime] = None, + certificate_has_private_key: Optional[bool] = None, + certificate_nonce: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateResponse: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param certificate_name: The mandatory logical name of the certificate, that the provisioning + service uses to access. Required. + :type certificate_name: str + :param if_match: ETag of the certificate. Required. + :type if_match: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param provisioning_service_name: Provisioning service name. Required. + :type provisioning_service_name: str + :param request: The name of the certificate. Required. + :type request: ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeRequest + :param certificate_name1: Common Name for the certificate. Default value is None. + :type certificate_name1: str + :param certificate_raw_bytes: Raw data of certificate. Default value is None. + :type certificate_raw_bytes: bytes + :param certificate_is_verified: Indicates if the certificate has been verified by owner of the + private key. Default value is None. + :type certificate_is_verified: bool + :param certificate_purpose: Describe the purpose of the certificate. Known values are: + "clientAuthentication" and "serverAuthentication". Default value is None. + :type certificate_purpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :param certificate_created: Certificate creation time. Default value is None. + :type certificate_created: ~datetime.datetime + :param certificate_last_updated: Certificate last updated time. Default value is None. + :type certificate_last_updated: ~datetime.datetime + :param certificate_has_private_key: Indicates if the certificate contains private key. Default + value is None. + :type certificate_has_private_key: bool + :param certificate_nonce: Random number generated to indicate Proof of Possession. Default + value is None. + :type certificate_nonce: str + :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: CertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def verify_certificate( + self, + certificate_name: str, + if_match: str, + resource_group_name: str, + provisioning_service_name: str, + request: IO, + certificate_name1: Optional[str] = None, + certificate_raw_bytes: Optional[bytes] = None, + certificate_is_verified: Optional[bool] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, + certificate_created: Optional[datetime.datetime] = None, + certificate_last_updated: Optional[datetime.datetime] = None, + certificate_has_private_key: Optional[bool] = None, + certificate_nonce: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CertificateResponse: + """Verify certificate's private key possession. + + Verifies the certificate's private key possession by providing the leaf cert issued by the + verifying pre uploaded certificate. + + :param certificate_name: The mandatory logical name of the certificate, that the provisioning + service uses to access. Required. + :type certificate_name: str + :param if_match: ETag of the certificate. Required. + :type if_match: str + :param resource_group_name: Resource group name. Required. + :type resource_group_name: str + :param provisioning_service_name: Provisioning service name. Required. + :type provisioning_service_name: str + :param request: The name of the certificate. Required. + :type request: IO + :param certificate_name1: Common Name for the certificate. Default value is None. + :type certificate_name1: str + :param certificate_raw_bytes: Raw data of certificate. Default value is None. + :type certificate_raw_bytes: bytes + :param certificate_is_verified: Indicates if the certificate has been verified by owner of the + private key. Default value is None. + :type certificate_is_verified: bool + :param certificate_purpose: Describe the purpose of the certificate. Known values are: + "clientAuthentication" and "serverAuthentication". Default value is None. + :type certificate_purpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :param certificate_created: Certificate creation time. Default value is None. + :type certificate_created: ~datetime.datetime + :param certificate_last_updated: Certificate last updated time. Default value is None. + :type certificate_last_updated: ~datetime.datetime + :param certificate_has_private_key: Indicates if the certificate contains private key. Default + value is None. + :type certificate_has_private_key: bool + :param certificate_nonce: Random number generated to indicate Proof of Possession. Default + value is None. + :type certificate_nonce: 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: CertificateResponse or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def verify_certificate( @@ -754,74 +1055,93 @@ def verify_certificate( if_match: str, resource_group_name: str, provisioning_service_name: str, - request: "_models.VerificationCodeRequest", + request: Union[_models.VerificationCodeRequest, IO], certificate_name1: Optional[str] = None, - certificate_raw_bytes: Optional[bytearray] = None, + certificate_raw_bytes: Optional[bytes] = None, certificate_is_verified: Optional[bool] = None, - certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_purpose: Optional[Union[str, _models.CertificatePurpose]] = None, certificate_created: Optional[datetime.datetime] = None, certificate_last_updated: Optional[datetime.datetime] = None, certificate_has_private_key: Optional[bool] = None, certificate_nonce: Optional[str] = None, **kwargs: Any - ) -> "_models.CertificateResponse": + ) -> _models.CertificateResponse: """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the verifying pre uploaded certificate. :param certificate_name: The mandatory logical name of the certificate, that the provisioning - service uses to access. + service uses to access. Required. :type certificate_name: str - :param if_match: ETag of the certificate. + :param if_match: ETag of the certificate. Required. :type if_match: str - :param resource_group_name: Resource group name. + :param resource_group_name: Resource group name. Required. :type resource_group_name: str - :param provisioning_service_name: Provisioning service name. + :param provisioning_service_name: Provisioning service name. Required. :type provisioning_service_name: str - :param request: The name of the certificate. - :type request: ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeRequest - :param certificate_name1: Common Name for the certificate. + :param request: The name of the certificate. Is either a model type or a IO type. Required. + :type request: ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeRequest or IO + :param certificate_name1: Common Name for the certificate. Default value is None. :type certificate_name1: str - :param certificate_raw_bytes: Raw data of certificate. - :type certificate_raw_bytes: bytearray + :param certificate_raw_bytes: Raw data of certificate. Default value is None. + :type certificate_raw_bytes: bytes :param certificate_is_verified: Indicates if the certificate has been verified by owner of the - private key. + private key. Default value is None. :type certificate_is_verified: bool - :param certificate_purpose: Describe the purpose of the certificate. + :param certificate_purpose: Describe the purpose of the certificate. Known values are: + "clientAuthentication" and "serverAuthentication". Default value is None. :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose - :param certificate_created: Certificate creation time. + :param certificate_created: Certificate creation time. Default value is None. :type certificate_created: ~datetime.datetime - :param certificate_last_updated: Certificate last updated time. + :param certificate_last_updated: Certificate last updated time. Default value is None. :type certificate_last_updated: ~datetime.datetime - :param certificate_has_private_key: Indicates if the certificate contains private key. + :param certificate_has_private_key: Indicates if the certificate contains private key. Default + value is None. :type certificate_has_private_key: bool - :param certificate_nonce: Random number generated to indicate Proof of Possession. + :param certificate_nonce: Random number generated to indicate Proof of Possession. Default + value is None. :type certificate_nonce: 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: CertificateResponse, or the result of cls(response) + :return: CertificateResponse or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.CertificateResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CertificateResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CertificateResponse] - _json = self._serialize.body(request, 'VerificationCodeRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(request, (IO, bytes)): + _content = request + else: + _json = self._serialize.body(request, "VerificationCodeRequest") request = build_verify_certificate_request( certificate_name=certificate_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, - content_type=content_type, + subscription_id=self._config.subscription_id, if_match=if_match, - json=_json, certificate_name1=certificate_name1, certificate_raw_bytes=certificate_raw_bytes, certificate_is_verified=certificate_is_verified, @@ -830,12 +1150,21 @@ def verify_certificate( certificate_last_updated=certificate_last_updated, certificate_has_private_key=certificate_has_private_key, certificate_nonce=certificate_nonce, - template_url=self.verify_certificate.metadata['url'], + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.verify_certificate.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -843,12 +1172,11 @@ def verify_certificate( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CertificateResponse', pipeline_response) + deserialized = self._deserialize("CertificateResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - verify_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify'} # type: ignore - + verify_certificate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_iot_dps_resource_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_iot_dps_resource_operations.py index 49de021e3d5f..4b8e1d845151 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_iot_dps_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_iot_dps_resource_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,724 +6,669 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, List, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( - provisioning_service_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any + provisioning_service_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - provisioning_service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_create_or_update_request( + resource_group_name: str, provisioning_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-10-15" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", + ) # 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'), - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - provisioning_service_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + +def build_update_request( + resource_group_name: str, provisioning_service_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-10-15" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", + ) # 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'), - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( - provisioning_service_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any + +def build_delete_request( + provisioning_service_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices", + ) # 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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_operation_result_request( operation_id: str, - subscription_id: str, resource_group_name: str, provisioning_service_name: str, + subscription_id: str, *, asyncinfo: str = "true", **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + "operationId": _SERIALIZER.url("operation_id", operation_id, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['asyncinfo'] = _SERIALIZER.query("asyncinfo", asyncinfo, 'str') - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["asyncinfo"] = _SERIALIZER.query("asyncinfo", asyncinfo, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_valid_skus_request( - provisioning_service_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any + provisioning_service_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus", + ) # pylint: disable=line-too-long path_format_arguments = { - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_check_provisioning_service_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2021-10-15" - accept = "application/json" +def build_check_provisioning_service_name_availability_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - provisioning_service_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any + provisioning_service_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_for_key_name_request( - provisioning_service_name: str, - key_name: str, - subscription_id: str, - resource_group_name: str, - **kwargs: Any + provisioning_service_name: str, key_name: str, resource_group_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), - "keyName": _SERIALIZER.url("key_name", key_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, "str"), + "keyName": _SERIALIZER.url("key_name", key_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_private_link_resources_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_private_link_resources_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any + resource_group_name: str, resource_name: str, group_id: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "groupId": _SERIALIZER.url("group_id", group_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "groupId": _SERIALIZER.url("group_id", group_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_private_endpoint_connections_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_private_endpoint_connection_request( - subscription_id: str, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_private_endpoint_connection_request_initial( - subscription_id: str, + +def build_create_or_update_private_endpoint_connection_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-10-15" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_private_endpoint_connection_request_initial( - subscription_id: str, + +def build_delete_private_endpoint_connection_request( resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -class IotDpsResourceOperations(object): - """IotDpsResourceOperations operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class IotDpsResourceOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothubprovisioningservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.iothubprovisioningservices.IotDpsClient`'s + :attr:`iot_dps_resource` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def get( - self, - provisioning_service_name: str, - resource_group_name: str, - **kwargs: Any - ) -> "_models.ProvisioningServiceDescription": + self, provisioning_service_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.ProvisioningServiceDescription: """Get the non-security related metadata of the provisioning service. Get the metadata of the provisioning service without SAS keys. - :param provisioning_service_name: Name of the provisioning service to retrieve. + :param provisioning_service_name: Name of the provisioning service to retrieve. Required. :type provisioning_service_name: str - :param resource_group_name: Resource group name. + :param resource_group_name: Resource group name. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ProvisioningServiceDescription, or the result of cls(response) + :return: ProvisioningServiceDescription or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescription] - request = build_get_request( provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -730,86 +676,113 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, provisioning_service_name: str, - iot_dps_description: "_models.ProvisioningServiceDescription", + iot_dps_description: Union[_models.ProvisioningServiceDescription, IO], **kwargs: Any - ) -> "_models.ProvisioningServiceDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] + ) -> _models.ProvisioningServiceDescription: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(iot_dps_description, 'ProvisioningServiceDescription') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(iot_dps_description, (IO, bytes)): + _content = iot_dps_description + else: + _json = self._serialize.body(iot_dps_description, "ProvisioningServiceDescription") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore - + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore - @distributed_trace + @overload def begin_create_or_update( self, resource_group_name: str, provisioning_service_name: str, - iot_dps_description: "_models.ProvisioningServiceDescription", + iot_dps_description: _models.ProvisioningServiceDescription, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.ProvisioningServiceDescription"]: + ) -> LROPoller[_models.ProvisioningServiceDescription]: """Create or update the metadata of the provisioning service. Create or update the metadata of the provisioning service. The usual pattern to modify a property is to retrieve the provisioning service metadata and security metadata, and then combine them with the modified values in a new body to update the provisioning service. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param provisioning_service_name: Name of provisioning service to create or update. + :param provisioning_service_name: Name of provisioning service to create or update. Required. :type provisioning_service_name: str :param iot_dps_description: Description of the provisioning service to create or update. + Required. :type iot_dps_description: ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription + :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 @@ -822,115 +795,307 @@ def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + provisioning_service_name: str, + iot_dps_description: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ProvisioningServiceDescription]: + """Create or update the metadata of the provisioning service. + + Create or update the metadata of the provisioning service. The usual pattern to modify a + property is to retrieve the provisioning service metadata and security metadata, and then + combine them with the modified values in a new body to update the provisioning service. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service to create or update. Required. + :type provisioning_service_name: str + :param iot_dps_description: Description of the provisioning service to create or update. + Required. + :type iot_dps_description: IO + :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 ProvisioningServiceDescription or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + provisioning_service_name: str, + iot_dps_description: Union[_models.ProvisioningServiceDescription, IO], + **kwargs: Any + ) -> LROPoller[_models.ProvisioningServiceDescription]: + """Create or update the metadata of the provisioning service. + + Create or update the metadata of the provisioning service. The usual pattern to modify a + property is to retrieve the provisioning service metadata and security metadata, and then + combine them with the modified values in a new body to update the provisioning service. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service to create or update. Required. + :type provisioning_service_name: str + :param iot_dps_description: Description of the provisioning service to create or update. Is + either a model type or a IO type. Required. + :type iot_dps_description: + ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription 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. + :return: An instance of LROPoller that returns either ProvisioningServiceDescription or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, iot_dps_description=iot_dps_description, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore def _update_initial( self, resource_group_name: str, provisioning_service_name: str, - provisioning_service_tags: "_models.TagsResource", + provisioning_service_tags: Union[_models.TagsResource, IO], **kwargs: Any - ) -> "_models.ProvisioningServiceDescription": - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] + ) -> _models.ProvisioningServiceDescription: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(provisioning_service_tags, 'TagsResource') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescription] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(provisioning_service_tags, (IO, bytes)): + _content = provisioning_service_tags + else: + _json = self._serialize.body(provisioning_service_tags, "TagsResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + provisioning_service_name: str, + provisioning_service_tags: _models.TagsResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ProvisioningServiceDescription]: + """Update an existing provisioning service's tags. + + Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate + method. + + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service to create or update. Required. + :type provisioning_service_name: str + :param provisioning_service_tags: Updated tag information to set into the provisioning service + instance. Required. + :type provisioning_service_tags: ~azure.mgmt.iothubprovisioningservices.models.TagsResource + :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 ProvisioningServiceDescription or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + provisioning_service_name: str, + provisioning_service_tags: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.ProvisioningServiceDescription]: + """Update an existing provisioning service's tags. + + Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate + method. + :param resource_group_name: Resource group identifier. Required. + :type resource_group_name: str + :param provisioning_service_name: Name of provisioning service to create or update. Required. + :type provisioning_service_name: str + :param provisioning_service_tags: Updated tag information to set into the provisioning service + instance. Required. + :type provisioning_service_tags: IO + :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 ProvisioningServiceDescription or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, provisioning_service_name: str, - provisioning_service_tags: "_models.TagsResource", + provisioning_service_tags: Union[_models.TagsResource, IO], **kwargs: Any - ) -> LROPoller["_models.ProvisioningServiceDescription"]: + ) -> LROPoller[_models.ProvisioningServiceDescription]: """Update an existing provisioning service's tags. Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate method. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str - :param provisioning_service_name: Name of provisioning service to create or update. + :param provisioning_service_name: Name of provisioning service to create or update. Required. :type provisioning_service_name: str :param provisioning_service_tags: Updated tag information to set into the provisioning service - instance. - :type provisioning_service_tags: ~azure.mgmt.iothubprovisioningservices.models.TagsResource + instance. Is either a model type or a IO type. Required. + :type provisioning_service_tags: ~azure.mgmt.iothubprovisioningservices.models.TagsResource 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 @@ -943,99 +1108,112 @@ def begin_update( result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescription] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, provisioning_service_tags=provisioning_service_tags, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('ProvisioningServiceDescription', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescription", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore - def _delete_initial( - self, - provisioning_service_name: str, - resource_group_name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, provisioning_service_name: str, resource_group_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore @distributed_trace - def begin_delete( - self, - provisioning_service_name: str, - resource_group_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, provisioning_service_name: str, resource_group_name: str, **kwargs: Any) -> LROPoller[None]: """Delete the Provisioning Service. Deletes the Provisioning Service. - :param provisioning_service_name: Name of provisioning service to delete. + :param provisioning_service_name: Name of provisioning service to delete. Required. :type provisioning_service_name: str - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_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. @@ -1047,83 +1225,108 @@ def begin_delete( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore provisioning_service_name=provisioning_service_name, resource_group_name=resource_group_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.ProvisioningServiceDescriptionListResult"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.ProvisioningServiceDescription"]: """Get all the provisioning services in a subscription. List all the provisioning services for a given subscription id. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProvisioningServiceDescriptionListResult or the - result of cls(response) + :return: An iterator like instance of either ProvisioningServiceDescription or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescriptionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescriptionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore - else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, + 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1137,7 +1340,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1147,54 +1352,70 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.ProvisioningServiceDescriptionListResult"]: + self, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.ProvisioningServiceDescription"]: """Get a list of all provisioning services in the given resource group. - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. 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 ProvisioningServiceDescriptionListResult or the - result of cls(response) + :return: An iterator like instance of either ProvisioningServiceDescription or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescriptionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ProvisioningServiceDescriptionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1208,7 +1429,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1218,11 +1441,9 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices"} # type: ignore @distributed_trace def get_operation_result( @@ -1232,45 +1453,60 @@ def get_operation_result( provisioning_service_name: str, asyncinfo: str = "true", **kwargs: Any - ) -> "_models.AsyncOperationResult": + ) -> _models.AsyncOperationResult: """Gets the status of a long running operation, such as create, update or delete a provisioning service. :param operation_id: Operation id corresponding to long running operation. Use this to poll for - the status. + the status. Required. :type operation_id: str - :param resource_group_name: Resource group identifier. + :param resource_group_name: Resource group identifier. Required. :type resource_group_name: str :param provisioning_service_name: Name of provisioning service that the operation is running - on. + on. Required. :type provisioning_service_name: str :param asyncinfo: Async header used to poll on the status of the operation, obtained while - creating the long running operation. + creating the long running operation. Default value is "true". :type asyncinfo: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: AsyncOperationResult, or the result of cls(response) + :return: AsyncOperationResult or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.AsyncOperationResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.AsyncOperationResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AsyncOperationResult] - request = build_get_operation_result_request( operation_id=operation_id, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, asyncinfo=asyncinfo, - template_url=self.get_operation_result.metadata['url'], + api_version=api_version, + template_url=self.get_operation_result.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1278,65 +1514,79 @@ def get_operation_result( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('AsyncOperationResult', pipeline_response) + deserialized = self._deserialize("AsyncOperationResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_operation_result.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}'} # type: ignore - + get_operation_result.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}"} # type: ignore @distributed_trace def list_valid_skus( - self, - provisioning_service_name: str, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.IotDpsSkuDefinitionListResult"]: + self, provisioning_service_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.IotDpsSkuDefinition"]: """Get the list of valid SKUs for a provisioning service. Gets the list of valid SKUs and tiers for a provisioning service. - :param provisioning_service_name: Name of provisioning service. + :param provisioning_service_name: Name of provisioning service. Required. :type provisioning_service_name: str - :param resource_group_name: Name of resource group. + :param resource_group_name: Name of resource group. 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 IotDpsSkuDefinitionListResult or the result of - cls(response) + :return: An iterator like instance of either IotDpsSkuDefinition or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinitionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinition] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.IotDpsSkuDefinitionListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.IotDpsSkuDefinitionListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_valid_skus_request( provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_valid_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_valid_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_valid_skus_request( - provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1350,7 +1600,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1360,51 +1612,114 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus'} # type: ignore + list_valid_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus"} # type: ignore - @distributed_trace + @overload def check_provisioning_service_name_availability( - self, - arguments: "_models.OperationInputs", - **kwargs: Any - ) -> "_models.NameAvailabilityInfo": + self, arguments: _models.OperationInputs, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityInfo: """Check if a provisioning service name is available. Check if a provisioning service name is available. This will validate if the name is syntactically valid and if the name is usable. :param arguments: Set the name parameter in the OperationInputs structure to the name of the - provisioning service to check. + provisioning service to check. Required. :type arguments: ~azure.mgmt.iothubprovisioningservices.models.OperationInputs + :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: NameAvailabilityInfo, or the result of cls(response) + :return: NameAvailabilityInfo or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.NameAvailabilityInfo - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailabilityInfo"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def check_provisioning_service_name_availability( + self, arguments: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailabilityInfo: + """Check if a provisioning service name is available. + + Check if a provisioning service name is available. This will validate if the name is + syntactically valid and if the name is usable. + + :param arguments: Set the name parameter in the OperationInputs structure to the name of the + provisioning service to check. Required. + :type arguments: IO + :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: NameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.NameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_provisioning_service_name_availability( + self, arguments: Union[_models.OperationInputs, IO], **kwargs: Any + ) -> _models.NameAvailabilityInfo: + """Check if a provisioning service name is available. + + Check if a provisioning service name is available. This will validate if the name is + syntactically valid and if the name is usable. - _json = self._serialize.body(arguments, 'OperationInputs') + :param arguments: Set the name parameter in the OperationInputs structure to the name of the + provisioning service to check. Is either a model type or a IO type. Required. + :type arguments: ~azure.mgmt.iothubprovisioningservices.models.OperationInputs 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 + :return: NameAvailabilityInfo or the result of cls(response) + :rtype: ~azure.mgmt.iothubprovisioningservices.models.NameAvailabilityInfo + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailabilityInfo] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(arguments, (IO, bytes)): + _content = arguments + else: + _json = self._serialize.body(arguments, "OperationInputs") request = build_check_provisioning_service_name_availability_request( subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_provisioning_service_name_availability.metadata['url'], + content=_content, + template_url=self.check_provisioning_service_name_availability.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1412,66 +1727,81 @@ def check_provisioning_service_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailabilityInfo', pipeline_response) + deserialized = self._deserialize("NameAvailabilityInfo", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_provisioning_service_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability'} # type: ignore - + check_provisioning_service_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability"} # type: ignore @distributed_trace def list_keys( - self, - provisioning_service_name: str, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + self, provisioning_service_name: str, resource_group_name: str, **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription"]: """Get the security metadata for a provisioning service. List the primary and secondary keys for a provisioning service. :param provisioning_service_name: The provisioning service name to get the shared access keys - for. + for. Required. :type provisioning_service_name: str - :param resource_group_name: resource group name. + :param resource_group_name: resource group name. 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 SharedAccessSignatureAuthorizationRuleListResult - or the result of cls(response) + :return: An iterator like instance of either + SharedAccessSignatureAuthorizationRuleAccessRightsDescription or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_keys_request( provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_keys_request( - provisioning_service_name=provisioning_service_name, - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -1485,7 +1815,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1495,56 +1827,67 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys'} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys"} # type: ignore @distributed_trace def list_keys_for_key_name( - self, - provisioning_service_name: str, - key_name: str, - resource_group_name: str, - **kwargs: Any - ) -> "_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription": + self, provisioning_service_name: str, key_name: str, resource_group_name: str, **kwargs: Any + ) -> _models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription: """Get a shared access policy by name from a provisioning service. List primary and secondary keys for a specific key name. - :param provisioning_service_name: Name of the provisioning service. + :param provisioning_service_name: Name of the provisioning service. Required. :type provisioning_service_name: str - :param key_name: Logical key name to get key-values for. + :param key_name: Logical key name to get key-values for. Required. :type key_name: str :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRuleAccessRightsDescription, or the result of + :return: SharedAccessSignatureAuthorizationRuleAccessRightsDescription or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop( + "cls", None + ) # type: ClsType[_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] - request = build_list_keys_for_key_name_request( provisioning_service_name=provisioning_service_name, key_name=key_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_keys_for_key_name.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys_for_key_name.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1552,54 +1895,67 @@ def list_keys_for_key_name( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleAccessRightsDescription', pipeline_response) + deserialized = self._deserialize( + "SharedAccessSignatureAuthorizationRuleAccessRightsDescription", pipeline_response + ) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys'} # type: ignore - + list_keys_for_key_name.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys"} # type: ignore @distributed_trace def list_private_link_resources( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateLinkResources": + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.PrivateLinkResources: """List private link resources. List private link resources for the given provisioning service. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResources, or the result of cls(response) + :return: PrivateLinkResources or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.PrivateLinkResources - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResources"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResources] - request = build_list_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_private_link_resources.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1607,58 +1963,68 @@ def list_private_link_resources( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResources', pipeline_response) + deserialized = self._deserialize("PrivateLinkResources", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources'} # type: ignore - + list_private_link_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources"} # type: ignore @distributed_trace def get_private_link_resources( - self, - resource_group_name: str, - resource_name: str, - group_id: str, - **kwargs: Any - ) -> "_models.GroupIdInformation": + self, resource_group_name: str, resource_name: str, group_id: str, **kwargs: Any + ) -> _models.GroupIdInformation: """Get the specified private link resource. Get the specified private link resource for the given provisioning service. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str - :param group_id: The name of the private link resource. + :param group_id: The name of the private link resource. Required. :type group_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: GroupIdInformation, or the result of cls(response) + :return: GroupIdInformation or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.GroupIdInformation - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.GroupIdInformation"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.GroupIdInformation] - request = build_get_private_link_resources_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, group_id=group_id, - template_url=self.get_private_link_resources.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_link_resources.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1666,54 +2032,65 @@ def get_private_link_resources( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('GroupIdInformation', pipeline_response) + deserialized = self._deserialize("GroupIdInformation", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}'} # type: ignore - + get_private_link_resources.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}"} # type: ignore @distributed_trace def list_private_endpoint_connections( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> List["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> List[_models.PrivateEndpointConnection]: """List private endpoint connections. List private endpoint connection properties. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: list of PrivateEndpointConnection, or the result of cls(response) + :return: list of PrivateEndpointConnection or the result of cls(response) :rtype: list[~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[List["_models.PrivateEndpointConnection"]] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[List[_models.PrivateEndpointConnection]] - request = build_list_private_endpoint_connections_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_private_endpoint_connections.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_private_endpoint_connections.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1721,58 +2098,68 @@ def list_private_endpoint_connections( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) + deserialized = self._deserialize("[PrivateEndpointConnection]", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_private_endpoint_connections.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections'} # type: ignore - + list_private_endpoint_connections.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace def get_private_endpoint_connection( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get private endpoint connection. Get private endpoint connection properties. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_private_endpoint_connection_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self.get_private_endpoint_connection.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get_private_endpoint_connection.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1780,90 +2167,117 @@ def get_private_endpoint_connection( error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + get_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _create_or_update_private_endpoint_connection_initial( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] + ) -> _models.PrivateEndpointConnection: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(private_endpoint_connection, (IO, bytes)): + _content = private_endpoint_connection + else: + _json = self._serialize.body(private_endpoint_connection, "PrivateEndpointConnection") - request = build_create_or_update_private_endpoint_connection_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_private_endpoint_connection_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_private_endpoint_connection_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_private_endpoint_connection_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_private_endpoint_connection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + _create_or_update_private_endpoint_connection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - - @distributed_trace + @overload def begin_create_or_update_private_endpoint_connection( self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, - private_endpoint_connection: "_models.PrivateEndpointConnection", + private_endpoint_connection: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + ) -> LROPoller[_models.PrivateEndpointConnection]: """Create or update private endpoint connection. Create or update the status of a private endpoint connection with the specified name. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. :type private_endpoint_connection: ~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection + :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 @@ -1876,115 +2290,220 @@ def begin_create_or_update_private_endpoint_connection( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + + @overload + def begin_create_or_update_private_endpoint_connection( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Create or update private endpoint connection. + + Create or update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the provisioning + service. Required. + :type resource_group_name: str + :param resource_name: The name of the provisioning service. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. + Required. + :type private_endpoint_connection: IO + :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.iothubprovisioningservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_or_update_private_endpoint_connection( + self, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: + """Create or update private endpoint connection. + + Create or update the status of a private endpoint connection with the specified name. + + :param resource_group_name: The name of the resource group that contains the provisioning + service. Required. + :type resource_group_name: str + :param resource_name: The name of the provisioning service. Required. + :type resource_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param private_endpoint_connection: The private endpoint connection with updated properties. Is + either a model type or a IO type. Required. + :type private_endpoint_connection: + ~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection 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. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_private_endpoint_connection_initial( + raw_result = self._create_or_update_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_create_or_update_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore def _delete_private_endpoint_connection_initial( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> Optional["_models.PrivateEndpointConnection"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> Optional[_models.PrivateEndpointConnection]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_private_endpoint_connection_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.PrivateEndpointConnection]] + + request = build_delete_private_endpoint_connection_request( resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - template_url=self._delete_private_endpoint_connection_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_private_endpoint_connection_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None + response_headers = {} if response.status_code == 200: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + response_headers["Azure-AsyncOperation"] = self._deserialize( + "str", response.headers.get("Azure-AsyncOperation") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + response_headers["Retry-After"] = self._deserialize("str", response.headers.get("Retry-After")) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: - return cls(pipeline_response, deserialized, {}) + return cls(pipeline_response, deserialized, response_headers) return deserialized - _delete_private_endpoint_connection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_private_endpoint_connection_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def begin_delete_private_endpoint_connection( - self, - resource_group_name: str, - resource_name: str, - private_endpoint_connection_name: str, - **kwargs: Any - ) -> LROPoller["_models.PrivateEndpointConnection"]: + self, resource_group_name: str, resource_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> LROPoller[_models.PrivateEndpointConnection]: """Delete private endpoint connection. Delete private endpoint connection with the specified name. :param resource_group_name: The name of the resource group that contains the provisioning - service. + service. Required. :type resource_group_name: str - :param resource_name: The name of the provisioning service. + :param resource_name: The name of the provisioning service. Required. :type resource_name: str - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. 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. @@ -1998,44 +2517,50 @@ def begin_delete_private_endpoint_connection( of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_private_endpoint_connection_initial( + raw_result = self._delete_private_endpoint_connection_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete_private_endpoint_connection.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_operations.py index 41c645e0e4b8..fe40a3d5b275 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,107 +6,131 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) 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.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2021-10-15" - accept = "application/json" + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-02-05")) # type: Literal["2022-02-05"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.Devices/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.iothubprovisioningservices.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.iothubprovisioningservices.IotDpsClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationListResult"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Microsoft.Devices REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-02-05"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -119,7 +144,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -129,8 +156,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.Devices/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Devices/operations"} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_patch.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_check_name.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_check_name.py new file mode 100644 index 000000000000..1ace776a7246 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_check_name.py @@ -0,0 +1,40 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_check_name.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.check_provisioning_service_name_availability( + arguments={"name": "test213123"}, + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCheckNameAvailability.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_create.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_create.py new file mode 100644 index 000000000000..16476c56942b --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_create.py @@ -0,0 +1,47 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_create.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.begin_create_or_update( + resource_group_name="myResourceGroup", + provisioning_service_name="myFirstProvisioningService", + iot_dps_description={ + "location": "East US", + "properties": {"enableDataResidency": False}, + "sku": {"capacity": 1, "name": "S1"}, + "tags": {}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreate.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_create_or_update_certificate.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_create_or_update_certificate.py new file mode 100644 index 000000000000..45a244eaeb28 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_create_or_update_certificate.py @@ -0,0 +1,43 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_create_or_update_certificate.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.dps_certificate.create_or_update( + resource_group_name="myResourceGroup", + provisioning_service_name="myFirstProvisioningService", + certificate_name="cert", + certificate_description={"properties": {"certificate": "############################################"}}, + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCertificateCreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_delete.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_delete.py new file mode 100644 index 000000000000..3982335dec6f --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_delete.py @@ -0,0 +1,41 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_delete.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.begin_delete( + provisioning_service_name="myFirstProvisioningService", + resource_group_name="myResourceGroup", + ).result() + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDelete.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_delete_certificate.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_delete_certificate.py new file mode 100644 index 000000000000..159c57795219 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_delete_certificate.py @@ -0,0 +1,43 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_delete_certificate.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.dps_certificate.delete( + resource_group_name="myResourceGroup", + if_match="AAAAAAAADGk=", + provisioning_service_name="myFirstProvisioningService", + certificate_name="cert", + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDeleteCertificate.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_generate_verification_code.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_generate_verification_code.py new file mode 100644 index 000000000000..4a709042702b --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_generate_verification_code.py @@ -0,0 +1,43 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_generate_verification_code.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.dps_certificate.generate_verification_code( + certificate_name="cert", + if_match="AAAAAAAADGk=", + resource_group_name="myResourceGroup", + provisioning_service_name="myFirstProvisioningService", + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGenerateVerificationCode.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get.py new file mode 100644 index 000000000000..bda38b5c329b --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get.py @@ -0,0 +1,41 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_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, + 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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.get( + provisioning_service_name="myFirstProvisioningService", + resource_group_name="myResourceGroup", + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGet.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_certificate.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_certificate.py new file mode 100644 index 000000000000..fe0660289b18 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_certificate.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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_get_certificate.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.dps_certificate.get( + certificate_name="cert", + resource_group_name="myResourceGroup", + provisioning_service_name="myFirstProvisioningService", + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificate.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_certificates.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_certificates.py new file mode 100644 index 000000000000..1393d97ab05a --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_certificates.py @@ -0,0 +1,41 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_get_certificates.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.dps_certificate.list( + resource_group_name="myResourceGroup", + provisioning_service_name="myFirstProvisioningService", + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetCertificates.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_key.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_key.py new file mode 100644 index 000000000000..e4353e4a7b9c --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_key.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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_get_key.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.list_keys_for_key_name( + provisioning_service_name="myFirstProvisioningService", + key_name="testKey", + resource_group_name="myResourceGroup", + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetKey.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_operation_result.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_operation_result.py new file mode 100644 index 000000000000..b403e64ded24 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_operation_result.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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_get_operation_result.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.get_operation_result( + operation_id="MTY5OTNmZDctODI5Yy00N2E2LTkxNDQtMDU1NGIyYzY1ZjRl", + resource_group_name="myResourceGroup", + provisioning_service_name="myFirstProvisioningService", + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetOperationResult.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_valid_sku.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_valid_sku.py new file mode 100644 index 000000000000..962628ef76d8 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_get_valid_sku.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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_get_valid_sku.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.list_valid_skus( + provisioning_service_name="myFirstProvisioningService", + resource_group_name="myResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetValidSku.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_by_resource_group.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_by_resource_group.py new file mode 100644 index 000000000000..d99133769fae --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_by_resource_group.py @@ -0,0 +1,41 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_list_by_resource_group.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.list_by_resource_group( + resource_group_name="myResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_by_subscription.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_by_subscription.py new file mode 100644 index 000000000000..4f614266e419 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_by_subscription.py @@ -0,0 +1,39 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_list_by_subscription.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_keys.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_keys.py new file mode 100644 index 000000000000..272a4729fb84 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_list_keys.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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_list_keys.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.list_keys( + provisioning_service_name="myFirstProvisioningService", + resource_group_name="myResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListKeys.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_operations.py new file mode 100644 index 000000000000..4241d457fed9 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_operations.py @@ -0,0 +1,39 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_operations.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSOperations.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_verify_certificate.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_verify_certificate.py new file mode 100644 index 000000000000..a45b857acfc4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/dps_verify_certificate.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. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python dps_verify_certificate.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.dps_certificate.verify_certificate( + certificate_name="cert", + if_match="AAAAAAAADGk=", + resource_group_name="myResourceGroup", + provisioning_service_name="myFirstProvisioningService", + request={"certificate": "#####################################"}, + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSVerifyCertificate.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_create_or_update.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_create_or_update.py new file mode 100644 index 000000000000..f13aac065790 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_create_or_update.py @@ -0,0 +1,50 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python private_endpoint_connection_create_or_update.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.begin_create_or_update_private_endpoint_connection( + resource_group_name="myResourceGroup", + resource_name="myFirstProvisioningService", + private_endpoint_connection_name="myPrivateEndpointConnection", + private_endpoint_connection={ + "properties": { + "privateLinkServiceConnectionState": { + "description": "Approved by johndoe@contoso.com", + "status": "Approved", + } + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSCreateOrUpdatePrivateEndpointConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_delete.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_delete.py new file mode 100644 index 000000000000..34f27b235198 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_delete.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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python private_endpoint_connection_delete.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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.begin_delete_private_endpoint_connection( + resource_group_name="myResourceGroup", + resource_name="myFirstProvisioningService", + private_endpoint_connection_name="myPrivateEndpointConnection", + ).result() + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSDeletePrivateEndpointConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_get.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_get.py new file mode 100644 index 000000000000..84670f0662dd --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connection_get.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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python private_endpoint_connection_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, + 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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.get_private_endpoint_connection( + resource_group_name="myResourceGroup", + resource_name="myFirstProvisioningService", + private_endpoint_connection_name="myPrivateEndpointConnection", + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSGetPrivateEndpointConnection.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connections_list.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connections_list.py new file mode 100644 index 000000000000..73d36a25b9b5 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_endpoint_connections_list.py @@ -0,0 +1,41 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python private_endpoint_connections_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, + 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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.list_private_endpoint_connections( + resource_group_name="myResourceGroup", + resource_name="myFirstProvisioningService", + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListPrivateEndpointConnections.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_link_resources_list.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_link_resources_list.py new file mode 100644 index 000000000000..1f79ba226f15 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/generated_samples/private_link_resources_list.py @@ -0,0 +1,41 @@ +# 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.iothubprovisioningservices import IotDpsClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-iothubprovisioningservices +# USAGE + python private_link_resources_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, + 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 = IotDpsClient( + credential=DefaultAzureCredential(), + subscription_id="91d12660-3dec-467a-be2a-213b5544ddc0", + ) + + response = client.iot_dps_resource.list_private_link_resources( + resource_group_name="myResourceGroup", + resource_name="myFirstProvisioningService", + ) + print(response) + + +# x-ms-original-file: specification/deviceprovisioningservices/resource-manager/Microsoft.Devices/stable/2022-02-05/examples/DPSListPrivateLinkResources.json +if __name__ == "__main__": + main() diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/setup.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/setup.py index ced7e8906cfb..03f0fc1d743a 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/setup.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/setup.py @@ -55,6 +55,7 @@ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'License :: OSI Approved :: MIT License', ], zip_safe=False, @@ -69,9 +70,10 @@ 'pytyped': ['py.typed'], }, install_requires=[ - 'msrest>=0.7.1', - 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.2,<2.0.0', + "msrest>=0.7.1", + "azure-common~=1.1", + "azure-mgmt-core>=1.3.2,<2.0.0", + "typing-extensions>=4.3.0; python_version<'3.8.0'", ], python_requires=">=3.7" ) diff --git a/shared_requirements.txt b/shared_requirements.txt index 118f0ac6442f..42f3f3528547 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -669,6 +669,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-developer-loadtesting azure-core<2.0.0,>=1.24.0 #override azure-developer-loadtesting isodate<1.0.0,>=0.6.1 #override azure-mgmt-datalake-analytics msrest>=0.6.21 +#override azure-mgmt-iothubprovisioningservices typing-extensions>=4.3.0; python_version<'3.8.0' #override azure-mgmt-datalake-analytics azure-mgmt-core>=1.3.1,<2.0.0 #override azure-mgmt-datalake-store msrest>=0.7.1 #override azure-mgmt-operationsmanagement msrest>=0.7.1 From cc0acf9750e3aa50b4c168f1cf452711f9538da2 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 16 Nov 2022 21:12:35 -0500 Subject: [PATCH 3/7] code and test (#27489) Co-authored-by: PythonSdkPipelines --- sdk/oep/azure-mgmt-oep/CHANGELOG.md | 8 + sdk/oep/azure-mgmt-oep/MANIFEST.in | 4 +- sdk/oep/azure-mgmt-oep/README.md | 2 - sdk/oep/azure-mgmt-oep/_meta.json | 12 +- .../azure-mgmt-oep/azure/mgmt/oep/__init__.py | 18 +- .../azure/mgmt/oep/_configuration.py | 57 +- .../azure/mgmt/oep/_metadata.json | 104 - ...energy_platform_management_service_apis.py | 36 +- .../azure-mgmt-oep/azure/mgmt/oep/_patch.py | 2 +- .../azure/mgmt/oep/_serialization.py | 1970 +++++++++++++++++ .../azure-mgmt-oep/azure/mgmt/oep/_vendor.py | 6 +- .../azure-mgmt-oep/azure/mgmt/oep/_version.py | 2 +- .../azure/mgmt/oep/aio/__init__.py | 18 +- .../azure/mgmt/oep/aio/_configuration.py | 59 +- ...energy_platform_management_service_apis.py | 37 +- .../azure/mgmt/oep/aio/_patch.py | 2 +- .../azure/mgmt/oep/aio/operations/__init__.py | 12 +- .../operations/_energy_services_operations.py | 1195 ++++++++-- .../aio/operations/_locations_operations.py | 140 +- .../mgmt/oep/aio/operations/_operations.py | 98 +- .../azure/mgmt/oep/aio/operations/_patch.py | 20 + .../azure/mgmt/oep/models/__init__.py | 66 +- .../azure/mgmt/oep/models/_models_py3.py | 510 +++-- ..._platform_management_service_apis_enums.py | 27 +- .../azure/mgmt/oep/models/_patch.py | 20 + .../azure/mgmt/oep/operations/__init__.py | 12 +- .../operations/_energy_services_operations.py | 1584 ++++++++++--- .../oep/operations/_locations_operations.py | 188 +- .../azure/mgmt/oep/operations/_operations.py | 139 +- .../azure/mgmt/oep/operations/_patch.py | 20 + ..._services_add_partition_maximum_set_gen.py | 41 + ...ervices_list_partitions_maximum_set_gen.py | 41 + ...rvices_remove_partition_maximum_set_gen.py | 41 + .../locations_check_name_availability.py | 40 + .../generated_samples/oep_resource_create.py | 41 + .../generated_samples/oep_resource_delete.py | 41 + .../generated_samples/oep_resource_get.py | 41 + .../oep_resource_list_by_resource_group.py | 41 + .../oep_resource_list_by_subscription_id.py | 39 + .../generated_samples/oep_resource_update.py | 41 + .../generated_samples/operations_list.py | 38 + sdk/oep/azure-mgmt-oep/setup.py | 18 +- shared_requirements.txt | 4 +- 43 files changed, 5547 insertions(+), 1288 deletions(-) delete mode 100644 sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_metadata.json create mode 100644 sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_serialization.py create mode 100644 sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_patch.py create mode 100644 sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_patch.py create mode 100644 sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_patch.py create mode 100644 sdk/oep/azure-mgmt-oep/generated_samples/energy_services_add_partition_maximum_set_gen.py create mode 100644 sdk/oep/azure-mgmt-oep/generated_samples/energy_services_list_partitions_maximum_set_gen.py create mode 100644 sdk/oep/azure-mgmt-oep/generated_samples/energy_services_remove_partition_maximum_set_gen.py create mode 100644 sdk/oep/azure-mgmt-oep/generated_samples/locations_check_name_availability.py create mode 100644 sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_create.py create mode 100644 sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_delete.py create mode 100644 sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_get.py create mode 100644 sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_list_by_resource_group.py create mode 100644 sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_list_by_subscription_id.py create mode 100644 sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_update.py create mode 100644 sdk/oep/azure-mgmt-oep/generated_samples/operations_list.py diff --git a/sdk/oep/azure-mgmt-oep/CHANGELOG.md b/sdk/oep/azure-mgmt-oep/CHANGELOG.md index 2819511708c9..edeb313e5fb9 100644 --- a/sdk/oep/azure-mgmt-oep/CHANGELOG.md +++ b/sdk/oep/azure-mgmt-oep/CHANGELOG.md @@ -1,5 +1,13 @@ # Release History +## 1.0.0b2 (2022-11-15) + +### Features Added + + - Added operation EnergyServicesOperations.begin_add_partition + - Added operation EnergyServicesOperations.begin_remove_partition + - Added operation EnergyServicesOperations.list_partitions + ## 1.0.0b1 (2022-02-15) * Initial Release diff --git a/sdk/oep/azure-mgmt-oep/MANIFEST.in b/sdk/oep/azure-mgmt-oep/MANIFEST.in index 2c31e8da0cb1..2b8d32bd3739 100644 --- a/sdk/oep/azure-mgmt-oep/MANIFEST.in +++ b/sdk/oep/azure-mgmt-oep/MANIFEST.in @@ -1,6 +1,8 @@ include _meta.json -recursive-include tests *.py *.yaml +recursive-include tests *.py *.json +recursive-include samples *.py *.md include *.md include azure/__init__.py include azure/mgmt/__init__.py include LICENSE +include azure/mgmt/oep/py.typed diff --git a/sdk/oep/azure-mgmt-oep/README.md b/sdk/oep/azure-mgmt-oep/README.md index 2f442b517240..f6fe675aa592 100644 --- a/sdk/oep/azure-mgmt-oep/README.md +++ b/sdk/oep/azure-mgmt-oep/README.md @@ -12,8 +12,6 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) - - For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) Code samples for this package can be found at [Oep Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. diff --git a/sdk/oep/azure-mgmt-oep/_meta.json b/sdk/oep/azure-mgmt-oep/_meta.json index 402d0531e813..d51c7c1e66e6 100644 --- a/sdk/oep/azure-mgmt-oep/_meta.json +++ b/sdk/oep/azure-mgmt-oep/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "commit": "83d42b77e751deafcf46784877922ec1538f41c6", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.12.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.2.1", + "@autorest/modelerfour@4.24.3" ], - "commit": "8ccb47875370596cf1992aa2a8997b8ce3861486", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/oep/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/oep/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.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/oep/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/__init__.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/__init__.py index 098a1631c9f6..7ee9f7979846 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/__init__.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['OpenEnergyPlatformManagementServiceAPIs'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "OpenEnergyPlatformManagementServiceAPIs", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_configuration.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_configuration.py index ce8c74440bf8..cfcfe87622ec 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_configuration.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,30 +15,37 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential -class OpenEnergyPlatformManagementServiceAPIsConfiguration(Configuration): +class OpenEnergyPlatformManagementServiceAPIsConfiguration( + Configuration +): # pylint: disable=too-many-instance-attributes """Configuration for OpenEnergyPlatformManagementServiceAPIs. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-04-04-preview". 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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(OpenEnergyPlatformManagementServiceAPIsConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-04-04-preview") # type: Literal["2022-04-04-preview"] + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +53,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-06-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-oep/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-oep/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_metadata.json b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_metadata.json deleted file mode 100644 index 6775573f4e36..000000000000 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_metadata.json +++ /dev/null @@ -1,104 +0,0 @@ -{ - "chosen_version": "2021-06-01-preview", - "total_api_version_list": ["2021-06-01-preview"], - "client": { - "name": "OpenEnergyPlatformManagementServiceAPIs", - "filename": "_open_energy_platform_management_service_apis", - "description": "Open Energy Platform Management Service APIs.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"OpenEnergyPlatformManagementServiceAPIsConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"OpenEnergyPlatformManagementServiceAPIsConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "locations": "LocationsOperations", - "energy_services": "EnergyServicesOperations", - "operations": "Operations" - } -} \ No newline at end of file diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_open_energy_platform_management_service_apis.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_open_energy_platform_management_service_apis.py index 4c8e5b117f38..7851e47b5334 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_open_energy_platform_management_service_apis.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_open_energy_platform_management_service_apis.py @@ -7,36 +7,39 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import OpenEnergyPlatformManagementServiceAPIsConfiguration +from ._serialization import Deserializer, Serializer from .operations import EnergyServicesOperations, LocationsOperations, Operations if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class OpenEnergyPlatformManagementServiceAPIs: + +class OpenEnergyPlatformManagementServiceAPIs: # pylint: disable=client-accepts-api-version-keyword """Open Energy Platform Management Service APIs. :ivar locations: LocationsOperations operations - :vartype locations: open_energy_platform_management_service_apis.operations.LocationsOperations + :vartype locations: azure.mgmt.oep.operations.LocationsOperations :ivar energy_services: EnergyServicesOperations operations - :vartype energy_services: - open_energy_platform_management_service_apis.operations.EnergyServicesOperations + :vartype energy_services: azure.mgmt.oep.operations.EnergyServicesOperations :ivar operations: Operations operations - :vartype operations: open_energy_platform_management_service_apis.operations.Operations - :param credential: Credential needed for the client to connect to Azure. + :vartype operations: azure.mgmt.oep.operations.Operations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-04-04-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -48,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = OpenEnergyPlatformManagementServiceAPIsConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = OpenEnergyPlatformManagementServiceAPIsConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -59,12 +64,7 @@ def __init__( self.energy_services = EnergyServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -73,7 +73,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_patch.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_patch.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_serialization.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_serialization.py new file mode 100644 index 000000000000..7c1dedb5133d --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # 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 + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # 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("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + 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) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **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) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + 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: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, 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:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_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:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + 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=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + 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"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_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) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + 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: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + 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) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + 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) + else: + return date_obj diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_vendor.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_vendor.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_version.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_version.py index e5754a47ce68..dfa6ee022f15 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_version.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b1" +VERSION = "1.0.0b2" diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/__init__.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/__init__.py index 3d6a9dfabc7a..f97aebae6461 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/__init__.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._open_energy_platform_management_service_apis import OpenEnergyPlatformManagementServiceAPIs -__all__ = ['OpenEnergyPlatformManagementServiceAPIs'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "OpenEnergyPlatformManagementServiceAPIs", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_configuration.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_configuration.py index c99587b55796..0d3360ff5e4a 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_configuration.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,30 +15,37 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential -class OpenEnergyPlatformManagementServiceAPIsConfiguration(Configuration): +class OpenEnergyPlatformManagementServiceAPIsConfiguration( + Configuration +): # pylint: disable=too-many-instance-attributes """Configuration for OpenEnergyPlatformManagementServiceAPIs. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-04-04-preview". 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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(OpenEnergyPlatformManagementServiceAPIsConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-04-04-preview") # type: Literal["2022-04-04-preview"] + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +53,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2021-06-01-preview" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-oep/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-oep/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_open_energy_platform_management_service_apis.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_open_energy_platform_management_service_apis.py index 73ce151d89aa..fee5c279e002 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_open_energy_platform_management_service_apis.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_open_energy_platform_management_service_apis.py @@ -7,13 +7,13 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from .._serialization import Deserializer, Serializer from ._configuration import OpenEnergyPlatformManagementServiceAPIsConfiguration from .operations import EnergyServicesOperations, LocationsOperations, Operations @@ -21,23 +21,25 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class OpenEnergyPlatformManagementServiceAPIs: + +class OpenEnergyPlatformManagementServiceAPIs: # pylint: disable=client-accepts-api-version-keyword """Open Energy Platform Management Service APIs. :ivar locations: LocationsOperations operations - :vartype locations: - open_energy_platform_management_service_apis.aio.operations.LocationsOperations + :vartype locations: azure.mgmt.oep.aio.operations.LocationsOperations :ivar energy_services: EnergyServicesOperations operations - :vartype energy_services: - open_energy_platform_management_service_apis.aio.operations.EnergyServicesOperations + :vartype energy_services: azure.mgmt.oep.aio.operations.EnergyServicesOperations :ivar operations: Operations operations - :vartype operations: open_energy_platform_management_service_apis.aio.operations.Operations - :param credential: Credential needed for the client to connect to Azure. + :vartype operations: azure.mgmt.oep.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-04-04-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -49,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = OpenEnergyPlatformManagementServiceAPIsConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = OpenEnergyPlatformManagementServiceAPIsConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -60,12 +64,7 @@ def __init__( self.energy_services = EnergyServicesOperations(self._client, self._config, self._serialize, self._deserialize) self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -74,7 +73,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_patch.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_patch.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/__init__.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/__init__.py index f24d9bd0a18c..80310be6ce59 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/__init__.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/__init__.py @@ -10,8 +10,14 @@ from ._energy_services_operations import EnergyServicesOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'LocationsOperations', - 'EnergyServicesOperations', - 'Operations', + "LocationsOperations", + "EnergyServicesOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_energy_services_operations.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_energy_services_operations.py index 14b01b4be755..0490ccf4fec5 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_energy_services_operations.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_energy_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,90 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._energy_services_operations import build_create_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request -T = TypeVar('T') +from ...operations._energy_services_operations import ( + build_add_partition_request, + build_create_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_partitions_request, + build_remove_partition_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class EnergyServicesOperations: - """EnergyServicesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class EnergyServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~open_energy_platform_management_service_apis.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.oep.aio.OpenEnergyPlatformManagementServiceAPIs`'s + :attr:`energy_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.EnergyServiceList"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> AsyncIterable["_models.EnergyService"]: """Returns list of oep resources.. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 EnergyServiceList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~open_energy_platform_management_service_apis.models.EnergyServiceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EnergyService or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.oep.models.EnergyService] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyServiceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyServiceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -102,57 +140,75 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.EnergyServiceList"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.EnergyService"]: """Lists a collection of oep resources under the given Azure Subscription ID. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EnergyServiceList or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~open_energy_platform_management_service_apis.models.EnergyServiceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EnergyService or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.oep.models.EnergyService] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyServiceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyServiceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -166,140 +222,246 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/energyServices'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/energyServices"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.EnergyService": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.EnergyService: """Returns oep resource for a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The resource name. + :param resource_name: The resource name. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EnergyService, or the result of cls(response) - :rtype: ~open_energy_platform_management_service_apis.models.EnergyService - :raises: ~azure.core.exceptions.HttpResponseError + :return: EnergyService or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.EnergyService + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyService] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EnergyService', pipeline_response) + deserialized = self._deserialize("EnergyService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore async def _create_initial( self, resource_group_name: str, resource_name: str, - body: Optional["_models.EnergyService"] = None, + body: Optional[Union[_models.EnergyService, IO]] = None, **kwargs: Any - ) -> "_models.EnergyService": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyService"] + ) -> _models.EnergyService: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyService] - if body is not None: - _json = self._serialize.body(body, 'EnergyService') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "EnergyService") + else: + _json = None - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EnergyService', pipeline_response) + deserialized = self._deserialize("EnergyService", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EnergyService', pipeline_response) + deserialized = self._deserialize("EnergyService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + resource_name: str, + body: Optional[_models.EnergyService] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EnergyService]: + """Method that gets called if subscribed for ResourceCreationBegin trigger. + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: Request body. Default value is None. + :type body: ~azure.mgmt.oep.models.EnergyService + :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 EnergyService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.oep.models.EnergyService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + resource_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.EnergyService]: + """Method that gets called if subscribed for ResourceCreationBegin trigger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: Request body. Default value is None. + :type body: IO + :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 EnergyService or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.oep.models.EnergyService] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( self, resource_group_name: str, resource_name: str, - body: Optional["_models.EnergyService"] = None, + body: Optional[Union[_models.EnergyService, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller["_models.EnergyService"]: + ) -> AsyncLROPoller[_models.EnergyService]: """Method that gets called if subscribed for ResourceCreationBegin trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The resource name. + :param resource_name: The resource name. Required. :type resource_name: str - :param body: Request body. - :type body: ~open_energy_platform_management_service_apis.models.EnergyService + :param body: Request body. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.oep.models.EnergyService 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 @@ -310,162 +472,476 @@ async def begin_create( Retry-After header is present. :return: An instance of AsyncLROPoller that returns either EnergyService or the result of cls(response) - :rtype: - ~azure.core.polling.AsyncLROPoller[~open_energy_platform_management_service_apis.models.EnergyService] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.oep.models.EnergyService] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyService"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyService] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_initial( + raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, body=body, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EnergyService', pipeline_response) + deserialized = self._deserialize("EnergyService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + body: Optional[_models.EnergyResourceUpdate] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EnergyService: + """update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.oep.models.EnergyResourceUpdate + :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: EnergyService or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.EnergyService + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + resource_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EnergyService: + """update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: Default value is None. + :type body: IO + :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: EnergyService or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.EnergyService + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, resource_name: str, - body: Optional["_models.EnergyResourceUpdate"] = None, + body: Optional[Union[_models.EnergyResourceUpdate, IO]] = None, **kwargs: Any - ) -> "_models.EnergyService": + ) -> _models.EnergyService: """update. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The resource name. + :param resource_name: The resource name. Required. :type resource_name: str - :param body: - :type body: ~open_energy_platform_management_service_apis.models.EnergyResourceUpdate + :param body: Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.oep.models.EnergyResourceUpdate 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 - :return: EnergyService, or the result of cls(response) - :rtype: ~open_energy_platform_management_service_apis.models.EnergyService - :raises: ~azure.core.exceptions.HttpResponseError + :return: EnergyService or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.EnergyService + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'EnergyResourceUpdate') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyService] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "EnergyResourceUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EnergyService', pipeline_response) + deserialized = self._deserialize("EnergyService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore + + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> None: + error_map = { + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + 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) + if cls: + return cls(pipeline_response, None, {}) - async def _delete_initial( + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore + + @distributed_trace_async + async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: + """Deletes oep resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore + + async def _add_partition_initial( self, resource_group_name: str, resource_name: str, + body: Optional[Union[_models.DataPartitionAddOrRemoveRequest, IO]] = None, **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] + ) -> _models.DataPartitionAddOrRemoveRequest: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPartitionAddOrRemoveRequest] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "DataPartitionAddOrRemoveRequest") + else: + _json = None - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_add_partition_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._add_partition_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataPartitionAddOrRemoveRequest", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore + return deserialized + _add_partition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/addPartition"} # type: ignore + + @overload + async def begin_add_partition( + self, + resource_group_name: str, + resource_name: str, + body: Optional[_models.DataPartitionAddOrRemoveRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be added in a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: add partition action payload. Default value is None. + :type body: ~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest + :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 DataPartitionAddOrRemoveRequest or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_add_partition( + self, + resource_group_name: str, + resource_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be added in a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: add partition action payload. Default value is None. + :type body: IO + :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 DataPartitionAddOrRemoveRequest or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def begin_delete( + async def begin_add_partition( self, resource_group_name: str, resource_name: str, + body: Optional[Union[_models.DataPartitionAddOrRemoveRequest, IO]] = None, **kwargs: Any - ) -> AsyncLROPoller[None]: - """Deletes oep resource. + ) -> AsyncLROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be added in a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The resource name. + :param resource_name: The resource name. Required. :type resource_name: str + :param body: add partition action payload. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest 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 @@ -474,42 +950,347 @@ async def begin_delete( :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 + :return: An instance of AsyncLROPoller that returns either DataPartitionAddOrRemoveRequest or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPartitionAddOrRemoveRequest] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._add_partition_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DataPartitionAddOrRemoveRequest", pipeline_response) if cls: - return cls(pipeline_response, None, {}) - + return cls(pipeline_response, deserialized, {}) + return deserialized - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_add_partition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/addPartition"} # type: ignore + + async def _remove_partition_initial( + self, + resource_group_name: str, + resource_name: str, + body: Optional[Union[_models.DataPartitionAddOrRemoveRequest, IO]] = None, + **kwargs: Any + ) -> _models.DataPartitionAddOrRemoveRequest: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPartitionAddOrRemoveRequest] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + if body is not None: + _json = self._serialize.body(body, "DataPartitionAddOrRemoveRequest") + else: + _json = None + + request = build_remove_partition_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._remove_partition_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + 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) + + deserialized = self._deserialize("DataPartitionAddOrRemoveRequest", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _remove_partition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/removePartition"} # type: ignore + + @overload + async def begin_remove_partition( + self, + resource_group_name: str, + resource_name: str, + body: Optional[_models.DataPartitionAddOrRemoveRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be removed from a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: remove partition action payload. Default value is None. + :type body: ~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest + :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 DataPartitionAddOrRemoveRequest or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_remove_partition( + self, + resource_group_name: str, + resource_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be removed from a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: remove partition action payload. Default value is None. + :type body: IO + :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 DataPartitionAddOrRemoveRequest or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_remove_partition( + self, + resource_group_name: str, + resource_name: str, + body: Optional[Union[_models.DataPartitionAddOrRemoveRequest, IO]] = None, + **kwargs: Any + ) -> AsyncLROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be removed from a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: remove partition action payload. Is either a model type or a IO type. Default + value is None. + :type body: ~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest 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. + :return: An instance of AsyncLROPoller that returns either DataPartitionAddOrRemoveRequest or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPartitionAddOrRemoveRequest] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._remove_partition_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DataPartitionAddOrRemoveRequest", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_remove_partition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/removePartition"} # type: ignore + + @distributed_trace_async + async def list_partitions( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.DataPartitionsListResult: + """Method that gets called when list of partitions is requested. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataPartitionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.DataPartitionsListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPartitionsListResult] + + request = build_list_partitions_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_partitions.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataPartitionsListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore + list_partitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/listPartitions"} # type: ignore diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_locations_operations.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_locations_operations.py index 1cbaf0081851..0d69e357e4e6 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_locations_operations.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_locations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,80 +6,138 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._locations_operations import build_check_name_availability_request -T = TypeVar('T') + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class LocationsOperations: - """LocationsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class LocationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~open_energy_platform_management_service_apis.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.oep.aio.OpenEnergyPlatformManagementServiceAPIs`'s + :attr:`locations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def check_name_availability( + self, body: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the name availability of the resource with requested resource name. + + :param body: NameAvailabilityRequest object. Required. + :type body: ~azure.mgmt.oep.models.CheckNameAvailabilityRequest + :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: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, body: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the name availability of the resource with requested resource name. + + :param body: NameAvailabilityRequest object. Required. + :type body: IO + :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: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def check_name_availability( - self, - body: "_models.CheckNameAvailabilityRequest", - **kwargs: Any - ) -> "_models.CheckNameAvailabilityResponse": + self, body: Union[_models.CheckNameAvailabilityRequest, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: """Checks the name availability of the resource with requested resource name. - :param body: NameAvailabilityRequest object. - :type body: ~open_energy_platform_management_service_apis.models.CheckNameAvailabilityRequest + :param body: NameAvailabilityRequest object. Is either a model type or a IO type. Required. + :type body: ~azure.mgmt.oep.models.CheckNameAvailabilityRequest 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 - :return: CheckNameAvailabilityResponse, or the result of cls(response) - :rtype: ~open_energy_platform_management_service_apis.models.CheckNameAvailabilityResponse - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResponse] - _json = self._serialize.body(body, 'CheckNameAvailabilityRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "CheckNameAvailabilityRequest") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -86,12 +145,11 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResponse', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/checkNameAvailability"} # type: ignore diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_operations.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_operations.py index 85ebc82ee0d4..5216deb52335 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_operations.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,71 +6,93 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~open_energy_platform_management_service_apis.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.oep.aio.OpenEnergyPlatformManagementServiceAPIs`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def list( - self, - **kwargs: Any - ) -> "_models.OperationListResult": + async def list(self, **kwargs: Any) -> _models.OperationListResult: """Lists the available operations of Microsoft.OpenEnergyPlatform resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult, or the result of cls(response) - :rtype: ~open_energy_platform_management_service_apis.models.OperationListResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.OperationListResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -77,12 +100,11 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/providers/Microsoft.OpenEnergyPlatform/operations'} # type: ignore - + list.metadata = {"url": "/providers/Microsoft.OpenEnergyPlatform/operations"} # type: ignore diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_patch.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/__init__.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/__init__.py index 6051a2192c20..8989ecf9021a 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/__init__.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/__init__.py @@ -8,7 +8,11 @@ from ._models_py3 import CheckNameAvailabilityRequest from ._models_py3 import CheckNameAvailabilityResponse +from ._models_py3 import DataPartitionAddOrRemoveRequest from ._models_py3 import DataPartitionNames +from ._models_py3 import DataPartitionProperties +from ._models_py3 import DataPartitionsList +from ._models_py3 import DataPartitionsListResult from ._models_py3 import EnergyResourceUpdate from ._models_py3 import EnergyService from ._models_py3 import EnergyServiceList @@ -22,34 +26,40 @@ from ._models_py3 import Resource from ._models_py3 import SystemData - -from ._open_energy_platform_management_service_apis_enums import ( - ActionType, - CheckNameAvailabilityReason, - CreatedByType, - Origin, - ProvisioningState, -) +from ._open_energy_platform_management_service_apis_enums import ActionType +from ._open_energy_platform_management_service_apis_enums import CheckNameAvailabilityReason +from ._open_energy_platform_management_service_apis_enums import CreatedByType +from ._open_energy_platform_management_service_apis_enums import Origin +from ._open_energy_platform_management_service_apis_enums import ProvisioningState +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'CheckNameAvailabilityRequest', - 'CheckNameAvailabilityResponse', - 'DataPartitionNames', - 'EnergyResourceUpdate', - 'EnergyService', - 'EnergyServiceList', - 'EnergyServiceProperties', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Resource', - 'SystemData', - 'ActionType', - 'CheckNameAvailabilityReason', - 'CreatedByType', - 'Origin', - 'ProvisioningState', + "CheckNameAvailabilityRequest", + "CheckNameAvailabilityResponse", + "DataPartitionAddOrRemoveRequest", + "DataPartitionNames", + "DataPartitionProperties", + "DataPartitionsList", + "DataPartitionsListResult", + "EnergyResourceUpdate", + "EnergyService", + "EnergyServiceList", + "EnergyServiceProperties", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "Operation", + "OperationDisplay", + "OperationListResult", + "Resource", + "SystemData", + "ActionType", + "CheckNameAvailabilityReason", + "CreatedByType", + "Origin", + "ProvisioningState", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_models_py3.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_models_py3.py index 018e549a1e45..bb43c1ca3136 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_models_py3.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization -from ._open_energy_platform_management_service_apis_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class CheckNameAvailabilityRequest(msrest.serialization.Model): +class CheckNameAvailabilityRequest(_serialization.Model): """The check availability request body. :ivar name: The name of the resource for which availability needs to be checked. @@ -25,72 +27,84 @@ class CheckNameAvailabilityRequest(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - type: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, type: Optional[str] = None, **kwargs): """ :keyword name: The name of the resource for which availability needs to be checked. :paramtype name: str :keyword type: The resource type. :paramtype type: str """ - super(CheckNameAvailabilityRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class CheckNameAvailabilityResponse(msrest.serialization.Model): +class CheckNameAvailabilityResponse(_serialization.Model): """The check availability result. :ivar name_available: Indicates if the resource name is available. :vartype name_available: bool - :ivar reason: The reason why the given name is not available. Possible values include: - "Invalid", "AlreadyExists". - :vartype reason: str or - ~open_energy_platform_management_service_apis.models.CheckNameAvailabilityReason + :ivar reason: The reason why the given name is not available. Known values are: "Invalid" and + "AlreadyExists". + :vartype reason: str or ~azure.mgmt.oep.models.CheckNameAvailabilityReason :ivar message: Detailed reason why the given name is available. :vartype message: str """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( self, *, name_available: Optional[bool] = None, - reason: Optional[Union[str, "CheckNameAvailabilityReason"]] = None, + reason: Optional[Union[str, "_models.CheckNameAvailabilityReason"]] = None, message: Optional[str] = None, **kwargs ): """ :keyword name_available: Indicates if the resource name is available. :paramtype name_available: bool - :keyword reason: The reason why the given name is not available. Possible values include: - "Invalid", "AlreadyExists". - :paramtype reason: str or - ~open_energy_platform_management_service_apis.models.CheckNameAvailabilityReason + :keyword reason: The reason why the given name is not available. Known values are: "Invalid" + and "AlreadyExists". + :paramtype reason: str or ~azure.mgmt.oep.models.CheckNameAvailabilityReason :keyword message: Detailed reason why the given name is available. :paramtype message: str """ - super(CheckNameAvailabilityResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class DataPartitionNames(msrest.serialization.Model): +class DataPartitionAddOrRemoveRequest(_serialization.Model): + """Defines the partition add/ delete action properties. + + :ivar name: The list of Energy services resource's Data Partition Names. + :vartype name: ~azure.mgmt.oep.models.DataPartitionNames + """ + + _attribute_map = { + "name": {"key": "name", "type": "DataPartitionNames"}, + } + + def __init__(self, *, name: Optional["_models.DataPartitionNames"] = None, **kwargs): + """ + :keyword name: The list of Energy services resource's Data Partition Names. + :paramtype name: ~azure.mgmt.oep.models.DataPartitionNames + """ + super().__init__(**kwargs) + self.name = name + + +class DataPartitionNames(_serialization.Model): """The list of Energy services resource's Data Partition Names. :ivar name: @@ -98,49 +112,107 @@ class DataPartitionNames(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, **kwargs): """ :keyword name: :paramtype name: str """ - super(DataPartitionNames, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class EnergyResourceUpdate(msrest.serialization.Model): +class DataPartitionProperties(_serialization.Model): + """Defines the properties of an individual data partition. + + :ivar name: Name of the data partition. + :vartype name: str + :ivar provisioning_state: Name of the data partition. + :vartype provisioning_state: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, provisioning_state: Optional[str] = None, **kwargs): + """ + :keyword name: Name of the data partition. + :paramtype name: str + :keyword provisioning_state: Name of the data partition. + :paramtype provisioning_state: str + """ + super().__init__(**kwargs) + self.name = name + self.provisioning_state = provisioning_state + + +class DataPartitionsList(_serialization.Model): + """List of data partitions. + + :ivar data_partition_names: + :vartype data_partition_names: list[~azure.mgmt.oep.models.DataPartitionNames] + """ + + _attribute_map = { + "data_partition_names": {"key": "dataPartitionNames", "type": "[DataPartitionNames]"}, + } + + def __init__(self, *, data_partition_names: Optional[List["_models.DataPartitionNames"]] = None, **kwargs): + """ + :keyword data_partition_names: + :paramtype data_partition_names: list[~azure.mgmt.oep.models.DataPartitionNames] + """ + super().__init__(**kwargs) + self.data_partition_names = data_partition_names + + +class DataPartitionsListResult(_serialization.Model): + """List of data partitions. + + :ivar data_partition_info: List of data partitions along with their properties in a given OEP + resource. + :vartype data_partition_info: list[~azure.mgmt.oep.models.DataPartitionProperties] + """ + + _attribute_map = { + "data_partition_info": {"key": "dataPartitionInfo", "type": "[DataPartitionProperties]"}, + } + + def __init__(self, *, data_partition_info: Optional[List["_models.DataPartitionProperties"]] = None, **kwargs): + """ + :keyword data_partition_info: List of data partitions along with their properties in a given + OEP resource. + :paramtype data_partition_info: list[~azure.mgmt.oep.models.DataPartitionProperties] + """ + super().__init__(**kwargs) + self.data_partition_info = data_partition_info + + +class EnergyResourceUpdate(_serialization.Model): """The resource model definition used for updating a tracked ARM resource. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(EnergyResourceUpdate, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags -class Resource(msrest.serialization.Model): +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. @@ -155,30 +227,26 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~open_energy_platform_management_service_apis.models.SystemData + :vartype system_data: ~azure.mgmt.oep.models.SystemData """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, + "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'}, + "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 - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -202,141 +270,132 @@ class EnergyService(Resource): :vartype type: str :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. - :vartype system_data: ~open_energy_platform_management_service_apis.models.SystemData + :vartype system_data: ~azure.mgmt.oep.models.SystemData :ivar properties: - :vartype properties: - ~open_energy_platform_management_service_apis.models.EnergyServiceProperties - :ivar tags: A set of tags. Resource tags. + :vartype properties: ~azure.mgmt.oep.models.EnergyServiceProperties + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. Geo-location where the resource lives. + :ivar location: Geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "location": {"required": 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': 'EnergyServiceProperties'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "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": "EnergyServiceProperties"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } def __init__( self, *, location: str, - properties: Optional["EnergyServiceProperties"] = None, + properties: Optional["_models.EnergyServiceProperties"] = None, tags: Optional[Dict[str, str]] = None, **kwargs ): """ :keyword properties: - :paramtype properties: - ~open_energy_platform_management_service_apis.models.EnergyServiceProperties - :keyword tags: A set of tags. Resource tags. + :paramtype properties: ~azure.mgmt.oep.models.EnergyServiceProperties + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. Geo-location where the resource lives. + :keyword location: Geo-location where the resource lives. Required. :paramtype location: str """ - super(EnergyService, self).__init__(**kwargs) + super().__init__(**kwargs) self.properties = properties self.tags = tags self.location = location -class EnergyServiceList(msrest.serialization.Model): +class EnergyServiceList(_serialization.Model): """The list of oep resources. :ivar next_link: The link used to get the next page of oep resources list. :vartype next_link: str :ivar value: The list of oep resources. - :vartype value: list[~open_energy_platform_management_service_apis.models.EnergyService] + :vartype value: list[~azure.mgmt.oep.models.EnergyService] """ _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[EnergyService]'}, + "next_link": {"key": "nextLink", "type": "str"}, + "value": {"key": "value", "type": "[EnergyService]"}, } def __init__( - self, - *, - next_link: Optional[str] = None, - value: Optional[List["EnergyService"]] = None, - **kwargs + self, *, next_link: Optional[str] = None, value: Optional[List["_models.EnergyService"]] = None, **kwargs ): """ :keyword next_link: The link used to get the next page of oep resources list. :paramtype next_link: str :keyword value: The list of oep resources. - :paramtype value: list[~open_energy_platform_management_service_apis.models.EnergyService] + :paramtype value: list[~azure.mgmt.oep.models.EnergyService] """ - super(EnergyServiceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.next_link = next_link self.value = value -class EnergyServiceProperties(msrest.serialization.Model): +class EnergyServiceProperties(_serialization.Model): """EnergyServiceProperties. Variables are only populated by the server, and will be ignored when sending a request. :ivar dns_name: :vartype dns_name: str - :ivar provisioning_state: Possible values include: "Unknown", "Succeeded", "Failed", - "Canceled", "Creating", "Deleting", "Updating". - :vartype provisioning_state: str or - ~open_energy_platform_management_service_apis.models.ProvisioningState + :ivar provisioning_state: Known values are: "Unknown", "Succeeded", "Failed", "Canceled", + "Creating", "Deleting", and "Updating". + :vartype provisioning_state: str or ~azure.mgmt.oep.models.ProvisioningState :ivar auth_app_id: :vartype auth_app_id: str :ivar data_partition_names: - :vartype data_partition_names: - list[~open_energy_platform_management_service_apis.models.DataPartitionNames] + :vartype data_partition_names: list[~azure.mgmt.oep.models.DataPartitionNames] """ _validation = { - 'dns_name': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "dns_name": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'dns_name': {'key': 'dnsName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'auth_app_id': {'key': 'authAppId', 'type': 'str'}, - 'data_partition_names': {'key': 'dataPartitionNames', 'type': '[DataPartitionNames]'}, + "dns_name": {"key": "dnsName", "type": "str"}, + "provisioning_state": {"key": "provisioningState", "type": "str"}, + "auth_app_id": {"key": "authAppId", "type": "str"}, + "data_partition_names": {"key": "dataPartitionNames", "type": "[DataPartitionNames]"}, } def __init__( self, *, auth_app_id: Optional[str] = None, - data_partition_names: Optional[List["DataPartitionNames"]] = None, + data_partition_names: Optional[List["_models.DataPartitionNames"]] = None, **kwargs ): """ :keyword auth_app_id: :paramtype auth_app_id: str :keyword data_partition_names: - :paramtype data_partition_names: - list[~open_energy_platform_management_service_apis.models.DataPartitionNames] + :paramtype data_partition_names: list[~azure.mgmt.oep.models.DataPartitionNames] """ - super(EnergyServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.dns_name = None self.provisioning_state = None self.auth_app_id = auth_app_id self.data_partition_names = data_partition_names -class ErrorAdditionalInfo(msrest.serialization.Model): +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. @@ -344,31 +403,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -380,35 +435,30 @@ class ErrorDetail(msrest.serialization.Model): :ivar target: The error target. :vartype target: str :ivar details: The error details. - :vartype details: list[~open_energy_platform_management_service_apis.models.ErrorDetail] + :vartype details: list[~azure.mgmt.oep.models.ErrorDetail] :ivar additional_info: The error additional info. - :vartype additional_info: - list[~open_energy_platform_management_service_apis.models.ErrorAdditionalInfo] + :vartype additional_info: list[~azure.mgmt.oep.models.ErrorAdditionalInfo] """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "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]'}, + "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 - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -416,32 +466,27 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +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: ~open_energy_platform_management_service_apis.models.ErrorDetail + :vartype error: ~azure.mgmt.oep.models.ErrorDetail """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. - :paramtype error: ~open_energy_platform_management_service_apis.models.ErrorDetail + :paramtype error: ~azure.mgmt.oep.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Details of a REST API operation, returned from the Resource Provider Operations API. Variables are only populated by the server, and will be ignored when sending a request. @@ -453,42 +498,37 @@ class Operation(msrest.serialization.Model): data-plane operations and "false" for ARM/control-plane operations. :vartype is_data_action: bool :ivar display: Localized display information for this particular operation. - :vartype display: ~open_energy_platform_management_service_apis.models.OperationDisplay + :vartype display: ~azure.mgmt.oep.models.OperationDisplay :ivar origin: The intended executor of the operation; as in Resource Based Access Control - (RBAC) and audit logs UX. Default value is "user,system". Possible values include: "user", - "system", "user,system". - :vartype origin: str or ~open_energy_platform_management_service_apis.models.Origin + (RBAC) and audit logs UX. Default value is "user,system". Known values are: "user", "system", + and "user,system". + :vartype origin: str or ~azure.mgmt.oep.models.Origin :ivar action_type: Enum. Indicates the action type. "Internal" refers to actions that are for - internal only APIs. Possible values include: "Internal". - :vartype action_type: str or ~open_energy_platform_management_service_apis.models.ActionType + internal only APIs. "Internal" + :vartype action_type: str or ~azure.mgmt.oep.models.ActionType """ _validation = { - 'name': {'readonly': True}, - 'is_data_action': {'readonly': True}, - 'origin': {'readonly': True}, - 'action_type': {'readonly': True}, + "name": {"readonly": True}, + "is_data_action": {"readonly": True}, + "origin": {"readonly": True}, + "action_type": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'action_type': {'key': 'actionType', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "action_type": {"key": "actionType", "type": "str"}, } - def __init__( - self, - *, - display: Optional["OperationDisplay"] = None, - **kwargs - ): + def __init__(self, *, display: Optional["_models.OperationDisplay"] = None, **kwargs): """ :keyword display: Localized display information for this particular operation. - :paramtype display: ~open_energy_platform_management_service_apis.models.OperationDisplay + :paramtype display: ~azure.mgmt.oep.models.OperationDisplay """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = None self.is_data_action = None self.display = display @@ -496,7 +536,7 @@ def __init__( self.action_type = None -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Localized display information for this particular operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -516,124 +556,112 @@ class OperationDisplay(msrest.serialization.Model): """ _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, + "provider": {"readonly": True}, + "resource": {"readonly": True}, + "operation": {"readonly": True}, + "description": {"readonly": True}, } _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationDisplay, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.provider = None self.resource = None self.operation = None self.description = None -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """A list of REST API operations supported by an Azure Resource Provider. It contains an URL link to get the next set of results. Variables are only populated by the server, and will be ignored when sending a request. :ivar value: List of operations supported by the resource provider. - :vartype value: list[~open_energy_platform_management_service_apis.models.Operation] + :vartype value: list[~azure.mgmt.oep.models.Operation] :ivar next_link: URL to get the next set of operation list results (if there are any). :vartype next_link: str """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(OperationListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SystemData(msrest.serialization.Model): +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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". - :vartype created_by_type: str or - ~open_energy_platform_management_service_apis.models.CreatedByType + :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.oep.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :vartype last_modified_by_type: str or - ~open_energy_platform_management_service_apis.models.CreatedByType + :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.oep.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'}, + "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, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :paramtype created_by_type: str or - ~open_energy_platform_management_service_apis.models.CreatedByType + :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.oep.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :paramtype last_modified_by_type: str or - ~open_energy_platform_management_service_apis.models.CreatedByType + :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.oep.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_open_energy_platform_management_service_apis_enums.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_open_energy_platform_management_service_apis_enums.py index cbccc7a40a09..80cf2b914674 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_open_energy_platform_management_service_apis_enums.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_open_energy_platform_management_service_apis_enums.py @@ -7,42 +7,43 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs. - """ +class ActionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum. Indicates the action type. "Internal" refers to actions that are for internal only APIs.""" INTERNAL = "Internal" -class CheckNameAvailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The reason why the given name is not available. - """ + +class CheckNameAvailabilityReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason why the given name is not available.""" INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class Origin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class Origin(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The intended executor of the operation; as in Resource Based Access Control (RBAC) and audit - logs UX. Default value is "user,system" + logs UX. Default value is "user,system". """ USER = "user" SYSTEM = "system" USER_SYSTEM = "user,system" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ProvisioningState.""" UNKNOWN = "Unknown" SUCCEEDED = "Succeeded" diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_patch.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/__init__.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/__init__.py index f24d9bd0a18c..80310be6ce59 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/__init__.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/__init__.py @@ -10,8 +10,14 @@ from ._energy_services_operations import EnergyServicesOperations from ._operations import Operations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'LocationsOperations', - 'EnergyServicesOperations', - 'Operations', + "LocationsOperations", + "EnergyServicesOperations", + "Operations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_energy_services_operations.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_energy_services_operations.py index 264841783361..b5098025b44e 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_energy_services_operations.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_energy_services_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,302 +6,427 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2021-06-01-preview" - accept = "application/json" + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-04-preview") + ) # type: Literal["2022-04-04-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) +def build_list_by_subscription_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-04-preview") + ) # type: Literal["2022-04-04-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/energyServices" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, resource_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-04-preview") + ) # type: Literal["2022-04-04-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_create_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-04-preview") + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/energyServices') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01-preview" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-04-preview") + ) # type: Literal["2022-04-04-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_add_partition_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-04-preview") + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/addPartition", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any +def build_remove_partition_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-04-preview") + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2021-06-01-preview" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/removePartition", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_partitions_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2021-06-01-preview" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-04-preview") + ) # type: Literal["2022-04-04-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/listPartitions", + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1 + ), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - **kwargs - ) - -class EnergyServicesOperations(object): - """EnergyServicesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~open_energy_platform_management_service_apis.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _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 EnergyServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.oep.OpenEnergyPlatformManagementServiceAPIs`'s + :attr:`energy_services` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.EnergyServiceList"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.EnergyService"]: """Returns list of oep resources.. :param resource_group_name: The name of the resource group. The name is case insensitive. + 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 EnergyServiceList or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~open_energy_platform_management_service_apis.models.EnergyServiceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EnergyService or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.oep.models.EnergyService] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyServiceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyServiceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -314,57 +440,75 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.EnergyServiceList"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.EnergyService"]: """Lists a collection of oep resources under the given Azure Subscription ID. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EnergyServiceList or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~open_energy_platform_management_service_apis.models.EnergyServiceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EnergyService or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.oep.models.EnergyService] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyServiceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyServiceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -378,140 +522,246 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/energyServices'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/energyServices"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.EnergyService": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.EnergyService: """Returns oep resource for a given name. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The resource name. + :param resource_name: The resource name. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EnergyService, or the result of cls(response) - :rtype: ~open_energy_platform_management_service_apis.models.EnergyService - :raises: ~azure.core.exceptions.HttpResponseError + :return: EnergyService or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.EnergyService + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyService] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EnergyService', pipeline_response) + deserialized = self._deserialize("EnergyService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore def _create_initial( self, resource_group_name: str, resource_name: str, - body: Optional["_models.EnergyService"] = None, + body: Optional[Union[_models.EnergyService, IO]] = None, **kwargs: Any - ) -> "_models.EnergyService": - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyService"] + ) -> _models.EnergyService: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - if body is not None: - _json = self._serialize.body(body, 'EnergyService') + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyService] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "EnergyService") + else: + _json = None - request = build_create_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EnergyService', pipeline_response) + deserialized = self._deserialize("EnergyService", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EnergyService', pipeline_response) + deserialized = self._deserialize("EnergyService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + resource_name: str, + body: Optional[_models.EnergyService] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EnergyService]: + """Method that gets called if subscribed for ResourceCreationBegin trigger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: Request body. Default value is None. + :type body: ~azure.mgmt.oep.models.EnergyService + :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 EnergyService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.oep.models.EnergyService] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + resource_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.EnergyService]: + """Method that gets called if subscribed for ResourceCreationBegin trigger. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: Request body. Default value is None. + :type body: IO + :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 EnergyService or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.oep.models.EnergyService] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( self, resource_group_name: str, resource_name: str, - body: Optional["_models.EnergyService"] = None, + body: Optional[Union[_models.EnergyService, IO]] = None, **kwargs: Any - ) -> LROPoller["_models.EnergyService"]: + ) -> LROPoller[_models.EnergyService]: """Method that gets called if subscribed for ResourceCreationBegin trigger. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The resource name. + :param resource_name: The resource name. Required. :type resource_name: str - :param body: Request body. - :type body: ~open_energy_platform_management_service_apis.models.EnergyService + :param body: Request body. Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.oep.models.EnergyService 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 @@ -522,162 +772,473 @@ def begin_create( Retry-After header is present. :return: An instance of LROPoller that returns either EnergyService or the result of cls(response) - :rtype: - ~azure.core.polling.LROPoller[~open_energy_platform_management_service_apis.models.EnergyService] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.oep.models.EnergyService] + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyService"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyService] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_initial( + raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, body=body, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('EnergyService', pipeline_response) + deserialized = self._deserialize("EnergyService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + body: Optional[_models.EnergyResourceUpdate] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EnergyService: + """update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: Default value is None. + :type body: ~azure.mgmt.oep.models.EnergyResourceUpdate + :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: EnergyService or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.EnergyService + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + resource_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EnergyService: + """update. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: Default value is None. + :type body: IO + :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: EnergyService or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.EnergyService + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, resource_name: str, - body: Optional["_models.EnergyResourceUpdate"] = None, + body: Optional[Union[_models.EnergyResourceUpdate, IO]] = None, **kwargs: Any - ) -> "_models.EnergyService": + ) -> _models.EnergyService: """update. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The resource name. + :param resource_name: The resource name. Required. :type resource_name: str - :param body: - :type body: ~open_energy_platform_management_service_apis.models.EnergyResourceUpdate + :param body: Is either a model type or a IO type. Default value is None. + :type body: ~azure.mgmt.oep.models.EnergyResourceUpdate 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 - :return: EnergyService, or the result of cls(response) - :rtype: ~open_energy_platform_management_service_apis.models.EnergyService - :raises: ~azure.core.exceptions.HttpResponseError + :return: EnergyService or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.EnergyService + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.EnergyService"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - if body is not None: - _json = self._serialize.body(body, 'EnergyResourceUpdate') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EnergyService] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body else: - _json = None + if body is not None: + _json = self._serialize.body(body, "EnergyResourceUpdate") + else: + _json = None request = build_update_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EnergyService', pipeline_response) + deserialized = self._deserialize("EnergyService", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore + + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> None: + error_map = { + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + resource_name=resource_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + 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) + + if cls: + return cls(pipeline_response, None, {}) + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore - def _delete_initial( + @distributed_trace + def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: + """Deletes oep resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}"} # type: ignore + + def _add_partition_initial( self, resource_group_name: str, resource_name: str, + body: Optional[Union[_models.DataPartitionAddOrRemoveRequest, IO]] = None, **kwargs: Any - ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] + ) -> _models.DataPartitionAddOrRemoveRequest: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPartitionAddOrRemoveRequest] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "DataPartitionAddOrRemoveRequest") + else: + _json = None - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + request = build_add_partition_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._add_partition_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response - if response.status_code not in [200, 202, 204]: + if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataPartitionAddOrRemoveRequest", pipeline_response) if cls: - return cls(pipeline_response, None, {}) + return cls(pipeline_response, deserialized, {}) + + return deserialized - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore + _add_partition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/addPartition"} # type: ignore + @overload + def begin_add_partition( + self, + resource_group_name: str, + resource_name: str, + body: Optional[_models.DataPartitionAddOrRemoveRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be added in a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: add partition action payload. Default value is None. + :type body: ~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest + :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 DataPartitionAddOrRemoveRequest or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_add_partition( + self, + resource_group_name: str, + resource_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be added in a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: add partition action payload. Default value is None. + :type body: IO + :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 DataPartitionAddOrRemoveRequest or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def begin_delete( + def begin_add_partition( self, resource_group_name: str, resource_name: str, + body: Optional[Union[_models.DataPartitionAddOrRemoveRequest, IO]] = None, **kwargs: Any - ) -> LROPoller[None]: - """Deletes oep resource. + ) -> LROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be added in a resource. :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. :type resource_group_name: str - :param resource_name: The resource name. + :param resource_name: The resource name. Required. :type resource_name: str + :param body: add partition action payload. Is either a model type or a IO type. Default value + is None. + :type body: ~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest 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 @@ -686,42 +1247,343 @@ def begin_delete( :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 + :return: An instance of LROPoller that returns either DataPartitionAddOrRemoveRequest or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPartitionAddOrRemoveRequest] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._add_partition_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DataPartitionAddOrRemoveRequest", pipeline_response) if cls: - return cls(pipeline_response, None, {}) - + return cls(pipeline_response, deserialized, {}) + return deserialized - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_add_partition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/addPartition"} # type: ignore + + def _remove_partition_initial( + self, + resource_group_name: str, + resource_name: str, + body: Optional[Union[_models.DataPartitionAddOrRemoveRequest, IO]] = None, + **kwargs: Any + ) -> _models.DataPartitionAddOrRemoveRequest: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPartitionAddOrRemoveRequest] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + if body is not None: + _json = self._serialize.body(body, "DataPartitionAddOrRemoveRequest") + else: + _json = None + + request = build_remove_partition_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._remove_partition_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [202]: + 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) + + deserialized = self._deserialize("DataPartitionAddOrRemoveRequest", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _remove_partition_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/removePartition"} # type: ignore + + @overload + def begin_remove_partition( + self, + resource_group_name: str, + resource_name: str, + body: Optional[_models.DataPartitionAddOrRemoveRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be removed from a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: remove partition action payload. Default value is None. + :type body: ~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest + :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 DataPartitionAddOrRemoveRequest or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_remove_partition( + self, + resource_group_name: str, + resource_name: str, + body: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be removed from a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: remove partition action payload. Default value is None. + :type body: IO + :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 DataPartitionAddOrRemoveRequest or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_remove_partition( + self, + resource_group_name: str, + resource_name: str, + body: Optional[Union[_models.DataPartitionAddOrRemoveRequest, IO]] = None, + **kwargs: Any + ) -> LROPoller[_models.DataPartitionAddOrRemoveRequest]: + """Method that gets called if new partition is to be removed from a resource. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :param body: remove partition action payload. Is either a model type or a IO type. Default + value is None. + :type body: ~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest 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. + :return: An instance of LROPoller that returns either DataPartitionAddOrRemoveRequest or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.oep.models.DataPartitionAddOrRemoveRequest] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPartitionAddOrRemoveRequest] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._remove_partition_initial( # type: ignore + resource_group_name=resource_group_name, + resource_name=resource_name, + body=body, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("DataPartitionAddOrRemoveRequest", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_remove_partition.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/removePartition"} # type: ignore + + @distributed_trace + def list_partitions( + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.DataPartitionsListResult: + """Method that gets called when list of partitions is requested. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + Required. + :type resource_group_name: str + :param resource_name: The resource name. Required. + :type resource_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DataPartitionsListResult or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.DataPartitionsListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DataPartitionsListResult] + + request = build_list_partitions_request( + resource_group_name=resource_group_name, + resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_partitions.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DataPartitionsListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}'} # type: ignore + list_partitions.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.OpenEnergyPlatform/energyServices/{resourceName}/listPartitions"} # type: ignore diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_locations_operations.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_locations_operations.py index 879adfe46118..b403fc7e8e91 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_locations_operations.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_locations_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,117 +6,165 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - accept = "application/json" +def build_check_name_availability_request(subscription_id: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/checkNameAvailability') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/checkNameAvailability" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - -class LocationsOperations(object): - """LocationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~open_energy_platform_management_service_apis.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs) + + +class LocationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.oep.OpenEnergyPlatformManagementServiceAPIs`'s + :attr:`locations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def check_name_availability( + self, body: _models.CheckNameAvailabilityRequest, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the name availability of the resource with requested resource name. + + :param body: NameAvailabilityRequest object. Required. + :type body: ~azure.mgmt.oep.models.CheckNameAvailabilityRequest + :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: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, body: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: + """Checks the name availability of the resource with requested resource name. + + :param body: NameAvailabilityRequest object. Required. + :type body: IO + :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: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def check_name_availability( - self, - body: "_models.CheckNameAvailabilityRequest", - **kwargs: Any - ) -> "_models.CheckNameAvailabilityResponse": + self, body: Union[_models.CheckNameAvailabilityRequest, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResponse: """Checks the name availability of the resource with requested resource name. - :param body: NameAvailabilityRequest object. - :type body: ~open_energy_platform_management_service_apis.models.CheckNameAvailabilityRequest + :param body: NameAvailabilityRequest object. Is either a model type or a IO type. Required. + :type body: ~azure.mgmt.oep.models.CheckNameAvailabilityRequest 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 - :return: CheckNameAvailabilityResponse, or the result of cls(response) - :rtype: ~open_energy_platform_management_service_apis.models.CheckNameAvailabilityResponse - :raises: ~azure.core.exceptions.HttpResponseError + :return: CheckNameAvailabilityResponse or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.CheckNameAvailabilityResponse + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResponse"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResponse] - _json = self._serialize.body(body, 'CheckNameAvailabilityRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(body, (IO, bytes)): + _content = body + else: + _json = self._serialize.body(body, "CheckNameAvailabilityRequest") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -123,12 +172,11 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResponse', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.OpenEnergyPlatform/checkNameAvailability"} # type: ignore diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_operations.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_operations.py index 0b2c4e9e4bb1..e6b19435fde1 100644 --- a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_operations.py +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,98 +6,117 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2021-06-01-preview" - accept = "application/json" + +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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-04-04-preview") + ) # type: Literal["2022-04-04-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.OpenEnergyPlatform/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.OpenEnergyPlatform/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~open_energy_platform_management_service_apis.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.oep.OpenEnergyPlatformManagementServiceAPIs`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> "_models.OperationListResult": + def list(self, **kwargs: Any) -> _models.OperationListResult: """Lists the available operations of Microsoft.OpenEnergyPlatform resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: OperationListResult, or the result of cls(response) - :rtype: ~open_energy_platform_management_service_apis.models.OperationListResult - :raises: ~azure.core.exceptions.HttpResponseError + :return: OperationListResult or the result of cls(response) + :rtype: ~azure.mgmt.oep.models.OperationListResult + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-04-04-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] - request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -104,12 +124,11 @@ def list( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': '/providers/Microsoft.OpenEnergyPlatform/operations'} # type: ignore - + list.metadata = {"url": "/providers/Microsoft.OpenEnergyPlatform/operations"} # type: ignore diff --git a/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_patch.py b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/azure/mgmt/oep/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/oep/azure-mgmt-oep/generated_samples/energy_services_add_partition_maximum_set_gen.py b/sdk/oep/azure-mgmt-oep/generated_samples/energy_services_add_partition_maximum_set_gen.py new file mode 100644 index 000000000000..c2ddfcaf4362 --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/generated_samples/energy_services_add_partition_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.oep import OpenEnergyPlatformManagementServiceAPIs + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-oep +# USAGE + python energy_services_add_partition_maximum_set_gen.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 = OpenEnergyPlatformManagementServiceAPIs( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.energy_services.begin_add_partition( + resource_group_name="rgoep", + resource_name="a", + ).result() + print(response) + + +# x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2022-04-04-preview/examples/EnergyServices_AddPartition_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/oep/azure-mgmt-oep/generated_samples/energy_services_list_partitions_maximum_set_gen.py b/sdk/oep/azure-mgmt-oep/generated_samples/energy_services_list_partitions_maximum_set_gen.py new file mode 100644 index 000000000000..0c52073fdf9c --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/generated_samples/energy_services_list_partitions_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.oep import OpenEnergyPlatformManagementServiceAPIs + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-oep +# USAGE + python energy_services_list_partitions_maximum_set_gen.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 = OpenEnergyPlatformManagementServiceAPIs( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.energy_services.list_partitions( + resource_group_name="rgoep", + resource_name="aaaaaaaaaaaaaaaaaaa", + ) + print(response) + + +# x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2022-04-04-preview/examples/EnergyServices_ListPartitions_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/oep/azure-mgmt-oep/generated_samples/energy_services_remove_partition_maximum_set_gen.py b/sdk/oep/azure-mgmt-oep/generated_samples/energy_services_remove_partition_maximum_set_gen.py new file mode 100644 index 000000000000..080c9c05181f --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/generated_samples/energy_services_remove_partition_maximum_set_gen.py @@ -0,0 +1,41 @@ +# 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.oep import OpenEnergyPlatformManagementServiceAPIs + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-oep +# USAGE + python energy_services_remove_partition_maximum_set_gen.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 = OpenEnergyPlatformManagementServiceAPIs( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.energy_services.begin_remove_partition( + resource_group_name="rgoep", + resource_name="aaaaaaa", + ).result() + print(response) + + +# x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2022-04-04-preview/examples/EnergyServices_RemovePartition_MaximumSet_Gen.json +if __name__ == "__main__": + main() diff --git a/sdk/oep/azure-mgmt-oep/generated_samples/locations_check_name_availability.py b/sdk/oep/azure-mgmt-oep/generated_samples/locations_check_name_availability.py new file mode 100644 index 000000000000..c70e7855d6d2 --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/generated_samples/locations_check_name_availability.py @@ -0,0 +1,40 @@ +# 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.oep import OpenEnergyPlatformManagementServiceAPIs + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-oep +# USAGE + python locations_check_name_availability.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 = OpenEnergyPlatformManagementServiceAPIs( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.locations.check_name_availability( + body={"name": "sample-name", "type": "Microsoft.OEP/oepResource"}, + ) + print(response) + + +# x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2022-04-04-preview/examples/Locations_CheckNameAvailability.json +if __name__ == "__main__": + main() diff --git a/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_create.py b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_create.py new file mode 100644 index 000000000000..ca6b0a2422b3 --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_create.py @@ -0,0 +1,41 @@ +# 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.oep import OpenEnergyPlatformManagementServiceAPIs + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-oep +# USAGE + python oep_resource_create.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 = OpenEnergyPlatformManagementServiceAPIs( + credential=DefaultAzureCredential(), + subscription_id="0000000-0000-0000-0000-000000000001", + ) + + response = client.energy_services.begin_create( + resource_group_name="DummyResourceGroupName", + resource_name="DummyResourceName", + ).result() + print(response) + + +# x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2022-04-04-preview/examples/OepResource_Create.json +if __name__ == "__main__": + main() diff --git a/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_delete.py b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_delete.py new file mode 100644 index 000000000000..5ffca483aac2 --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_delete.py @@ -0,0 +1,41 @@ +# 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.oep import OpenEnergyPlatformManagementServiceAPIs + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-oep +# USAGE + python oep_resource_delete.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 = OpenEnergyPlatformManagementServiceAPIs( + credential=DefaultAzureCredential(), + subscription_id="0000000-0000-0000-0000-000000000001", + ) + + response = client.energy_services.begin_delete( + resource_group_name="DummyResourceGroupName", + resource_name="DummyResourceName", + ).result() + print(response) + + +# x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2022-04-04-preview/examples/OepResource_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_get.py b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_get.py new file mode 100644 index 000000000000..8487b4c5ac2e --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_get.py @@ -0,0 +1,41 @@ +# 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.oep import OpenEnergyPlatformManagementServiceAPIs + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-oep +# USAGE + python oep_resource_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, + 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 = OpenEnergyPlatformManagementServiceAPIs( + credential=DefaultAzureCredential(), + subscription_id="0000000-0000-0000-0000-000000000001", + ) + + response = client.energy_services.get( + resource_group_name="DummyResourceGroupName", + resource_name="DummyResourceName", + ) + print(response) + + +# x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2022-04-04-preview/examples/OepResource_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_list_by_resource_group.py b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_list_by_resource_group.py new file mode 100644 index 000000000000..2e2c2ef4795f --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_list_by_resource_group.py @@ -0,0 +1,41 @@ +# 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.oep import OpenEnergyPlatformManagementServiceAPIs + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-oep +# USAGE + python oep_resource_list_by_resource_group.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 = OpenEnergyPlatformManagementServiceAPIs( + credential=DefaultAzureCredential(), + subscription_id="0000000-0000-0000-0000-000000000001", + ) + + response = client.energy_services.list_by_resource_group( + resource_group_name="DummyResourceGroupName", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2022-04-04-preview/examples/OepResource_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_list_by_subscription_id.py b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_list_by_subscription_id.py new file mode 100644 index 000000000000..ad64b4f762a5 --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_list_by_subscription_id.py @@ -0,0 +1,39 @@ +# 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.oep import OpenEnergyPlatformManagementServiceAPIs + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-oep +# USAGE + python oep_resource_list_by_subscription_id.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 = OpenEnergyPlatformManagementServiceAPIs( + credential=DefaultAzureCredential(), + subscription_id="0000000-0000-0000-0000-000000000001", + ) + + response = client.energy_services.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2022-04-04-preview/examples/OepResource_ListBySubscriptionId.json +if __name__ == "__main__": + main() diff --git a/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_update.py b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_update.py new file mode 100644 index 000000000000..85edcf7295cf --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/generated_samples/oep_resource_update.py @@ -0,0 +1,41 @@ +# 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.oep import OpenEnergyPlatformManagementServiceAPIs + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-oep +# USAGE + python oep_resource_update.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 = OpenEnergyPlatformManagementServiceAPIs( + credential=DefaultAzureCredential(), + subscription_id="0000000-0000-0000-0000-000000000001", + ) + + response = client.energy_services.update( + resource_group_name="DummyResourceGroupName", + resource_name="DummyResourceName", + ) + print(response) + + +# x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2022-04-04-preview/examples/OepResource_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/oep/azure-mgmt-oep/generated_samples/operations_list.py b/sdk/oep/azure-mgmt-oep/generated_samples/operations_list.py new file mode 100644 index 000000000000..95d6ad1af1e4 --- /dev/null +++ b/sdk/oep/azure-mgmt-oep/generated_samples/operations_list.py @@ -0,0 +1,38 @@ +# 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.oep import OpenEnergyPlatformManagementServiceAPIs + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-oep +# USAGE + python operations_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, + 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 = OpenEnergyPlatformManagementServiceAPIs( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + print(response) + + +# x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2022-04-04-preview/examples/Operations_List.json +if __name__ == "__main__": + main() diff --git a/sdk/oep/azure-mgmt-oep/setup.py b/sdk/oep/azure-mgmt-oep/setup.py index b09e11623d76..312f9cdf1bd2 100644 --- a/sdk/oep/azure-mgmt-oep/setup.py +++ b/sdk/oep/azure-mgmt-oep/setup.py @@ -45,16 +45,17 @@ author='Microsoft Corporation', author_email='azpysdkhelp@microsoft.com', url='https://github.com/Azure/azure-sdk-for-python', + keywords="azure, azure sdk", # update with search keywords relevant to the azure service / product classifiers=[ 'Development Status :: 4 - Beta', 'Programming Language :: Python', - "Programming Language :: Python :: 3 :: Only", + 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'License :: OSI Approved :: MIT License', ], zip_safe=False, @@ -64,10 +65,15 @@ 'azure', 'azure.mgmt', ]), + include_package_data=True, + package_data={ + 'pytyped': ['py.typed'], + }, install_requires=[ - 'msrest>=0.6.21', - 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.0,<2.0.0', + "msrest>=0.7.1", + "azure-common~=1.1", + "azure-mgmt-core>=1.3.2,<2.0.0", + "typing-extensions>=4.3.0; python_version<'3.8.0'", ], - python_requires=">=3.6" + python_requires=">=3.7" ) diff --git a/shared_requirements.txt b/shared_requirements.txt index 42f3f3528547..ea3708929ddb 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -379,7 +379,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-servicefabric msrest>=0.7.1 #override azure-mgmt-streamanalytics msrest>=0.7.1 #override azure-mgmt-consumption msrest>=0.7.1 -#override azure-mgmt-oep msrest>=0.6.21 +#override azure-mgmt-oep msrest>=0.7.1 #override azure-mgmt-loganalytics msrest>=0.7.1 #override azure-mgmt-labservices msrest>=0.7.1 #override azure-mgmt-synapse msrest>=0.6.21 @@ -457,6 +457,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-monitor azure-mgmt-core>=1.3.2,<2.0.0 #override azure-mgmt-hanaonazure azure-mgmt-core>=1.3.2,<2.0.0 #override azure-mgmt-storagepool azure-mgmt-core>=1.3.2,<2.0.0 +#override azure-mgmt-oep typing-extensions>=4.3.0; python_version<'3.8.0' #override azure-mgmt-labservices azure-mgmt-core>=1.3.2,<2.0.0 #override azure-mgmt-notificationhubs typing-extensions>=4.3.0; python_version<'3.8.0' #override azure-mgmt-securityinsight msrest>=0.7.1 @@ -601,6 +602,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-logic msrest>=0.7.1 #override azure-mgmt-logic azure-mgmt-core>=1.3.2,<2.0.0 #override azure-mgmt-datadog typing-extensions>=4.3.0; python_version<'3.8.0' +#override azure-mgmt-oep azure-mgmt-core>=1.3.2,<2.0.0 #override azure-mgmt-communication msrest>=0.7.1 #override azure-mgmt-communication azure-mgmt-core>=1.3.2,<2.0.0 #override azure-mgmt-marketplaceordering msrest>=0.7.1 From ba4aeddd58d54b137cd130491b5c2252b3d2fc7d Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 16 Nov 2022 21:13:35 -0500 Subject: [PATCH 4/7] code and test (#27497) Co-authored-by: PythonSdkPipelines --- sdk/signalr/azure-mgmt-signalr/CHANGELOG.md | 6 + sdk/signalr/azure-mgmt-signalr/MANIFEST.in | 4 +- sdk/signalr/azure-mgmt-signalr/README.md | 4 +- sdk/signalr/azure-mgmt-signalr/_meta.json | 12 +- .../azure/mgmt/signalr/__init__.py | 18 +- .../azure/mgmt/signalr/_configuration.py | 56 +- .../azure/mgmt/signalr/_metadata.json | 109 - .../azure/mgmt/signalr/_patch.py | 2 +- .../azure/mgmt/signalr/_serialization.py | 1970 +++++++++++++++++ .../signalr/_signal_rmanagement_client.py | 62 +- .../azure/mgmt/signalr/_vendor.py | 6 +- .../azure/mgmt/signalr/_version.py | 2 +- .../azure/mgmt/signalr/aio/__init__.py | 18 +- .../azure/mgmt/signalr/aio/_configuration.py | 58 +- .../azure/mgmt/signalr/aio/_patch.py | 2 +- .../signalr/aio/_signal_rmanagement_client.py | 62 +- .../mgmt/signalr/aio/operations/__init__.py | 22 +- .../signalr/aio/operations/_operations.py | 116 +- .../mgmt/signalr/aio/operations/_patch.py | 20 + .../aio/operations/_signal_r_operations.py | 1260 +++++++---- ..._signal_rcustom_certificates_operations.py | 444 ++-- .../_signal_rcustom_domains_operations.py | 496 +++-- ...private_endpoint_connections_operations.py | 426 ++-- ...gnal_rprivate_link_resources_operations.py | 129 +- ...hared_private_link_resources_operations.py | 500 +++-- .../aio/operations/_usages_operations.py | 121 +- .../azure/mgmt/signalr/models/__init__.py | 180 +- .../azure/mgmt/signalr/models/_models_py3.py | 1532 ++++++------- .../azure/mgmt/signalr/models/_patch.py | 20 + .../_signal_rmanagement_client_enums.py | 75 +- .../azure/mgmt/signalr/operations/__init__.py | 22 +- .../mgmt/signalr/operations/_operations.py | 158 +- .../azure/mgmt/signalr/operations/_patch.py | 20 + .../operations/_signal_r_operations.py | 1803 +++++++++------ ..._signal_rcustom_certificates_operations.py | 643 +++--- .../_signal_rcustom_domains_operations.py | 706 +++--- ...private_endpoint_connections_operations.py | 614 +++-- ...gnal_rprivate_link_resources_operations.py | 182 +- ...hared_private_link_resources_operations.py | 688 +++--- .../signalr/operations/_usages_operations.py | 173 +- .../generated_samples/operations_list.py | 39 + .../signal_r_check_name_availability.py | 41 + .../signal_r_create_or_update.py | 84 + .../generated_samples/signal_r_delete.py | 41 + .../generated_samples/signal_r_get.py | 41 + .../signal_r_list_by_resource_group.py | 41 + .../signal_r_list_by_subscription.py | 39 + .../generated_samples/signal_r_list_keys.py | 41 + .../generated_samples/signal_r_list_skus.py | 41 + .../signal_r_regenerate_key.py | 42 + .../generated_samples/signal_r_restart.py | 41 + .../generated_samples/signal_r_update.py | 84 + ...l_rcustom_certificates_create_or_update.py | 49 + .../signal_rcustom_certificates_delete.py | 42 + .../signal_rcustom_certificates_get.py | 42 + .../signal_rcustom_certificates_list.py | 42 + ...signal_rcustom_domains_create_or_update.py | 50 + .../signal_rcustom_domains_delete.py | 42 + .../signal_rcustom_domains_get.py | 42 + .../signal_rcustom_domains_list.py | 42 + ...al_rprivate_endpoint_connections_delete.py | 42 + ...ignal_rprivate_endpoint_connections_get.py | 42 + ...gnal_rprivate_endpoint_connections_list.py | 42 + ...al_rprivate_endpoint_connections_update.py | 50 + .../signal_rprivate_link_resources_list.py | 42 + ...private_link_resources_create_or_update.py | 49 + ...l_rshared_private_link_resources_delete.py | 42 + ...gnal_rshared_private_link_resources_get.py | 42 + ...nal_rshared_private_link_resources_list.py | 42 + .../generated_samples/usages_list.py | 41 + sdk/signalr/azure-mgmt-signalr/setup.py | 15 +- shared_requirements.txt | 5 +- 72 files changed, 9870 insertions(+), 4251 deletions(-) delete mode 100644 sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_metadata.json create mode 100644 sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_serialization.py create mode 100644 sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_patch.py create mode 100644 sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_patch.py create mode 100644 sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_patch.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/operations_list.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_check_name_availability.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_create_or_update.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_delete.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_get.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_resource_group.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_subscription.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_keys.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_skus.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_regenerate_key.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_restart.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_update.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_create_or_update.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_delete.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_get.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_list.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_create_or_update.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_delete.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_get.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_list.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_delete.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_get.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_list.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_update.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_link_resources_list.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_create_or_update.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_delete.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_get.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_list.py create mode 100644 sdk/signalr/azure-mgmt-signalr/generated_samples/usages_list.py diff --git a/sdk/signalr/azure-mgmt-signalr/CHANGELOG.md b/sdk/signalr/azure-mgmt-signalr/CHANGELOG.md index 4f7f8884792e..a9e8588b9ef8 100644 --- a/sdk/signalr/azure-mgmt-signalr/CHANGELOG.md +++ b/sdk/signalr/azure-mgmt-signalr/CHANGELOG.md @@ -1,5 +1,11 @@ # Release History +## 1.2.0b1 (2022-11-15) + +### Features Added + + - Model SignalRResource has a new parameter serverless + ## 1.1.0 (2022-03-28) **Features** diff --git a/sdk/signalr/azure-mgmt-signalr/MANIFEST.in b/sdk/signalr/azure-mgmt-signalr/MANIFEST.in index 2c31e8da0cb1..e16d68d280c3 100644 --- a/sdk/signalr/azure-mgmt-signalr/MANIFEST.in +++ b/sdk/signalr/azure-mgmt-signalr/MANIFEST.in @@ -1,6 +1,8 @@ include _meta.json -recursive-include tests *.py *.yaml +recursive-include tests *.py *.json +recursive-include samples *.py *.md include *.md include azure/__init__.py include azure/mgmt/__init__.py include LICENSE +include azure/mgmt/signalr/py.typed diff --git a/sdk/signalr/azure-mgmt-signalr/README.md b/sdk/signalr/azure-mgmt-signalr/README.md index d8d3f7d0bf0e..187c7754b24f 100644 --- a/sdk/signalr/azure-mgmt-signalr/README.md +++ b/sdk/signalr/azure-mgmt-signalr/README.md @@ -1,7 +1,7 @@ # Microsoft Azure SDK for Python This is the Microsoft Azure SignalR Client Library. -This package has been tested with Python 3.6+. +This package has been tested with Python 3.7+. For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). ## _Disclaimer_ @@ -12,8 +12,6 @@ _Azure SDK Python packages support for Python 2.7 has ended 01 January 2022. For To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) - - For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) Code samples for this package can be found at [SignalR](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. diff --git a/sdk/signalr/azure-mgmt-signalr/_meta.json b/sdk/signalr/azure-mgmt-signalr/_meta.json index faaad9c178d7..a859c81c0e2a 100644 --- a/sdk/signalr/azure-mgmt-signalr/_meta.json +++ b/sdk/signalr/azure-mgmt-signalr/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "commit": "30deed618795ce9e4a549aa16ef349ae2b03785c", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.12.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.2.1", + "@autorest/modelerfour@4.24.3" ], - "commit": "4acb59eaeaeff82d37f7e885096d3668588b33a1", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/signalr/resource-manager/readme.md --multiapi --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/signalr/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.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/signalr/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/__init__.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/__init__.py index a4c83e80f925..da46f97016ea 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/__init__.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/__init__.py @@ -10,9 +10,17 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['SignalRManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SignalRManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_configuration.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_configuration.py index 6b932f223f4f..f2f968150070 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_configuration.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,30 +15,36 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential -class SignalRManagementClientConfiguration(Configuration): +class SignalRManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SignalRManagementClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Gets subscription Id which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription Id which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". 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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SignalRManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-08-01-preview") # type: Literal["2022-08-01-preview"] + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,24 +52,25 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2022-02-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-signalr/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-signalr/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_metadata.json b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_metadata.json deleted file mode 100644 index 662aebf16427..000000000000 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_metadata.json +++ /dev/null @@ -1,109 +0,0 @@ -{ - "chosen_version": "2022-02-01", - "total_api_version_list": ["2022-02-01"], - "client": { - "name": "SignalRManagementClient", - "filename": "_signal_rmanagement_client", - "description": "REST API for Azure SignalR Service.", - "host_value": "\"https://management.azure.com\"", - "parameterized_host_template": null, - "azure_arm": true, - "has_lro_operations": true, - "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SignalRManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"SignalRManagementClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription Id which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Gets subscription Id which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: str = \"https://management.azure.com\",", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "config": { - "credential": true, - "credential_scopes": ["https://management.azure.com/.default"], - "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" - }, - "operation_groups": { - "operations": "Operations", - "signal_r": "SignalROperations", - "usages": "UsagesOperations", - "signal_rcustom_certificates": "SignalRCustomCertificatesOperations", - "signal_rcustom_domains": "SignalRCustomDomainsOperations", - "signal_rprivate_endpoint_connections": "SignalRPrivateEndpointConnectionsOperations", - "signal_rprivate_link_resources": "SignalRPrivateLinkResourcesOperations", - "signal_rshared_private_link_resources": "SignalRSharedPrivateLinkResourcesOperations" - } -} \ No newline at end of file diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_patch.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_patch.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_serialization.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_serialization.py new file mode 100644 index 000000000000..7c1dedb5133d --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_serialization.py @@ -0,0 +1,1970 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs + +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding="utf-8") + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r"^(application|text)/([a-z+.]+\+)?json$") + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, "read"): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding="utf-8-sig") + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # 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 + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # 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("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if "content-type" in headers: + content_type = headers["content-type"].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds() / 3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + + +try: + from datetime import timezone + + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0, + } + + def __init__(self, classes=None): + self.serialize_type = { + "iso-8601": Serializer.serialize_iso, + "rfc-1123": Serializer.serialize_rfc, + "unix-time": Serializer.serialize_unix, + "duration": Serializer.serialize_duration, + "date": Serializer.serialize_date, + "time": Serializer.serialize_time, + "decimal": Serializer.serialize_decimal, + "long": Serializer.serialize_long, + "bytearray": Serializer.serialize_bytearray, + "base64": Serializer.serialize_base64, + "object": self.serialize_object, + "[]": self.serialize_iter, + "{}": self.serialize_dict, + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data(target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data(target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get("readonly", False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == "": + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc["type"], **kwargs) + + if is_xml_model_serialization: + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + xml_prefix = xml_desc.get("prefix", None) + xml_ns = xml_desc.get("ns", None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if "name" not in getattr(orig_attr, "_xml_map", {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + 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) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip("[]{}") + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor, + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback(SerializationError, "Unable to build a model: " + str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" for d in data] + if not kwargs.get("skip_quote", False): + data = [quote(str(d), safe="") for d in data] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + if kwargs.get("skip_quote") is True: + output = str(output) + else: + output = quote(str(output), safe="") + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ["[str]"]: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == "bool": + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type](data, data_type[1:-1], **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) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == "str": + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ["" if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if "xml" in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get("xml", {}) + xml_name = xml_desc.get("name") + if not xml_name: + xml_name = serialization_ctxt["key"] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node(node_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data(value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if "xml" in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt["xml"] + xml_name = xml_desc["name"] + + final_result = _create_xml_node(xml_name, xml_desc.get("prefix", None), xml_desc.get("ns", None)) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + 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: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object(value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object(obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode("ascii") + return encoded.strip("=").replace("+", "-").replace("/", "_") + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], + utc.tm_mday, + Serializer.months[utc.tm_mon], + utc.tm_year, + utc.tm_hour, + utc.tm_min, + utc.tm_sec, + ) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6, "0").rstrip("0").ljust(3, "0") + if microseconds: + microseconds = "." + microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, utc.tm_hour, utc.tm_min, utc.tm_sec + ) + return date + microseconds + "Z" + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning("Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, 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:]) + + return working_data.get(key) + + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc["key"] + working_data = data + + while "." in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_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:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key.""" + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc["key"] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get("name", internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get("xml", {}) + xml_name = xml_desc.get("name", attr_desc["key"]) + + # Look for a children + is_iter_type = attr_desc["type"].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get("ns", internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or "name" not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and "name" in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + ) + ) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: "str", int: "int", bool: "bool", float: "float"} + + 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=None): + self.deserialize_type = { + "iso-8601": Deserializer.deserialize_iso, + "rfc-1123": Deserializer.deserialize_rfc, + "unix-time": Deserializer.deserialize_unix, + "duration": Deserializer.deserialize_duration, + "date": Deserializer.deserialize_date, + "time": Deserializer.deserialize_time, + "decimal": Deserializer.deserialize_decimal, + "long": Deserializer.deserialize_long, + "bytearray": Deserializer.deserialize_bytearray, + "base64": Deserializer.deserialize_base64, + "object": self.deserialize_object, + "[]": self.deserialize_iter, + "{}": self.deserialize_dict, + } + self.deserialize_expected_types = { + "duration": (isodate.Duration, datetime.timedelta), + "iso-8601": (datetime.datetime), + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, "_validation", {}).items() if config.get("constant")] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig["type"] + internal_data_type = local_type.strip("[]{}") + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr(data, attr, self._deserialize(local_type, value)) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == "": + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip("[]{}") + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ( + "Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" + ) + _LOGGER.warning(msg, found_value, key_extractor, attr) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc["type"]) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != "": + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = { + _decode_attribute_map_key(_FLATTEN.split(desc["key"])[0]) + for desc in attribute_map.values() + if desc["key"] != "" + } + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + # Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics(raw_data.text(), raw_data.headers) + + # Assume this enough to recognize requests.Response without importing it. + 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"): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, "_subtype_map", {}) + try: + readonly = [k for k, v in response._validation.items() if v.get("readonly")] + const = [k for k, v in response._validation.items() if v.get("constant")] + kwargs = {k: v for k, v in attrs.items() if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format(kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_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) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format(iter_type, type(attr))) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x["key"]: self.deserialize_data(x["value"], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, "str") + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object(value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object(obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return "" + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == "bool": + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ["true", "1"]: + return True + elif attr.lower() in ["false", "0"]: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == "str": + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + 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: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = "=" * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace("-", "+").replace("_", "/") + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0) / 60)) + ) + if not date_obj.tzinfo: + 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) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split(".") + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except (ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + 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) + else: + return date_obj diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_signal_rmanagement_client.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_signal_rmanagement_client.py index 1f22d0a3571f..ea14a0a3d181 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_signal_rmanagement_client.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_signal_rmanagement_client.py @@ -7,21 +7,31 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Optional, TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient -from msrest import Deserializer, Serializer from . import models from ._configuration import SignalRManagementClientConfiguration -from .operations import Operations, SignalRCustomCertificatesOperations, SignalRCustomDomainsOperations, SignalROperations, SignalRPrivateEndpointConnectionsOperations, SignalRPrivateLinkResourcesOperations, SignalRSharedPrivateLinkResourcesOperations, UsagesOperations +from ._serialization import Deserializer, Serializer +from .operations import ( + Operations, + SignalRCustomCertificatesOperations, + SignalRCustomDomainsOperations, + SignalROperations, + SignalRPrivateEndpointConnectionsOperations, + SignalRPrivateLinkResourcesOperations, + SignalRSharedPrivateLinkResourcesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class SignalRManagementClient: + +class SignalRManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure SignalR Service. :ivar operations: Operations operations @@ -46,13 +56,16 @@ class SignalRManagementClient: operations :vartype signal_rshared_private_link_resources: azure.mgmt.signalr.operations.SignalRSharedPrivateLinkResourcesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Gets subscription Id which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -64,7 +77,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SignalRManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SignalRManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -74,18 +89,23 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.signal_r = SignalROperations(self._client, self._config, self._serialize, self._deserialize) self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.signal_rcustom_certificates = SignalRCustomCertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.signal_rcustom_domains = SignalRCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) - self.signal_rprivate_endpoint_connections = SignalRPrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.signal_rprivate_link_resources = SignalRPrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.signal_rshared_private_link_resources = SignalRSharedPrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request, # type: HttpRequest - **kwargs: Any - ) -> HttpResponse: + self.signal_rcustom_certificates = SignalRCustomCertificatesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.signal_rcustom_domains = SignalRCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.signal_rprivate_endpoint_connections = SignalRPrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.signal_rprivate_link_resources = SignalRPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.signal_rshared_private_link_resources = SignalRSharedPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -94,7 +114,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_vendor.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_vendor.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_version.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_version.py index 59deb8c7263b..58920e6942de 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_version.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.1.0" +VERSION = "1.2.0b1" diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/__init__.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/__init__.py index 883d13814096..713aa85f3f15 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/__init__.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/__init__.py @@ -7,9 +7,17 @@ # -------------------------------------------------------------------------- from ._signal_rmanagement_client import SignalRManagementClient -__all__ = ['SignalRManagementClient'] -# `._patch.py` is used for handwritten extensions to the generated code -# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md -from ._patch import patch_sdk -patch_sdk() +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SignalRManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_configuration.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_configuration.py index f2807500c91e..f04d1a3fa764 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_configuration.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,30 +15,36 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential -class SignalRManagementClientConfiguration(Configuration): +class SignalRManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for SignalRManagementClient. Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Gets subscription Id which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Gets subscription Id which uniquely identify the Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". 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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SignalRManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-08-01-preview") # type: Literal["2022-08-01-preview"] + if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -45,23 +52,22 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.api_version = "2022-02-01" - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-signalr/{}'.format(VERSION)) + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-signalr/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_patch.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_patch.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_signal_rmanagement_client.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_signal_rmanagement_client.py index c2ec56721333..25aa0cd6d4d2 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_signal_rmanagement_client.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/_signal_rmanagement_client.py @@ -7,21 +7,31 @@ # -------------------------------------------------------------------------- from copy import deepcopy -from typing import Any, Awaitable, Optional, TYPE_CHECKING +from typing import Any, Awaitable, TYPE_CHECKING from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient -from msrest import Deserializer, Serializer from .. import models +from .._serialization import Deserializer, Serializer from ._configuration import SignalRManagementClientConfiguration -from .operations import Operations, SignalRCustomCertificatesOperations, SignalRCustomDomainsOperations, SignalROperations, SignalRPrivateEndpointConnectionsOperations, SignalRPrivateLinkResourcesOperations, SignalRSharedPrivateLinkResourcesOperations, UsagesOperations +from .operations import ( + Operations, + SignalRCustomCertificatesOperations, + SignalRCustomDomainsOperations, + SignalROperations, + SignalRPrivateEndpointConnectionsOperations, + SignalRPrivateLinkResourcesOperations, + SignalRSharedPrivateLinkResourcesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class SignalRManagementClient: + +class SignalRManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """REST API for Azure SignalR Service. :ivar operations: Operations operations @@ -47,13 +57,16 @@ class SignalRManagementClient: operations :vartype signal_rshared_private_link_resources: azure.mgmt.signalr.aio.operations.SignalRSharedPrivateLinkResourcesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Gets subscription Id which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str - :param base_url: Service URL. Default value is 'https://management.azure.com'. + :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ @@ -65,7 +78,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = SignalRManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = SignalRManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -75,18 +90,23 @@ def __init__( self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) self.signal_r = SignalROperations(self._client, self._config, self._serialize, self._deserialize) self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) - self.signal_rcustom_certificates = SignalRCustomCertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.signal_rcustom_domains = SignalRCustomDomainsOperations(self._client, self._config, self._serialize, self._deserialize) - self.signal_rprivate_endpoint_connections = SignalRPrivateEndpointConnectionsOperations(self._client, self._config, self._serialize, self._deserialize) - self.signal_rprivate_link_resources = SignalRPrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - self.signal_rshared_private_link_resources = SignalRSharedPrivateLinkResourcesOperations(self._client, self._config, self._serialize, self._deserialize) - - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + self.signal_rcustom_certificates = SignalRCustomCertificatesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.signal_rcustom_domains = SignalRCustomDomainsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.signal_rprivate_endpoint_connections = SignalRPrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.signal_rprivate_link_resources = SignalRPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.signal_rshared_private_link_resources = SignalRSharedPrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -95,7 +115,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/__init__.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/__init__.py index bab1a78daafd..0fe4134b4d88 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/__init__.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/__init__.py @@ -15,13 +15,19 @@ from ._signal_rprivate_link_resources_operations import SignalRPrivateLinkResourcesOperations from ._signal_rshared_private_link_resources_operations import SignalRSharedPrivateLinkResourcesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SignalROperations', - 'UsagesOperations', - 'SignalRCustomCertificatesOperations', - 'SignalRCustomDomainsOperations', - 'SignalRPrivateEndpointConnectionsOperations', - 'SignalRPrivateLinkResourcesOperations', - 'SignalRSharedPrivateLinkResourcesOperations', + "Operations", + "SignalROperations", + "UsagesOperations", + "SignalRCustomCertificatesOperations", + "SignalRCustomDomainsOperations", + "SignalRPrivateEndpointConnectionsOperations", + "SignalRPrivateLinkResourcesOperations", + "SignalRSharedPrivateLinkResourcesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_operations.py index 7f7358249b77..454a8f4d1baf 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,80 +6,109 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class Operations: - """Operations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.aio.SignalRManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.OperationList"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available REST API operations of the Microsoft.SignalRService provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.OperationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -92,7 +122,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -102,8 +134,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.SignalRService/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.SignalRService/operations"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_patch.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_r_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_r_operations.py index 20c487388ef1..30d804ee6755 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_r_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_r_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,88 +6,177 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._signal_r_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_keys_request, build_list_skus_request, build_regenerate_key_request_initial, build_restart_request_initial, build_update_request_initial -T = TypeVar('T') +from ...operations._signal_r_operations import ( + build_check_name_availability_request, + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_by_subscription_request, + build_list_keys_request, + build_list_skus_request, + build_regenerate_key_request, + build_restart_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SignalROperations: - """SignalROperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SignalROperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.aio.SignalRManagementClient`'s + :attr:`signal_r` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async + @overload async def check_name_availability( self, location: str, - parameters: "_models.NameAvailabilityParameters", + parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.signalr.models.NameAvailabilityParameters + :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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO + :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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.signalr.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @distributed_trace_async + async def check_name_availability( + self, location: str, parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. - _json = self._serialize.body(parameters, 'NameAvailabilityParameters') + :param location: the region. Required. + :type location: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.signalr.models.NameAvailabilityParameters 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 + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.signalr.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -94,51 +184,68 @@ async def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SignalRResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SignalRResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SignalRResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SignalRResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SignalRResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -152,7 +259,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -162,53 +271,69 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/signalR'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/signalR"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SignalRResourceList"]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SignalRResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 SignalRResourceList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SignalRResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SignalRResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -222,7 +347,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -232,48 +359,56 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.SignalRResource": + async def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SignalRResource: """Get the resource and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SignalRResource, or the result of cls(response) + :return: SignalRResource or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SignalRResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -281,83 +416,180 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.SignalRResource", + parameters: Union[_models.SignalRResource, IO], **kwargs: Any - ) -> Optional["_models.SignalRResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SignalRResource"]] + ) -> Optional[_models.SignalRResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'SignalRResource') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SignalRResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SignalRResource") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.SignalRResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SignalRResource]: + """Create or update a resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource + :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 SignalRResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SignalRResource]: + """Create or update a resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: IO + :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 SignalRResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.SignalRResource", + parameters: Union[_models.SignalRResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.SignalRResource"]: + ) -> AsyncLROPoller[_models.SignalRResource]: """Create or update a resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param parameters: Parameters for the create or update operation. - :type parameters: ~azure.mgmt.signalr.models.SignalRResource + :param parameters: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource 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 @@ -369,98 +601,111 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore @distributed_trace_async - async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Operation to delete a resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_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. @@ -472,108 +717,215 @@ async def begin_delete( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore async def _update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.SignalRResource", + parameters: Union[_models.SignalRResource, IO], **kwargs: Any - ) -> Optional["_models.SignalRResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SignalRResource"]] + ) -> Optional[_models.SignalRResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'SignalRResource') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SignalRResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SignalRResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.SignalRResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SignalRResource]: + """Operation to update an exiting resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource + :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 SignalRResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SignalRResource]: + """Operation to update an exiting resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: IO + :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 SignalRResource or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.SignalRResource", + parameters: Union[_models.SignalRResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.SignalRResource"]: + ) -> AsyncLROPoller[_models.SignalRResource]: """Operation to update an exiting resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param parameters: Parameters for the update operation. - :type parameters: ~azure.mgmt.signalr.models.SignalRResource + :param parameters: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource 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 @@ -585,86 +937,102 @@ async def begin_update( :return: An instance of AsyncLROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._update_initial( + raw_result = await self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore @distributed_trace_async - async def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.SignalRKeys": + async def list_keys(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SignalRKeys: """Get the access keys of the resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SignalRKeys, or the result of cls(response) + :return: SignalRKeys or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SignalRKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRKeys] - request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -672,79 +1040,178 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SignalRKeys', pipeline_response) + deserialized = self._deserialize("SignalRKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/listKeys'} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/listKeys"} # type: ignore async def _regenerate_key_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.RegenerateKeyParameters", + parameters: Union[_models.RegenerateKeyParameters, IO], **kwargs: Any - ) -> "_models.SignalRKeys": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRKeys"] + ) -> _models.SignalRKeys: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'RegenerateKeyParameters') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeyParameters") - request = build_regenerate_key_request_initial( - subscription_id=self._config.subscription_id, + request = build_regenerate_key_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._regenerate_key_initial.metadata['url'], + content=_content, + template_url=self._regenerate_key_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SignalRKeys', pipeline_response) + deserialized = self._deserialize("SignalRKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _regenerate_key_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey'} # type: ignore + _regenerate_key_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey"} # type: ignore + @overload + async def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SignalRKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Required. + :type parameters: ~azure.mgmt.signalr.models.RegenerateKeyParameters + :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 SignalRKeys or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SignalRKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Required. + :type parameters: IO + :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 SignalRKeys or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_regenerate_key( self, resource_group_name: str, resource_name: str, - parameters: "_models.RegenerateKeyParameters", + parameters: Union[_models.RegenerateKeyParameters, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.SignalRKeys"]: + ) -> AsyncLROPoller[_models.SignalRKeys]: """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated at the same time. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param parameters: Parameter that describes the Regenerate Key Operation. - :type parameters: ~azure.mgmt.signalr.models.RegenerateKeyParameters + :param parameters: Parameter that describes the Regenerate Key Operation. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.signalr.models.RegenerateKeyParameters 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 @@ -756,98 +1223,114 @@ async def begin_regenerate_key( :return: An instance of AsyncLROPoller that returns either SignalRKeys or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SignalRKeys] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRKeys"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRKeys] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._regenerate_key_initial( + raw_result = await self._regenerate_key_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SignalRKeys', pipeline_response) + deserialized = self._deserialize("SignalRKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey'} # type: ignore + begin_regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey"} # type: ignore - async def _restart_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any + async def _restart_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._restart_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart'} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart"} # type: ignore @distributed_trace_async - async def begin_restart( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_restart(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Operation to restart a resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_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. @@ -859,80 +1342,100 @@ async def begin_restart( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._restart_initial( + raw_result = await self._restart_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, + AsyncARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs), + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart'} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart"} # type: ignore @distributed_trace_async - async def list_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.SkuList": + async def list_skus(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SkuList: """List all available skus of the resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SkuList, or the result of cls(response) + :return: SkuList or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SkuList - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SkuList] - request = build_list_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -940,12 +1443,11 @@ async def list_skus( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SkuList', pipeline_response) + deserialized = self._deserialize("SkuList", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/skus'} # type: ignore - + list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/skus"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_certificates_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_certificates_operations.py index b2d6ea78cac1..7d8610044cbb 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_certificates_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,97 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._signal_rcustom_certificates_operations import build_create_or_update_request_initial, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._signal_rcustom_certificates_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SignalRCustomCertificatesOperations: - """SignalRCustomCertificatesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SignalRCustomCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.aio.SignalRManagementClient`'s + :attr:`signal_rcustom_certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CustomCertificateList"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomCertificate"]: """List all custom certificates. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomCertificateList or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.CustomCertificateList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either CustomCertificate or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomCertificateList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomCertificateList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +140,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,52 +152,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CustomCertificate": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CustomCertificate: """Get a custom certificate. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param certificate_name: Custom certificate name. + :param certificate_name: Custom certificate name. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomCertificate, or the result of cls(response) + :return: CustomCertificate or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.CustomCertificate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomCertificate"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomCertificate] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -172,66 +214,165 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomCertificate', pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, certificate_name: str, - parameters: "_models.CustomCertificate", + parameters: Union[_models.CustomCertificate, IO], **kwargs: Any - ) -> "_models.CustomCertificate": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomCertificate"] + ) -> _models.CustomCertificate: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'CustomCertificate') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomCertificate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CustomCertificate") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomCertificate', pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomCertificate', pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}"} # type: ignore + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: _models.CustomCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.signalr.models.CustomCertificate + :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 CustomCertificate or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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 CustomCertificate or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -239,20 +380,23 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - parameters: "_models.CustomCertificate", + parameters: Union[_models.CustomCertificate, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomCertificate"]: + ) -> AsyncLROPoller[_models.CustomCertificate]: """Create or update a custom certificate. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param certificate_name: Custom certificate name. + :param certificate_name: Custom certificate name. Required. :type certificate_name: str - :param parameters: - :type parameters: ~azure.mgmt.signalr.models.CustomCertificate + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.signalr.models.CustomCertificate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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 @@ -264,91 +408,108 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either CustomCertificate or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomCertificate] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomCertificate"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomCertificate] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomCertificate', pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}"} # type: ignore @distributed_trace_async - async def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any ) -> None: """Delete a custom certificate. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param certificate_name: Custom certificate name. + :param certificate_name: Custom certificate name. Required. :type certificate_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.delete.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -359,5 +520,4 @@ async def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_domains_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_domains_operations.py index 4782d77bbae2..46a0ba6aef34 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_domains_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rcustom_domains_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,127 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._signal_rcustom_domains_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._signal_rcustom_domains_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SignalRCustomDomainsOperations: - """SignalRCustomDomainsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SignalRCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.aio.SignalRManagementClient`'s + :attr:`signal_rcustom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.CustomDomainList"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.CustomDomain"]: """List all custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomDomainList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.CustomDomainList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either CustomDomain or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -107,7 +140,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,52 +152,59 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - resource_name: str, - name: str, - **kwargs: Any - ) -> "_models.CustomDomain": + async def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> _models.CustomDomain: """Get a custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param name: Custom domain name. + :param name: Custom domain name. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomain, or the result of cls(response) + :return: CustomDomain or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.CustomDomain - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomain"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomain] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, name=name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -170,62 +212,161 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomain', pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}"} # type: ignore async def _create_or_update_initial( self, resource_group_name: str, resource_name: str, name: str, - parameters: "_models.CustomDomain", + parameters: Union[_models.CustomDomain, IO], **kwargs: Any - ) -> "_models.CustomDomain": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomain"] + ) -> _models.CustomDomain: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'CustomDomain') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomain] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CustomDomain") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomain', pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}"} # type: ignore + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: _models.CustomDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.signalr.models.CustomDomain + :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 CustomDomain or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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 CustomDomain or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -233,20 +374,23 @@ async def begin_create_or_update( resource_group_name: str, resource_name: str, name: str, - parameters: "_models.CustomDomain", + parameters: Union[_models.CustomDomain, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.CustomDomain"]: + ) -> AsyncLROPoller[_models.CustomDomain]: """Create or update a custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param name: Custom domain name. + :param name: Custom domain name. Required. :type name: str - :param parameters: - :type parameters: ~azure.mgmt.signalr.models.CustomDomain + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.signalr.models.CustomDomain or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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 @@ -258,104 +402,117 @@ async def begin_create_or_update( :return: An instance of AsyncLROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.CustomDomain] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomain"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomain] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, name=name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomain', pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}"} # type: ignore - async def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, name=name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_name: str, - name: str, - **kwargs: Any + self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete a custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param name: Custom domain name. + :param name: Custom domain name. Required. :type 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. @@ -367,41 +524,50 @@ async def begin_delete( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, name=name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_endpoint_connections_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_endpoint_connections_operations.py index 4fd05a5a8d75..fed40eccdcfe 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_endpoint_connections_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,97 +6,129 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._signal_rprivate_endpoint_connections_operations import build_delete_request_initial, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._signal_rprivate_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SignalRPrivateEndpointConnectionsOperations: - """SignalRPrivateEndpointConnectionsOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SignalRPrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.aio.SignalRManagementClient`'s + :attr:`signal_rprivate_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateEndpointConnectionList"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List private endpoint connections. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionList or the result of + :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.PrivateEndpointConnectionList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +142,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,52 +154,61 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection. - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -172,15 +216,76 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload + async def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Required. + :type parameters: ~azure.mgmt.signalr.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Required. + :type parameters: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( @@ -188,48 +293,74 @@ async def update( private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection. - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param parameters: The resource of private endpoint and its properties. - :type parameters: ~azure.mgmt.signalr.models.PrivateEndpointConnection + :param parameters: The resource of private endpoint and its properties. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.signalr.models.PrivateEndpointConnection 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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_update_request( private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -237,69 +368,75 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - async def _delete_initial( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the specified private endpoint connection. - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_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. @@ -311,41 +448,50 @@ async def begin_delete( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore private_endpoint_connection_name=private_endpoint_connection_name, resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_link_resources_operations.py index ff7533bab4a3..636bbcc629e6 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_link_resources_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rprivate_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,95 +6,119 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._signal_rprivate_link_resources_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SignalRPrivateLinkResourcesOperations: - """SignalRPrivateLinkResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SignalRPrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.aio.SignalRManagementClient`'s + :attr:`signal_rprivate_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.PrivateLinkResourceList"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateLinkResource"]: """Get the private link resources that need to be created for a resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceList or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.PrivateLinkResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -107,7 +132,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -117,8 +144,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateLinkResources'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateLinkResources"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rshared_private_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rshared_private_link_resources_operations.py index 07cbd131abf0..511310457d07 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rshared_private_link_resources_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_signal_rshared_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,97 +6,129 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.tracing.decorator import distributed_trace from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models from ..._vendor import _convert_request -from ...operations._signal_rshared_private_link_resources_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._signal_rshared_private_link_resources_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class SignalRSharedPrivateLinkResourcesOperations: - """SignalRSharedPrivateLinkResourcesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class SignalRSharedPrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.aio.SignalRManagementClient`'s + :attr:`signal_rshared_private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> AsyncIterable["_models.SharedPrivateLinkResourceList"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SharedPrivateLinkResource"]: """List shared private link resources. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedPrivateLinkResourceList or the result of + :return: An iterator like instance of either SharedPrivateLinkResource or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SharedPrivateLinkResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedPrivateLinkResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -109,7 +142,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -119,52 +154,62 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources"} # type: ignore @distributed_trace_async async def get( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.SharedPrivateLinkResource": + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.SharedPrivateLinkResource: """Get the specified shared private link resource. :param shared_private_link_resource_name: The name of the shared private link resource. + Required. :type shared_private_link_resource_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedPrivateLinkResource, or the result of cls(response) + :return: SharedPrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SharedPrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedPrivateLinkResource] - request = build_get_request( shared_private_link_resource_name=shared_private_link_resource_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -172,66 +217,169 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedPrivateLinkResource', pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"} # type: ignore async def _create_or_update_initial( self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, - parameters: "_models.SharedPrivateLinkResource", + parameters: Union[_models.SharedPrivateLinkResource, IO], **kwargs: Any - ) -> "_models.SharedPrivateLinkResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResource"] + ) -> _models.SharedPrivateLinkResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'SharedPrivateLinkResource') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedPrivateLinkResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedPrivateLinkResource") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( shared_private_link_resource_name=shared_private_link_resource_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SharedPrivateLinkResource', pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SharedPrivateLinkResource', pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"} # type: ignore + @overload + async def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: _models.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource + :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 SharedPrivateLinkResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: IO + :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 SharedPrivateLinkResource or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create_or_update( @@ -239,20 +387,25 @@ async def begin_create_or_update( shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, - parameters: "_models.SharedPrivateLinkResource", + parameters: Union[_models.SharedPrivateLinkResource, IO], **kwargs: Any - ) -> AsyncLROPoller["_models.SharedPrivateLinkResource"]: + ) -> AsyncLROPoller[_models.SharedPrivateLinkResource]: """Create or update a shared private link resource. :param shared_private_link_resource_name: The name of the shared private link resource. + Required. :type shared_private_link_resource_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param parameters: The shared private link resource. - :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource + :param parameters: The shared private link resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource 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 @@ -265,104 +418,118 @@ async def begin_create_or_update( result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedPrivateLinkResource] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._create_or_update_initial( + raw_result = await self._create_or_update_initial( # type: ignore shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SharedPrivateLinkResource', pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"} # type: ignore - async def _delete_initial( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + async def _delete_initial( # pylint: disable=inconsistent-return-statements + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( shared_private_link_resource_name=shared_private_link_resource_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Delete the specified shared private link resource. :param shared_private_link_resource_name: The name of the shared private link resource. + Required. :type shared_private_link_resource_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_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. @@ -374,41 +541,50 @@ async def begin_delete( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = await self._delete_initial( + raw_result = await self._delete_initial( # type: ignore shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = AsyncNoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_usages_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_usages_operations.py index aa1860efef37..84a64f73b734 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_usages_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/aio/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,87 +6,113 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +import sys +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest from azure.core.tracing.decorator import distributed_trace -from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] -class UsagesOperations: - """UsagesOperations async operations. - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.aio.SignalRManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable["_models.SignalRUsageList"]: + def list(self, location: str, **kwargs: Any) -> AsyncIterable["_models.SignalRUsage"]: """List resource usage quotas by location. - :param location: the location like "eastus". + :param location: the location like "eastus". Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SignalRUsageList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SignalRUsageList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SignalRUsage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.signalr.models.SignalRUsage] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRUsageList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRUsageList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( location=location, subscription_id=self._config.subscription_id, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - location=location, - subscription_id=self._config.subscription_id, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -99,7 +126,9 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -109,8 +138,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/__init__.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/__init__.py index 77981208a65d..e98cc00204a0 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/__init__.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/__init__.py @@ -41,6 +41,7 @@ from ._models_py3 import ResourceLogConfiguration from ._models_py3 import ResourceReference from ._models_py3 import ResourceSku +from ._models_py3 import ServerlessSettings from ._models_py3 import ServerlessUpstreamSettings from ._models_py3 import ServiceSpecification from ._models_py3 import ShareablePrivateLinkResourceProperties @@ -66,94 +67,97 @@ from ._models_py3 import UpstreamTemplate from ._models_py3 import UserAssignedIdentityProperty - -from ._signal_rmanagement_client_enums import ( - ACLAction, - CreatedByType, - FeatureFlags, - KeyType, - ManagedIdentityType, - PrivateLinkServiceConnectionStatus, - ProvisioningState, - ScaleType, - ServiceKind, - SharedPrivateLinkResourceStatus, - SignalRRequestType, - SignalRSkuTier, - UpstreamAuthType, -) +from ._signal_rmanagement_client_enums import ACLAction +from ._signal_rmanagement_client_enums import CreatedByType +from ._signal_rmanagement_client_enums import FeatureFlags +from ._signal_rmanagement_client_enums import KeyType +from ._signal_rmanagement_client_enums import ManagedIdentityType +from ._signal_rmanagement_client_enums import PrivateLinkServiceConnectionStatus +from ._signal_rmanagement_client_enums import ProvisioningState +from ._signal_rmanagement_client_enums import ScaleType +from ._signal_rmanagement_client_enums import ServiceKind +from ._signal_rmanagement_client_enums import SharedPrivateLinkResourceStatus +from ._signal_rmanagement_client_enums import SignalRRequestType +from ._signal_rmanagement_client_enums import SignalRSkuTier +from ._signal_rmanagement_client_enums import UpstreamAuthType +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ - 'CustomCertificate', - 'CustomCertificateList', - 'CustomDomain', - 'CustomDomainList', - 'Dimension', - 'ErrorAdditionalInfo', - 'ErrorDetail', - 'ErrorResponse', - 'LiveTraceCategory', - 'LiveTraceConfiguration', - 'LogSpecification', - 'ManagedIdentity', - 'ManagedIdentitySettings', - 'MetricSpecification', - 'NameAvailability', - 'NameAvailabilityParameters', - 'NetworkACL', - 'Operation', - 'OperationDisplay', - 'OperationList', - 'OperationProperties', - 'PrivateEndpoint', - 'PrivateEndpointACL', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionList', - 'PrivateLinkResource', - 'PrivateLinkResourceList', - 'PrivateLinkServiceConnectionState', - 'ProxyResource', - 'RegenerateKeyParameters', - 'Resource', - 'ResourceLogCategory', - 'ResourceLogConfiguration', - 'ResourceReference', - 'ResourceSku', - 'ServerlessUpstreamSettings', - 'ServiceSpecification', - 'ShareablePrivateLinkResourceProperties', - 'ShareablePrivateLinkResourceType', - 'SharedPrivateLinkResource', - 'SharedPrivateLinkResourceList', - 'SignalRCorsSettings', - 'SignalRFeature', - 'SignalRKeys', - 'SignalRNetworkACLs', - 'SignalRResource', - 'SignalRResourceList', - 'SignalRTlsSettings', - 'SignalRUsage', - 'SignalRUsageList', - 'SignalRUsageName', - 'Sku', - 'SkuCapacity', - 'SkuList', - 'SystemData', - 'TrackedResource', - 'UpstreamAuthSettings', - 'UpstreamTemplate', - 'UserAssignedIdentityProperty', - 'ACLAction', - 'CreatedByType', - 'FeatureFlags', - 'KeyType', - 'ManagedIdentityType', - 'PrivateLinkServiceConnectionStatus', - 'ProvisioningState', - 'ScaleType', - 'ServiceKind', - 'SharedPrivateLinkResourceStatus', - 'SignalRRequestType', - 'SignalRSkuTier', - 'UpstreamAuthType', + "CustomCertificate", + "CustomCertificateList", + "CustomDomain", + "CustomDomainList", + "Dimension", + "ErrorAdditionalInfo", + "ErrorDetail", + "ErrorResponse", + "LiveTraceCategory", + "LiveTraceConfiguration", + "LogSpecification", + "ManagedIdentity", + "ManagedIdentitySettings", + "MetricSpecification", + "NameAvailability", + "NameAvailabilityParameters", + "NetworkACL", + "Operation", + "OperationDisplay", + "OperationList", + "OperationProperties", + "PrivateEndpoint", + "PrivateEndpointACL", + "PrivateEndpointConnection", + "PrivateEndpointConnectionList", + "PrivateLinkResource", + "PrivateLinkResourceList", + "PrivateLinkServiceConnectionState", + "ProxyResource", + "RegenerateKeyParameters", + "Resource", + "ResourceLogCategory", + "ResourceLogConfiguration", + "ResourceReference", + "ResourceSku", + "ServerlessSettings", + "ServerlessUpstreamSettings", + "ServiceSpecification", + "ShareablePrivateLinkResourceProperties", + "ShareablePrivateLinkResourceType", + "SharedPrivateLinkResource", + "SharedPrivateLinkResourceList", + "SignalRCorsSettings", + "SignalRFeature", + "SignalRKeys", + "SignalRNetworkACLs", + "SignalRResource", + "SignalRResourceList", + "SignalRTlsSettings", + "SignalRUsage", + "SignalRUsageList", + "SignalRUsageName", + "Sku", + "SkuCapacity", + "SkuList", + "SystemData", + "TrackedResource", + "UpstreamAuthSettings", + "UpstreamTemplate", + "UserAssignedIdentityProperty", + "ACLAction", + "CreatedByType", + "FeatureFlags", + "KeyType", + "ManagedIdentityType", + "PrivateLinkServiceConnectionStatus", + "ProvisioningState", + "ScaleType", + "ServiceKind", + "SharedPrivateLinkResourceStatus", + "SignalRRequestType", + "SignalRSkuTier", + "UpstreamAuthType", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_models_py3.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_models_py3.py index 0c4a65d16388..116bb3f497e9 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_models_py3.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,15 +8,16 @@ # -------------------------------------------------------------------------- import datetime -from typing import Dict, List, Optional, Union +from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from .. import _serialization -from ._signal_rmanagement_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """The core properties of ARM resources. Variables are only populated by the server, and will be ignored when sending a request. @@ -29,24 +31,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -66,24 +64,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class CustomCertificate(ProxyResource): @@ -101,37 +95,36 @@ class CustomCertificate(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.signalr.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Unknown", "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", - "Moving". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". :vartype provisioning_state: str or ~azure.mgmt.signalr.models.ProvisioningState - :ivar key_vault_base_uri: Required. Base uri of the KeyVault that stores certificate. + :ivar key_vault_base_uri: Base uri of the KeyVault that stores certificate. Required. :vartype key_vault_base_uri: str - :ivar key_vault_secret_name: Required. Certificate secret name. + :ivar key_vault_secret_name: Certificate secret name. Required. :vartype key_vault_secret_name: str :ivar key_vault_secret_version: Certificate secret version. :vartype key_vault_secret_version: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'key_vault_base_uri': {'required': True}, - 'key_vault_secret_name': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "key_vault_base_uri": {"required": True}, + "key_vault_secret_name": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'key_vault_base_uri': {'key': 'properties.keyVaultBaseUri', 'type': 'str'}, - 'key_vault_secret_name': {'key': 'properties.keyVaultSecretName', 'type': 'str'}, - 'key_vault_secret_version': {'key': 'properties.keyVaultSecretVersion', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "key_vault_base_uri": {"key": "properties.keyVaultBaseUri", "type": "str"}, + "key_vault_secret_name": {"key": "properties.keyVaultSecretName", "type": "str"}, + "key_vault_secret_version": {"key": "properties.keyVaultSecretVersion", "type": "str"}, } def __init__( @@ -143,14 +136,14 @@ def __init__( **kwargs ): """ - :keyword key_vault_base_uri: Required. Base uri of the KeyVault that stores certificate. + :keyword key_vault_base_uri: Base uri of the KeyVault that stores certificate. Required. :paramtype key_vault_base_uri: str - :keyword key_vault_secret_name: Required. Certificate secret name. + :keyword key_vault_secret_name: Certificate secret name. Required. :paramtype key_vault_secret_name: str :keyword key_vault_secret_version: Certificate secret version. :paramtype key_vault_secret_version: str """ - super(CustomCertificate, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.key_vault_base_uri = key_vault_base_uri @@ -158,7 +151,7 @@ def __init__( self.key_vault_secret_version = key_vault_secret_version -class CustomCertificateList(msrest.serialization.Model): +class CustomCertificateList(_serialization.Model): """Custom certificates list. :ivar value: List of custom certificates of this resource. @@ -169,16 +162,12 @@ class CustomCertificateList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomCertificate]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CustomCertificate]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CustomCertificate"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CustomCertificate"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: List of custom certificates of this resource. @@ -188,7 +177,7 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(CustomCertificateList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -208,57 +197,50 @@ class CustomDomain(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.signalr.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Unknown", "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", - "Moving". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". :vartype provisioning_state: str or ~azure.mgmt.signalr.models.ProvisioningState - :ivar domain_name: Required. The custom domain name. + :ivar domain_name: The custom domain name. Required. :vartype domain_name: str - :ivar custom_certificate: Required. Reference to a resource. + :ivar custom_certificate: Reference to a resource. Required. :vartype custom_certificate: ~azure.mgmt.signalr.models.ResourceReference """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'domain_name': {'required': True}, - 'custom_certificate': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "domain_name": {"required": True}, + "custom_certificate": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'domain_name': {'key': 'properties.domainName', 'type': 'str'}, - 'custom_certificate': {'key': 'properties.customCertificate', 'type': 'ResourceReference'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "domain_name": {"key": "properties.domainName", "type": "str"}, + "custom_certificate": {"key": "properties.customCertificate", "type": "ResourceReference"}, } - def __init__( - self, - *, - domain_name: str, - custom_certificate: "ResourceReference", - **kwargs - ): + def __init__(self, *, domain_name: str, custom_certificate: "_models.ResourceReference", **kwargs): """ - :keyword domain_name: Required. The custom domain name. + :keyword domain_name: The custom domain name. Required. :paramtype domain_name: str - :keyword custom_certificate: Required. Reference to a resource. + :keyword custom_certificate: Reference to a resource. Required. :paramtype custom_certificate: ~azure.mgmt.signalr.models.ResourceReference """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.domain_name = domain_name self.custom_certificate = custom_certificate -class CustomDomainList(msrest.serialization.Model): +class CustomDomainList(_serialization.Model): """Custom domains list. :ivar value: List of custom domains that bind to this resource. @@ -269,16 +251,12 @@ class CustomDomainList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[CustomDomain]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[CustomDomain]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["CustomDomain"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.CustomDomain"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: List of custom domains that bind to this resource. @@ -288,12 +266,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(CustomDomainList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Specifications of the Dimension of metrics. :ivar name: The public facing name of the dimension. @@ -308,10 +286,10 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'internal_name': {'key': 'internalName', 'type': 'str'}, - 'to_be_exported_for_shoebox': {'key': 'toBeExportedForShoebox', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "internal_name": {"key": "internalName", "type": "str"}, + "to_be_exported_for_shoebox": {"key": "toBeExportedForShoebox", "type": "bool"}, } def __init__( @@ -334,14 +312,14 @@ def __init__( included for the shoebox export scenario. :paramtype to_be_exported_for_shoebox: bool """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.internal_name = internal_name self.to_be_exported_for_shoebox = to_be_exported_for_shoebox -class ErrorAdditionalInfo(msrest.serialization.Model): +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. @@ -349,31 +327,27 @@ class ErrorAdditionalInfo(msrest.serialization.Model): :ivar type: The additional info type. :vartype type: str :ivar info: The additional info. - :vartype info: any + :vartype info: JSON """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, + "type": {"key": "type", "type": "str"}, + "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ErrorAdditionalInfo, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.type = None self.info = None -class ErrorDetail(msrest.serialization.Model): +class ErrorDetail(_serialization.Model): """The error detail. Variables are only populated by the server, and will be ignored when sending a request. @@ -391,28 +365,24 @@ class ErrorDetail(msrest.serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "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]'}, + "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 - ): - """ - """ - super(ErrorDetail, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.code = None self.message = None self.target = None @@ -420,7 +390,7 @@ def __init__( self.additional_info = None -class ErrorResponse(msrest.serialization.Model): +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. @@ -428,24 +398,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, + "error": {"key": "error", "type": "ErrorDetail"}, } - def __init__( - self, - *, - error: Optional["ErrorDetail"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorDetail"] = None, **kwargs): """ :keyword error: The error object. :paramtype error: ~azure.mgmt.signalr.models.ErrorDetail """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class LiveTraceCategory(msrest.serialization.Model): +class LiveTraceCategory(_serialization.Model): """Live trace category configuration of a Microsoft.SignalRService resource. :ivar name: Gets or sets the live trace category's name. @@ -459,17 +424,11 @@ class LiveTraceCategory(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "enabled": {"key": "enabled", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - enabled: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, enabled: Optional[str] = None, **kwargs): """ :keyword name: Gets or sets the live trace category's name. Available values: ConnectivityLogs, MessagingLogs. @@ -480,12 +439,12 @@ def __init__( Case insensitive. :paramtype enabled: str """ - super(LiveTraceCategory, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.enabled = enabled -class LiveTraceConfiguration(msrest.serialization.Model): +class LiveTraceConfiguration(_serialization.Model): """Live trace configuration of a Microsoft.SignalRService resource. :ivar enabled: Indicates whether or not enable live trace. @@ -500,16 +459,12 @@ class LiveTraceConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'str'}, - 'categories': {'key': 'categories', 'type': '[LiveTraceCategory]'}, + "enabled": {"key": "enabled", "type": "str"}, + "categories": {"key": "categories", "type": "[LiveTraceCategory]"}, } def __init__( - self, - *, - enabled: Optional[str] = "false", - categories: Optional[List["LiveTraceCategory"]] = None, - **kwargs + self, *, enabled: str = "false", categories: Optional[List["_models.LiveTraceCategory"]] = None, **kwargs ): """ :keyword enabled: Indicates whether or not enable live trace. @@ -522,12 +477,12 @@ def __init__( :keyword categories: Gets or sets the list of category configurations. :paramtype categories: list[~azure.mgmt.signalr.models.LiveTraceCategory] """ - super(LiveTraceConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.categories = categories -class LogSpecification(msrest.serialization.Model): +class LogSpecification(_serialization.Model): """Specifications of the Logs for Azure Monitoring. :ivar name: Name of the log. @@ -537,35 +492,29 @@ class LogSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Name of the log. :paramtype name: str :keyword display_name: Localized friendly display name of the log. :paramtype display_name: str """ - super(LogSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class ManagedIdentity(msrest.serialization.Model): +class ManagedIdentity(_serialization.Model): """A class represent managed identities used for request and response. Variables are only populated by the server, and will be ignored when sending a request. - :ivar type: Represents the identity type: systemAssigned, userAssigned, None. Possible values - include: "None", "SystemAssigned", "UserAssigned". + :ivar type: Represents the identity type: systemAssigned, userAssigned, None. Known values are: + "None", "SystemAssigned", and "UserAssigned". :vartype type: str or ~azure.mgmt.signalr.models.ManagedIdentityType :ivar user_assigned_identities: Get or set the user assigned identities. :vartype user_assigned_identities: dict[str, @@ -579,40 +528,40 @@ class ManagedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentityProperty}'}, - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentityProperty}"}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, } def __init__( self, *, - type: Optional[Union[str, "ManagedIdentityType"]] = None, - user_assigned_identities: Optional[Dict[str, "UserAssignedIdentityProperty"]] = None, + type: Optional[Union[str, "_models.ManagedIdentityType"]] = None, + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentityProperty"]] = None, **kwargs ): """ - :keyword type: Represents the identity type: systemAssigned, userAssigned, None. Possible - values include: "None", "SystemAssigned", "UserAssigned". + :keyword type: Represents the identity type: systemAssigned, userAssigned, None. Known values + are: "None", "SystemAssigned", and "UserAssigned". :paramtype type: str or ~azure.mgmt.signalr.models.ManagedIdentityType :keyword user_assigned_identities: Get or set the user assigned identities. :paramtype user_assigned_identities: dict[str, ~azure.mgmt.signalr.models.UserAssignedIdentityProperty] """ - super(ManagedIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.user_assigned_identities = user_assigned_identities self.principal_id = None self.tenant_id = None -class ManagedIdentitySettings(msrest.serialization.Model): +class ManagedIdentitySettings(_serialization.Model): """Managed identity settings for upstream. :ivar resource: The Resource indicating the App ID URI of the target resource. @@ -621,25 +570,20 @@ class ManagedIdentitySettings(msrest.serialization.Model): """ _attribute_map = { - 'resource': {'key': 'resource', 'type': 'str'}, + "resource": {"key": "resource", "type": "str"}, } - def __init__( - self, - *, - resource: Optional[str] = None, - **kwargs - ): + def __init__(self, *, resource: Optional[str] = None, **kwargs): """ :keyword resource: The Resource indicating the App ID URI of the target resource. It also appears in the aud (audience) claim of the issued token. :paramtype resource: str """ - super(ManagedIdentitySettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.resource = resource -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Specifications of the Metrics for Azure Monitoring. :ivar name: Name of the metric. @@ -668,14 +612,14 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'str'}, - 'category': {'key': 'category', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "str"}, + "category": {"key": "category", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, } def __init__( @@ -688,7 +632,7 @@ def __init__( aggregation_type: Optional[str] = None, fill_gap_with_zero: Optional[str] = None, category: Optional[str] = None, - dimensions: Optional[List["Dimension"]] = None, + dimensions: Optional[List["_models.Dimension"]] = None, **kwargs ): """ @@ -716,7 +660,7 @@ def __init__( :keyword dimensions: The dimensions of the metrics. :paramtype dimensions: list[~azure.mgmt.signalr.models.Dimension] """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -727,7 +671,7 @@ def __init__( self.dimensions = dimensions -class NameAvailability(msrest.serialization.Model): +class NameAvailability(_serialization.Model): """Result of the request to check name availability. It contains a flag and possible reason of failure. :ivar name_available: Indicates whether the name is available or not. @@ -739,9 +683,9 @@ class NameAvailability(msrest.serialization.Model): """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( @@ -760,54 +704,48 @@ def __init__( :keyword message: The message of the operation. :paramtype message: str """ - super(NameAvailability, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class NameAvailabilityParameters(msrest.serialization.Model): +class NameAvailabilityParameters(_serialization.Model): """Data POST-ed to the nameAvailability action. All required parameters must be populated in order to send to Azure. - :ivar type: Required. The resource type. Can be "Microsoft.SignalRService/SignalR" or - "Microsoft.SignalRService/webPubSub". + :ivar type: The resource type. Can be "Microsoft.SignalRService/SignalR" or + "Microsoft.SignalRService/webPubSub". Required. :vartype type: str - :ivar name: Required. The resource name to validate. e.g."my-resource-name". + :ivar name: The resource name to validate. e.g."my-resource-name". Required. :vartype name: str """ _validation = { - 'type': {'required': True}, - 'name': {'required': True}, + "type": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "name": {"key": "name", "type": "str"}, } - def __init__( - self, - *, - type: str, - name: str, - **kwargs - ): + def __init__(self, *, type: str, name: str, **kwargs): """ - :keyword type: Required. The resource type. Can be "Microsoft.SignalRService/SignalR" or - "Microsoft.SignalRService/webPubSub". + :keyword type: The resource type. Can be "Microsoft.SignalRService/SignalR" or + "Microsoft.SignalRService/webPubSub". Required. :paramtype type: str - :keyword name: Required. The resource name to validate. e.g."my-resource-name". + :keyword name: The resource name to validate. e.g."my-resource-name". Required. :paramtype name: str """ - super(NameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.name = name -class NetworkACL(msrest.serialization.Model): +class NetworkACL(_serialization.Model): """Network ACL. :ivar allow: Allowed request types. The value can be one or more of: ClientConnection, @@ -819,15 +757,15 @@ class NetworkACL(msrest.serialization.Model): """ _attribute_map = { - 'allow': {'key': 'allow', 'type': '[str]'}, - 'deny': {'key': 'deny', 'type': '[str]'}, + "allow": {"key": "allow", "type": "[str]"}, + "deny": {"key": "deny", "type": "[str]"}, } def __init__( self, *, - allow: Optional[List[Union[str, "SignalRRequestType"]]] = None, - deny: Optional[List[Union[str, "SignalRRequestType"]]] = None, + allow: Optional[List[Union[str, "_models.SignalRRequestType"]]] = None, + deny: Optional[List[Union[str, "_models.SignalRRequestType"]]] = None, **kwargs ): """ @@ -838,12 +776,12 @@ def __init__( ServerConnection, RESTAPI. :paramtype deny: list[str or ~azure.mgmt.signalr.models.SignalRRequestType] """ - super(NetworkACL, self).__init__(**kwargs) + super().__init__(**kwargs) self.allow = allow self.deny = deny -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """REST API operation supported by resource provider. :ivar name: Name of the operation with format: {provider}/{resource}/{operation}. @@ -860,11 +798,11 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'OperationProperties'}, + "name": {"key": "name", "type": "str"}, + "is_data_action": {"key": "isDataAction", "type": "bool"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "properties": {"key": "properties", "type": "OperationProperties"}, } def __init__( @@ -872,9 +810,9 @@ def __init__( *, name: Optional[str] = None, is_data_action: Optional[bool] = None, - display: Optional["OperationDisplay"] = None, + display: Optional["_models.OperationDisplay"] = None, origin: Optional[str] = None, - properties: Optional["OperationProperties"] = None, + properties: Optional["_models.OperationProperties"] = None, **kwargs ): """ @@ -890,7 +828,7 @@ def __init__( :keyword properties: Extra Operation properties. :paramtype properties: ~azure.mgmt.signalr.models.OperationProperties """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.is_data_action = is_data_action self.display = display @@ -898,7 +836,7 @@ def __init__( self.properties = properties -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """The object that describes a operation. :ivar provider: Friendly name of the resource provider. @@ -912,10 +850,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -937,14 +875,14 @@ def __init__( :keyword description: The localized friendly description for the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationList(msrest.serialization.Model): +class OperationList(_serialization.Model): """Result of the request to list REST API operations. It contains a list of operations. :ivar value: List of operations supported by the resource provider. @@ -955,17 +893,11 @@ class OperationList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Operation]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["Operation"]] = None, - next_link: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, next_link: Optional[str] = None, **kwargs): """ :keyword value: List of operations supported by the resource provider. :paramtype value: list[~azure.mgmt.signalr.models.Operation] @@ -974,12 +906,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(OperationList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class OperationProperties(msrest.serialization.Model): +class OperationProperties(_serialization.Model): """Extra Operation properties. :ivar service_specification: An object that describes a specification. @@ -987,24 +919,19 @@ class OperationProperties(msrest.serialization.Model): """ _attribute_map = { - 'service_specification': {'key': 'serviceSpecification', 'type': 'ServiceSpecification'}, + "service_specification": {"key": "serviceSpecification", "type": "ServiceSpecification"}, } - def __init__( - self, - *, - service_specification: Optional["ServiceSpecification"] = None, - **kwargs - ): + def __init__(self, *, service_specification: Optional["_models.ServiceSpecification"] = None, **kwargs): """ :keyword service_specification: An object that describes a specification. :paramtype service_specification: ~azure.mgmt.signalr.models.ServiceSpecification """ - super(OperationProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.service_specification = service_specification -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """Private endpoint. :ivar id: Full qualified Id of the private endpoint. @@ -1012,20 +939,15 @@ class PrivateEndpoint(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Full qualified Id of the private endpoint. :paramtype id: str """ - super(PrivateEndpoint, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id @@ -1040,26 +962,26 @@ class PrivateEndpointACL(NetworkACL): :ivar deny: Denied request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. :vartype deny: list[str or ~azure.mgmt.signalr.models.SignalRRequestType] - :ivar name: Required. Name of the private endpoint connection. + :ivar name: Name of the private endpoint connection. Required. :vartype name: str """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'allow': {'key': 'allow', 'type': '[str]'}, - 'deny': {'key': 'deny', 'type': '[str]'}, - 'name': {'key': 'name', 'type': 'str'}, + "allow": {"key": "allow", "type": "[str]"}, + "deny": {"key": "deny", "type": "[str]"}, + "name": {"key": "name", "type": "str"}, } def __init__( self, *, name: str, - allow: Optional[List[Union[str, "SignalRRequestType"]]] = None, - deny: Optional[List[Union[str, "SignalRRequestType"]]] = None, + allow: Optional[List[Union[str, "_models.SignalRRequestType"]]] = None, + deny: Optional[List[Union[str, "_models.SignalRRequestType"]]] = None, **kwargs ): """ @@ -1069,10 +991,10 @@ def __init__( :keyword deny: Denied request types. The value can be one or more of: ClientConnection, ServerConnection, RESTAPI. :paramtype deny: list[str or ~azure.mgmt.signalr.models.SignalRRequestType] - :keyword name: Required. Name of the private endpoint connection. + :keyword name: Name of the private endpoint connection. Required. :paramtype name: str """ - super(PrivateEndpointACL, self).__init__(allow=allow, deny=deny, **kwargs) + super().__init__(allow=allow, deny=deny, **kwargs) self.name = name @@ -1089,9 +1011,8 @@ class PrivateEndpointConnection(ProxyResource): :vartype type: str :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.signalr.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Unknown", "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", - "Moving". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". :vartype provisioning_state: str or ~azure.mgmt.signalr.models.ProvisioningState :ivar private_endpoint: Private endpoint. :vartype private_endpoint: ~azure.mgmt.signalr.models.PrivateEndpoint @@ -1104,30 +1025,33 @@ class PrivateEndpointConnection(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'group_ids': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "group_ids": {"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'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'group_ids': {'key': 'properties.groupIds', 'type': '[str]'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "group_ids": {"key": "properties.groupIds", "type": "[str]"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, } def __init__( self, *, - private_endpoint: Optional["PrivateEndpoint"] = None, - private_link_service_connection_state: Optional["PrivateLinkServiceConnectionState"] = None, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, **kwargs ): """ @@ -1138,7 +1062,7 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.signalr.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.provisioning_state = None self.private_endpoint = private_endpoint @@ -1146,7 +1070,7 @@ def __init__( self.private_link_service_connection_state = private_link_service_connection_state -class PrivateEndpointConnectionList(msrest.serialization.Model): +class PrivateEndpointConnectionList(_serialization.Model): """A list of private endpoint connections. :ivar value: The list of the private endpoint connections. @@ -1158,14 +1082,14 @@ class PrivateEndpointConnectionList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["PrivateEndpointConnection"]] = None, + value: Optional[List["_models.PrivateEndpointConnection"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1177,7 +1101,7 @@ def __init__( maximum page size. :paramtype next_link: str """ - super(PrivateEndpointConnectionList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link @@ -1206,19 +1130,22 @@ class PrivateLinkResource(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, - 'shareable_private_link_resource_types': {'key': 'properties.shareablePrivateLinkResourceTypes', 'type': '[ShareablePrivateLinkResourceType]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "required_members": {"key": "properties.requiredMembers", "type": "[str]"}, + "required_zone_names": {"key": "properties.requiredZoneNames", "type": "[str]"}, + "shareable_private_link_resource_types": { + "key": "properties.shareablePrivateLinkResourceTypes", + "type": "[ShareablePrivateLinkResourceType]", + }, } def __init__( @@ -1227,7 +1154,7 @@ def __init__( group_id: Optional[str] = None, required_members: Optional[List[str]] = None, required_zone_names: Optional[List[str]] = None, - shareable_private_link_resource_types: Optional[List["ShareablePrivateLinkResourceType"]] = None, + shareable_private_link_resource_types: Optional[List["_models.ShareablePrivateLinkResourceType"]] = None, **kwargs ): """ @@ -1242,14 +1169,14 @@ def __init__( :paramtype shareable_private_link_resource_types: list[~azure.mgmt.signalr.models.ShareablePrivateLinkResourceType] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = group_id self.required_members = required_members self.required_zone_names = required_zone_names self.shareable_private_link_resource_types = shareable_private_link_resource_types -class PrivateLinkResourceList(msrest.serialization.Model): +class PrivateLinkResourceList(_serialization.Model): """Contains a list of PrivateLinkResource and a possible link to query more results. :ivar value: List of PrivateLinkResource. @@ -1260,16 +1187,12 @@ class PrivateLinkResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["PrivateLinkResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: List of PrivateLinkResource. @@ -1279,16 +1202,16 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(PrivateLinkResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """Connection state of the private endpoint connection. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". + of the service. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". :vartype status: str or ~azure.mgmt.signalr.models.PrivateLinkServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. :vartype description: str @@ -1298,23 +1221,22 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'actions_required': {'key': 'actionsRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "actions_required": {"key": "actionsRequired", "type": "str"}, } def __init__( self, *, - status: Optional[Union[str, "PrivateLinkServiceConnectionStatus"]] = None, + status: Optional[Union[str, "_models.PrivateLinkServiceConnectionStatus"]] = None, description: Optional[str] = None, actions_required: Optional[str] = None, **kwargs ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Possible values include: "Pending", "Approved", "Rejected", - "Disconnected". + owner of the service. Known values are: "Pending", "Approved", "Rejected", and "Disconnected". :paramtype status: str or ~azure.mgmt.signalr.models.PrivateLinkServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. :paramtype description: str @@ -1322,40 +1244,34 @@ def __init__( updates on the consumer. :paramtype actions_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.actions_required = actions_required -class RegenerateKeyParameters(msrest.serialization.Model): +class RegenerateKeyParameters(_serialization.Model): """Parameters describes the request to regenerate access keys. - :ivar key_type: The type of access key. Possible values include: "Primary", "Secondary", - "Salt". + :ivar key_type: The type of access key. Known values are: "Primary", "Secondary", and "Salt". :vartype key_type: str or ~azure.mgmt.signalr.models.KeyType """ _attribute_map = { - 'key_type': {'key': 'keyType', 'type': 'str'}, + "key_type": {"key": "keyType", "type": "str"}, } - def __init__( - self, - *, - key_type: Optional[Union[str, "KeyType"]] = None, - **kwargs - ): + def __init__(self, *, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs): """ - :keyword key_type: The type of access key. Possible values include: "Primary", "Secondary", + :keyword key_type: The type of access key. Known values are: "Primary", "Secondary", and "Salt". :paramtype key_type: str or ~azure.mgmt.signalr.models.KeyType """ - super(RegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_type = key_type -class ResourceLogCategory(msrest.serialization.Model): +class ResourceLogCategory(_serialization.Model): """Resource log category configuration of a Microsoft.SignalRService resource. :ivar name: Gets or sets the resource log category's name. @@ -1369,17 +1285,11 @@ class ResourceLogCategory(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'enabled': {'key': 'enabled', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "enabled": {"key": "enabled", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - enabled: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, enabled: Optional[str] = None, **kwargs): """ :keyword name: Gets or sets the resource log category's name. Available values: ConnectivityLogs, MessagingLogs. @@ -1390,12 +1300,12 @@ def __init__( Case insensitive. :paramtype enabled: str """ - super(ResourceLogCategory, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.enabled = enabled -class ResourceLogConfiguration(msrest.serialization.Model): +class ResourceLogConfiguration(_serialization.Model): """Resource log configuration of a Microsoft.SignalRService resource. :ivar categories: Gets or sets the list of category configurations. @@ -1403,24 +1313,19 @@ class ResourceLogConfiguration(msrest.serialization.Model): """ _attribute_map = { - 'categories': {'key': 'categories', 'type': '[ResourceLogCategory]'}, + "categories": {"key": "categories", "type": "[ResourceLogCategory]"}, } - def __init__( - self, - *, - categories: Optional[List["ResourceLogCategory"]] = None, - **kwargs - ): + def __init__(self, *, categories: Optional[List["_models.ResourceLogCategory"]] = None, **kwargs): """ :keyword categories: Gets or sets the list of category configurations. :paramtype categories: list[~azure.mgmt.signalr.models.ResourceLogCategory] """ - super(ResourceLogConfiguration, self).__init__(**kwargs) + super().__init__(**kwargs) self.categories = categories -class ResourceReference(msrest.serialization.Model): +class ResourceReference(_serialization.Model): """Reference to a resource. :ivar id: Resource ID. @@ -1428,91 +1333,88 @@ class ResourceReference(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Resource ID. :paramtype id: str """ - super(ResourceReference, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id -class ResourceSku(msrest.serialization.Model): +class ResourceSku(_serialization.Model): """The billing information of the resource. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The name of the SKU. Required. - - Allowed values: Standard_S1, Free_F1. + :ivar name: The name of the SKU. Required. + + Allowed values: Standard_S1, Free_F1, Premium_P1. Required. :vartype name: str :ivar tier: Optional tier of this particular SKU. 'Standard' or 'Free'. - - ``Basic`` is deprecated, use ``Standard`` instead. Possible values include: "Free", "Basic", - "Standard", "Premium". + + ``Basic`` is deprecated, use ``Standard`` instead. Known values are: "Free", "Basic", + "Standard", and "Premium". :vartype tier: str or ~azure.mgmt.signalr.models.SignalRSkuTier :ivar size: Not used. Retained for future use. :vartype size: str :ivar family: Not used. Retained for future use. :vartype family: str :ivar capacity: Optional, integer. The unit count of the resource. 1 by default. - + If present, following values are allowed: - Free: 1 - Standard: 1,2,5,10,20,50,100. + Free: 1; + Standard: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100;. :vartype capacity: int """ _validation = { - 'name': {'required': True}, - 'size': {'readonly': True}, - 'family': {'readonly': True}, + "name": {"required": True}, + "size": {"readonly": True}, + "family": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'size': {'key': 'size', 'type': 'str'}, - 'family': {'key': 'family', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'int'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "size": {"key": "size", "type": "str"}, + "family": {"key": "family", "type": "str"}, + "capacity": {"key": "capacity", "type": "int"}, } def __init__( self, *, name: str, - tier: Optional[Union[str, "SignalRSkuTier"]] = None, + tier: Optional[Union[str, "_models.SignalRSkuTier"]] = None, capacity: Optional[int] = None, **kwargs ): """ - :keyword name: Required. The name of the SKU. Required. - - Allowed values: Standard_S1, Free_F1. + :keyword name: The name of the SKU. Required. + + Allowed values: Standard_S1, Free_F1, Premium_P1. Required. :paramtype name: str :keyword tier: Optional tier of this particular SKU. 'Standard' or 'Free'. - - ``Basic`` is deprecated, use ``Standard`` instead. Possible values include: "Free", "Basic", - "Standard", "Premium". + + ``Basic`` is deprecated, use ``Standard`` instead. Known values are: "Free", "Basic", + "Standard", and "Premium". :paramtype tier: str or ~azure.mgmt.signalr.models.SignalRSkuTier :keyword capacity: Optional, integer. The unit count of the resource. 1 by default. - + If present, following values are allowed: - Free: 1 - Standard: 1,2,5,10,20,50,100. + Free: 1; + Standard: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100; + Premium: 1,2,3,4,5,6,7,8,9,10,20,30,40,50,60,70,80,90,100;. :paramtype capacity: int """ - super(ResourceSku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = tier self.size = None @@ -1520,7 +1422,53 @@ def __init__( self.capacity = capacity -class ServerlessUpstreamSettings(msrest.serialization.Model): +class ServerlessSettings(_serialization.Model): + """Serverless settings. + + :ivar connection_timeout_in_seconds: Gets or sets Client Connection Timeout. Optional to be + set. + Value in seconds. + Default value is 30 seconds. + Customer should set the timeout to a shorter period if messages are expected to be sent in + shorter intervals, + and want the client to disconnect more quickly after the last message is sent. + You can set the timeout to a longer period if messages are expected to be sent in longer + intervals, + and they want to keep the same client connection alive during this session. + The service considers the client disconnected if it hasn't received a message (including + keep-alive) in this interval. + :vartype connection_timeout_in_seconds: int + """ + + _validation = { + "connection_timeout_in_seconds": {"maximum": 120, "minimum": 1}, + } + + _attribute_map = { + "connection_timeout_in_seconds": {"key": "connectionTimeoutInSeconds", "type": "int"}, + } + + def __init__(self, *, connection_timeout_in_seconds: int = 30, **kwargs): + """ + :keyword connection_timeout_in_seconds: Gets or sets Client Connection Timeout. Optional to be + set. + Value in seconds. + Default value is 30 seconds. + Customer should set the timeout to a shorter period if messages are expected to be sent in + shorter intervals, + and want the client to disconnect more quickly after the last message is sent. + You can set the timeout to a longer period if messages are expected to be sent in longer + intervals, + and they want to keep the same client connection alive during this session. + The service considers the client disconnected if it hasn't received a message (including + keep-alive) in this interval. + :paramtype connection_timeout_in_seconds: int + """ + super().__init__(**kwargs) + self.connection_timeout_in_seconds = connection_timeout_in_seconds + + +class ServerlessUpstreamSettings(_serialization.Model): """The settings for the Upstream when the service is in server-less mode. :ivar templates: Gets or sets the list of Upstream URL templates. Order matters, and the first @@ -1529,25 +1477,20 @@ class ServerlessUpstreamSettings(msrest.serialization.Model): """ _attribute_map = { - 'templates': {'key': 'templates', 'type': '[UpstreamTemplate]'}, + "templates": {"key": "templates", "type": "[UpstreamTemplate]"}, } - def __init__( - self, - *, - templates: Optional[List["UpstreamTemplate"]] = None, - **kwargs - ): + def __init__(self, *, templates: Optional[List["_models.UpstreamTemplate"]] = None, **kwargs): """ :keyword templates: Gets or sets the list of Upstream URL templates. Order matters, and the first matching template takes effects. :paramtype templates: list[~azure.mgmt.signalr.models.UpstreamTemplate] """ - super(ServerlessUpstreamSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.templates = templates -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """An object that describes a specification. :ivar metric_specifications: Specifications of the Metrics for Azure Monitoring. @@ -1557,15 +1500,15 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, - 'log_specifications': {'key': 'logSpecifications', 'type': '[LogSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, + "log_specifications": {"key": "logSpecifications", "type": "[LogSpecification]"}, } def __init__( self, *, - metric_specifications: Optional[List["MetricSpecification"]] = None, - log_specifications: Optional[List["LogSpecification"]] = None, + metric_specifications: Optional[List["_models.MetricSpecification"]] = None, + log_specifications: Optional[List["_models.LogSpecification"]] = None, **kwargs ): """ @@ -1574,12 +1517,12 @@ def __init__( :keyword log_specifications: Specifications of the Logs for Azure Monitoring. :paramtype log_specifications: list[~azure.mgmt.signalr.models.LogSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications self.log_specifications = log_specifications -class ShareablePrivateLinkResourceProperties(msrest.serialization.Model): +class ShareablePrivateLinkResourceProperties(_serialization.Model): """Describes the properties of a resource type that has been onboarded to private link service. :ivar description: The description of the resource type that has been onboarded to private link @@ -1594,18 +1537,13 @@ class ShareablePrivateLinkResourceProperties(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'group_id': {'key': 'groupId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "group_id": {"key": "groupId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( - self, - *, - description: Optional[str] = None, - group_id: Optional[str] = None, - type: Optional[str] = None, - **kwargs + self, *, description: Optional[str] = None, group_id: Optional[str] = None, type: Optional[str] = None, **kwargs ): """ :keyword description: The description of the resource type that has been onboarded to private @@ -1618,13 +1556,13 @@ def __init__( link service. :paramtype type: str """ - super(ShareablePrivateLinkResourceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.group_id = group_id self.type = type -class ShareablePrivateLinkResourceType(msrest.serialization.Model): +class ShareablePrivateLinkResourceType(_serialization.Model): """Describes a resource type that has been onboarded to private link service. :ivar name: The name of the resource type that has been onboarded to private link service. @@ -1635,15 +1573,15 @@ class ShareablePrivateLinkResourceType(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ShareablePrivateLinkResourceProperties'}, + "name": {"key": "name", "type": "str"}, + "properties": {"key": "properties", "type": "ShareablePrivateLinkResourceProperties"}, } def __init__( self, *, name: Optional[str] = None, - properties: Optional["ShareablePrivateLinkResourceProperties"] = None, + properties: Optional["_models.ShareablePrivateLinkResourceProperties"] = None, **kwargs ): """ @@ -1653,7 +1591,7 @@ def __init__( private link service. :paramtype properties: ~azure.mgmt.signalr.models.ShareablePrivateLinkResourceProperties """ - super(ShareablePrivateLinkResourceType, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.properties = properties @@ -1677,37 +1615,36 @@ class SharedPrivateLinkResource(ProxyResource): :ivar private_link_resource_id: The resource id of the resource the shared private link resource is for. :vartype private_link_resource_id: str - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Unknown", "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", - "Moving". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". :vartype provisioning_state: str or ~azure.mgmt.signalr.models.ProvisioningState :ivar request_message: The request message for requesting approval of the shared private link resource. :vartype request_message: str - :ivar status: Status of the shared private link resource. Possible values include: "Pending", - "Approved", "Rejected", "Disconnected", "Timeout". + :ivar status: Status of the shared private link resource. Known values are: "Pending", + "Approved", "Rejected", "Disconnected", and "Timeout". :vartype status: str or ~azure.mgmt.signalr.models.SharedPrivateLinkResourceStatus """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "status": {"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'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'private_link_resource_id': {'key': 'properties.privateLinkResourceId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'request_message': {'key': 'properties.requestMessage', 'type': 'str'}, - 'status': {'key': 'properties.status', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "group_id": {"key": "properties.groupId", "type": "str"}, + "private_link_resource_id": {"key": "properties.privateLinkResourceId", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "request_message": {"key": "properties.requestMessage", "type": "str"}, + "status": {"key": "properties.status", "type": "str"}, } def __init__( @@ -1729,7 +1666,7 @@ def __init__( link resource. :paramtype request_message: str """ - super(SharedPrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.group_id = group_id self.private_link_resource_id = private_link_resource_id @@ -1738,7 +1675,7 @@ def __init__( self.status = None -class SharedPrivateLinkResourceList(msrest.serialization.Model): +class SharedPrivateLinkResourceList(_serialization.Model): """A list of shared private link resources. :ivar value: The list of the shared private link resources. @@ -1750,14 +1687,14 @@ class SharedPrivateLinkResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedPrivateLinkResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SharedPrivateLinkResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( self, *, - value: Optional[List["SharedPrivateLinkResource"]] = None, + value: Optional[List["_models.SharedPrivateLinkResource"]] = None, next_link: Optional[str] = None, **kwargs ): @@ -1769,12 +1706,12 @@ def __init__( maximum page size. :paramtype next_link: str """ - super(SharedPrivateLinkResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SignalRCorsSettings(msrest.serialization.Model): +class SignalRCorsSettings(_serialization.Model): """Cross-Origin Resource Sharing (CORS) settings. :ivar allowed_origins: Gets or sets the list of origins that should be allowed to make @@ -1784,33 +1721,28 @@ class SignalRCorsSettings(msrest.serialization.Model): """ _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, } - def __init__( - self, - *, - allowed_origins: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, allowed_origins: Optional[List[str]] = None, **kwargs): """ :keyword allowed_origins: Gets or sets the list of origins that should be allowed to make cross-origin calls (for example: http://example.com:12345). Use "*" to allow all. If omitted, allow all by default. :paramtype allowed_origins: list[str] """ - super(SignalRCorsSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins -class SignalRFeature(msrest.serialization.Model): +class SignalRFeature(_serialization.Model): """Feature of a resource, which controls the runtime behavior. All required parameters must be populated in order to send to Azure. - :ivar flag: Required. FeatureFlags is the supported features of Azure SignalR service. - - + :ivar flag: FeatureFlags is the supported features of Azure SignalR service. + + * ServiceMode: Flag for backend server for SignalR service. Values allowed: "Default": have your own backend server; "Serverless": your application doesn't have a backend server; "Classic": for backward compatibility. Support both Default and Serverless mode but not @@ -1823,39 +1755,39 @@ class SignalRFeature(msrest.serialization.Model): service, it will give you live traces in real time, it will be helpful when you developing your own Azure SignalR based web application or self-troubleshooting some issues. Please note that live traces are counted as outbound messages that will be charged. Values allowed: - "true"/"false", to enable/disable live trace feature. Possible values include: "ServiceMode", - "EnableConnectivityLogs", "EnableMessagingLogs", "EnableLiveTrace". + "true"/"false", to enable/disable live trace feature. Required. Known values are: + "ServiceMode", "EnableConnectivityLogs", "EnableMessagingLogs", and "EnableLiveTrace". :vartype flag: str or ~azure.mgmt.signalr.models.FeatureFlags - :ivar value: Required. Value of the feature flag. See Azure SignalR service document - https://docs.microsoft.com/azure/azure-signalr/ for allowed values. + :ivar value: Value of the feature flag. See Azure SignalR service document + https://docs.microsoft.com/azure/azure-signalr/ for allowed values. Required. :vartype value: str :ivar properties: Optional properties related to this feature. :vartype properties: dict[str, str] """ _validation = { - 'flag': {'required': True}, - 'value': {'required': True, 'max_length': 128, 'min_length': 1}, + "flag": {"required": True}, + "value": {"required": True, "max_length": 128, "min_length": 1}, } _attribute_map = { - 'flag': {'key': 'flag', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': '{str}'}, + "flag": {"key": "flag", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "properties": {"key": "properties", "type": "{str}"}, } def __init__( self, *, - flag: Union[str, "FeatureFlags"], + flag: Union[str, "_models.FeatureFlags"], value: str, properties: Optional[Dict[str, str]] = None, **kwargs ): """ - :keyword flag: Required. FeatureFlags is the supported features of Azure SignalR service. - - + :keyword flag: FeatureFlags is the supported features of Azure SignalR service. + + * ServiceMode: Flag for backend server for SignalR service. Values allowed: "Default": have your own backend server; "Serverless": your application doesn't have a backend server; "Classic": for backward compatibility. Support both Default and Serverless mode but not @@ -1868,22 +1800,22 @@ def __init__( service, it will give you live traces in real time, it will be helpful when you developing your own Azure SignalR based web application or self-troubleshooting some issues. Please note that live traces are counted as outbound messages that will be charged. Values allowed: - "true"/"false", to enable/disable live trace feature. Possible values include: "ServiceMode", - "EnableConnectivityLogs", "EnableMessagingLogs", "EnableLiveTrace". + "true"/"false", to enable/disable live trace feature. Required. Known values are: + "ServiceMode", "EnableConnectivityLogs", "EnableMessagingLogs", and "EnableLiveTrace". :paramtype flag: str or ~azure.mgmt.signalr.models.FeatureFlags - :keyword value: Required. Value of the feature flag. See Azure SignalR service document - https://docs.microsoft.com/azure/azure-signalr/ for allowed values. + :keyword value: Value of the feature flag. See Azure SignalR service document + https://docs.microsoft.com/azure/azure-signalr/ for allowed values. Required. :paramtype value: str :keyword properties: Optional properties related to this feature. :paramtype properties: dict[str, str] """ - super(SignalRFeature, self).__init__(**kwargs) + super().__init__(**kwargs) self.flag = flag self.value = value self.properties = properties -class SignalRKeys(msrest.serialization.Model): +class SignalRKeys(_serialization.Model): """A class represents the access keys of the resource. :ivar primary_key: The primary access key. @@ -1897,10 +1829,10 @@ class SignalRKeys(msrest.serialization.Model): """ _attribute_map = { - 'primary_key': {'key': 'primaryKey', 'type': 'str'}, - 'secondary_key': {'key': 'secondaryKey', 'type': 'str'}, - 'primary_connection_string': {'key': 'primaryConnectionString', 'type': 'str'}, - 'secondary_connection_string': {'key': 'secondaryConnectionString', 'type': 'str'}, + "primary_key": {"key": "primaryKey", "type": "str"}, + "secondary_key": {"key": "secondaryKey", "type": "str"}, + "primary_connection_string": {"key": "primaryConnectionString", "type": "str"}, + "secondary_connection_string": {"key": "secondaryConnectionString", "type": "str"}, } def __init__( @@ -1922,17 +1854,17 @@ def __init__( :keyword secondary_connection_string: Connection string constructed via the secondaryKey. :paramtype secondary_connection_string: str """ - super(SignalRKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.primary_key = primary_key self.secondary_key = secondary_key self.primary_connection_string = primary_connection_string self.secondary_connection_string = secondary_connection_string -class SignalRNetworkACLs(msrest.serialization.Model): +class SignalRNetworkACLs(_serialization.Model): """Network ACLs for the resource. - :ivar default_action: Azure Networking ACL Action. Possible values include: "Allow", "Deny". + :ivar default_action: Azure Networking ACL Action. Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.signalr.models.ACLAction :ivar public_network: Network ACL. :vartype public_network: ~azure.mgmt.signalr.models.NetworkACL @@ -1941,28 +1873,28 @@ class SignalRNetworkACLs(msrest.serialization.Model): """ _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'public_network': {'key': 'publicNetwork', 'type': 'NetworkACL'}, - 'private_endpoints': {'key': 'privateEndpoints', 'type': '[PrivateEndpointACL]'}, + "default_action": {"key": "defaultAction", "type": "str"}, + "public_network": {"key": "publicNetwork", "type": "NetworkACL"}, + "private_endpoints": {"key": "privateEndpoints", "type": "[PrivateEndpointACL]"}, } def __init__( self, *, - default_action: Optional[Union[str, "ACLAction"]] = None, - public_network: Optional["NetworkACL"] = None, - private_endpoints: Optional[List["PrivateEndpointACL"]] = None, + default_action: Optional[Union[str, "_models.ACLAction"]] = None, + public_network: Optional["_models.NetworkACL"] = None, + private_endpoints: Optional[List["_models.PrivateEndpointACL"]] = None, **kwargs ): """ - :keyword default_action: Azure Networking ACL Action. Possible values include: "Allow", "Deny". + :keyword default_action: Azure Networking ACL Action. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.signalr.models.ACLAction :keyword public_network: Network ACL. :paramtype public_network: ~azure.mgmt.signalr.models.NetworkACL :keyword private_endpoints: ACLs for requests from private endpoints. :paramtype private_endpoints: list[~azure.mgmt.signalr.models.PrivateEndpointACL] """ - super(SignalRNetworkACLs, self).__init__(**kwargs) + super().__init__(**kwargs) self.default_action = default_action self.public_network = public_network self.private_endpoints = private_endpoints @@ -1982,46 +1914,39 @@ class TrackedResource(Resource): :ivar location: The GEO location of the resource. e.g. West US | East US | North Central US | South Central US. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: The GEO location of the resource. e.g. West US | East US | North Central US | South Central US. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags -class SignalRResource(TrackedResource): +class SignalRResource(TrackedResource): # pylint: disable=too-many-instance-attributes """A class represent a resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2035,21 +1960,19 @@ class SignalRResource(TrackedResource): :ivar location: The GEO location of the resource. e.g. West US | East US | North Central US | South Central US. :vartype location: str - :ivar tags: A set of tags. Tags of the service which is a list of key value pairs that describe - the resource. + :ivar tags: Tags of the service which is a list of key value pairs that describe the resource. :vartype tags: dict[str, str] :ivar sku: The billing information of the resource. :vartype sku: ~azure.mgmt.signalr.models.ResourceSku - :ivar kind: The kind of the service, it can be SignalR or RawWebSockets. Possible values - include: "SignalR", "RawWebSockets". + :ivar kind: The kind of the service, it can be SignalR or RawWebSockets. Known values are: + "SignalR" and "RawWebSockets". :vartype kind: str or ~azure.mgmt.signalr.models.ServiceKind :ivar identity: A class represent managed identities used for request and response. :vartype identity: ~azure.mgmt.signalr.models.ManagedIdentity :ivar system_data: Metadata pertaining to creation and last modification of the resource. :vartype system_data: ~azure.mgmt.signalr.models.SystemData - :ivar provisioning_state: Provisioning state of the resource. Possible values include: - "Unknown", "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", - "Moving". + :ivar provisioning_state: Provisioning state of the resource. Known values are: "Unknown", + "Succeeded", "Failed", "Canceled", "Running", "Creating", "Updating", "Deleting", and "Moving". :vartype provisioning_state: str or ~azure.mgmt.signalr.models.ProvisioningState :ivar external_ip: The publicly accessible IP of the resource. :vartype external_ip: str @@ -2075,7 +1998,7 @@ class SignalRResource(TrackedResource): :ivar host_name_prefix: Deprecated. :vartype host_name_prefix: str :ivar features: List of the featureFlags. - + FeatureFlags that are not included in the parameters for the update operation will not be modified. And the response will only include featureFlags that are explicitly set. @@ -2091,6 +2014,8 @@ class SignalRResource(TrackedResource): :vartype resource_log_configuration: ~azure.mgmt.signalr.models.ResourceLogConfiguration :ivar cors: Cross-Origin Resource Sharing (CORS) settings. :vartype cors: ~azure.mgmt.signalr.models.SignalRCorsSettings + :ivar serverless: Serverless settings. + :vartype serverless: ~azure.mgmt.signalr.models.ServerlessSettings :ivar upstream: The settings for the Upstream when the service is in server-less mode. :vartype upstream: ~azure.mgmt.signalr.models.ServerlessUpstreamSettings :ivar network_ac_ls: Network ACLs for the resource. @@ -2111,90 +2036,101 @@ class SignalRResource(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'external_ip': {'readonly': True}, - 'host_name': {'readonly': True}, - 'public_port': {'readonly': True}, - 'server_port': {'readonly': True}, - 'version': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'shared_private_link_resources': {'readonly': True}, - 'host_name_prefix': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "external_ip": {"readonly": True}, + "host_name": {"readonly": True}, + "public_port": {"readonly": True}, + "server_port": {"readonly": True}, + "version": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "shared_private_link_resources": {"readonly": True}, + "host_name_prefix": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'ResourceSku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'external_ip': {'key': 'properties.externalIP', 'type': 'str'}, - 'host_name': {'key': 'properties.hostName', 'type': 'str'}, - 'public_port': {'key': 'properties.publicPort', 'type': 'int'}, - 'server_port': {'key': 'properties.serverPort', 'type': 'int'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'shared_private_link_resources': {'key': 'properties.sharedPrivateLinkResources', 'type': '[SharedPrivateLinkResource]'}, - 'tls': {'key': 'properties.tls', 'type': 'SignalRTlsSettings'}, - 'host_name_prefix': {'key': 'properties.hostNamePrefix', 'type': 'str'}, - 'features': {'key': 'properties.features', 'type': '[SignalRFeature]'}, - 'live_trace_configuration': {'key': 'properties.liveTraceConfiguration', 'type': 'LiveTraceConfiguration'}, - 'resource_log_configuration': {'key': 'properties.resourceLogConfiguration', 'type': 'ResourceLogConfiguration'}, - 'cors': {'key': 'properties.cors', 'type': 'SignalRCorsSettings'}, - 'upstream': {'key': 'properties.upstream', 'type': 'ServerlessUpstreamSettings'}, - 'network_ac_ls': {'key': 'properties.networkACLs', 'type': 'SignalRNetworkACLs'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'disable_local_auth': {'key': 'properties.disableLocalAuth', 'type': 'bool'}, - 'disable_aad_auth': {'key': 'properties.disableAadAuth', 'type': 'bool'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "ResourceSku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "ManagedIdentity"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "external_ip": {"key": "properties.externalIP", "type": "str"}, + "host_name": {"key": "properties.hostName", "type": "str"}, + "public_port": {"key": "properties.publicPort", "type": "int"}, + "server_port": {"key": "properties.serverPort", "type": "int"}, + "version": {"key": "properties.version", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "shared_private_link_resources": { + "key": "properties.sharedPrivateLinkResources", + "type": "[SharedPrivateLinkResource]", + }, + "tls": {"key": "properties.tls", "type": "SignalRTlsSettings"}, + "host_name_prefix": {"key": "properties.hostNamePrefix", "type": "str"}, + "features": {"key": "properties.features", "type": "[SignalRFeature]"}, + "live_trace_configuration": {"key": "properties.liveTraceConfiguration", "type": "LiveTraceConfiguration"}, + "resource_log_configuration": { + "key": "properties.resourceLogConfiguration", + "type": "ResourceLogConfiguration", + }, + "cors": {"key": "properties.cors", "type": "SignalRCorsSettings"}, + "serverless": {"key": "properties.serverless", "type": "ServerlessSettings"}, + "upstream": {"key": "properties.upstream", "type": "ServerlessUpstreamSettings"}, + "network_ac_ls": {"key": "properties.networkACLs", "type": "SignalRNetworkACLs"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "disable_local_auth": {"key": "properties.disableLocalAuth", "type": "bool"}, + "disable_aad_auth": {"key": "properties.disableAadAuth", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - sku: Optional["ResourceSku"] = None, - kind: Optional[Union[str, "ServiceKind"]] = None, - identity: Optional["ManagedIdentity"] = None, - tls: Optional["SignalRTlsSettings"] = None, - features: Optional[List["SignalRFeature"]] = None, - live_trace_configuration: Optional["LiveTraceConfiguration"] = None, - resource_log_configuration: Optional["ResourceLogConfiguration"] = None, - cors: Optional["SignalRCorsSettings"] = None, - upstream: Optional["ServerlessUpstreamSettings"] = None, - network_ac_ls: Optional["SignalRNetworkACLs"] = None, - public_network_access: Optional[str] = "Enabled", - disable_local_auth: Optional[bool] = False, - disable_aad_auth: Optional[bool] = False, + sku: Optional["_models.ResourceSku"] = None, + kind: Optional[Union[str, "_models.ServiceKind"]] = None, + identity: Optional["_models.ManagedIdentity"] = None, + tls: Optional["_models.SignalRTlsSettings"] = None, + features: Optional[List["_models.SignalRFeature"]] = None, + live_trace_configuration: Optional["_models.LiveTraceConfiguration"] = None, + resource_log_configuration: Optional["_models.ResourceLogConfiguration"] = None, + cors: Optional["_models.SignalRCorsSettings"] = None, + serverless: Optional["_models.ServerlessSettings"] = None, + upstream: Optional["_models.ServerlessUpstreamSettings"] = None, + network_ac_ls: Optional["_models.SignalRNetworkACLs"] = None, + public_network_access: str = "Enabled", + disable_local_auth: bool = False, + disable_aad_auth: bool = False, **kwargs ): """ :keyword location: The GEO location of the resource. e.g. West US | East US | North Central US | South Central US. :paramtype location: str - :keyword tags: A set of tags. Tags of the service which is a list of key value pairs that - describe the resource. + :keyword tags: Tags of the service which is a list of key value pairs that describe the + resource. :paramtype tags: dict[str, str] :keyword sku: The billing information of the resource. :paramtype sku: ~azure.mgmt.signalr.models.ResourceSku - :keyword kind: The kind of the service, it can be SignalR or RawWebSockets. Possible values - include: "SignalR", "RawWebSockets". + :keyword kind: The kind of the service, it can be SignalR or RawWebSockets. Known values are: + "SignalR" and "RawWebSockets". :paramtype kind: str or ~azure.mgmt.signalr.models.ServiceKind :keyword identity: A class represent managed identities used for request and response. :paramtype identity: ~azure.mgmt.signalr.models.ManagedIdentity :keyword tls: TLS settings for the resource. :paramtype tls: ~azure.mgmt.signalr.models.SignalRTlsSettings :keyword features: List of the featureFlags. - + FeatureFlags that are not included in the parameters for the update operation will not be modified. And the response will only include featureFlags that are explicitly set. @@ -2210,6 +2146,8 @@ def __init__( :paramtype resource_log_configuration: ~azure.mgmt.signalr.models.ResourceLogConfiguration :keyword cors: Cross-Origin Resource Sharing (CORS) settings. :paramtype cors: ~azure.mgmt.signalr.models.SignalRCorsSettings + :keyword serverless: Serverless settings. + :paramtype serverless: ~azure.mgmt.signalr.models.ServerlessSettings :keyword upstream: The settings for the Upstream when the service is in server-less mode. :paramtype upstream: ~azure.mgmt.signalr.models.ServerlessUpstreamSettings :keyword network_ac_ls: Network ACLs for the resource. @@ -2228,7 +2166,7 @@ def __init__( When set as true, connection with AuthType=aad won't work. :paramtype disable_aad_auth: bool """ - super(SignalRResource, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = sku self.kind = kind self.identity = identity @@ -2247,6 +2185,7 @@ def __init__( self.live_trace_configuration = live_trace_configuration self.resource_log_configuration = resource_log_configuration self.cors = cors + self.serverless = serverless self.upstream = upstream self.network_ac_ls = network_ac_ls self.public_network_access = public_network_access @@ -2254,7 +2193,7 @@ def __init__( self.disable_aad_auth = disable_aad_auth -class SignalRResourceList(msrest.serialization.Model): +class SignalRResourceList(_serialization.Model): """Object that includes an array of resources and a possible link for next set. :ivar value: List of the resources. @@ -2265,16 +2204,12 @@ class SignalRResourceList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SignalRResource]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SignalRResource]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["SignalRResource"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SignalRResource"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: List of the resources. @@ -2284,12 +2219,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(SignalRResourceList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SignalRTlsSettings(msrest.serialization.Model): +class SignalRTlsSettings(_serialization.Model): """TLS settings for the resource. :ivar client_cert_enabled: Request client certificate during TLS handshake if enabled. @@ -2297,33 +2232,28 @@ class SignalRTlsSettings(msrest.serialization.Model): """ _attribute_map = { - 'client_cert_enabled': {'key': 'clientCertEnabled', 'type': 'bool'}, + "client_cert_enabled": {"key": "clientCertEnabled", "type": "bool"}, } - def __init__( - self, - *, - client_cert_enabled: Optional[bool] = True, - **kwargs - ): + def __init__(self, *, client_cert_enabled: bool = True, **kwargs): """ :keyword client_cert_enabled: Request client certificate during TLS handshake if enabled. :paramtype client_cert_enabled: bool """ - super(SignalRTlsSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.client_cert_enabled = client_cert_enabled -class SignalRUsage(msrest.serialization.Model): +class SignalRUsage(_serialization.Model): """Object that describes a specific usage of the resources. :ivar id: Fully qualified ARM resource id. :vartype id: str :ivar current_value: Current value for the usage quota. - :vartype current_value: long + :vartype current_value: int :ivar limit: The maximum permitted value for the usage quota. If there is no limit, this value will be -1. - :vartype limit: long + :vartype limit: int :ivar name: Localizable String object containing the name and a localized value. :vartype name: ~azure.mgmt.signalr.models.SignalRUsageName :ivar unit: Representing the units of the usage quota. Possible values are: Count, Bytes, @@ -2332,20 +2262,20 @@ class SignalRUsage(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'limit': {'key': 'limit', 'type': 'long'}, - 'name': {'key': 'name', 'type': 'SignalRUsageName'}, - 'unit': {'key': 'unit', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "SignalRUsageName"}, + "unit": {"key": "unit", "type": "str"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin current_value: Optional[int] = None, limit: Optional[int] = None, - name: Optional["SignalRUsageName"] = None, + name: Optional["_models.SignalRUsageName"] = None, unit: Optional[str] = None, **kwargs ): @@ -2353,17 +2283,17 @@ def __init__( :keyword id: Fully qualified ARM resource id. :paramtype id: str :keyword current_value: Current value for the usage quota. - :paramtype current_value: long + :paramtype current_value: int :keyword limit: The maximum permitted value for the usage quota. If there is no limit, this value will be -1. - :paramtype limit: long + :paramtype limit: int :keyword name: Localizable String object containing the name and a localized value. :paramtype name: ~azure.mgmt.signalr.models.SignalRUsageName :keyword unit: Representing the units of the usage quota. Possible values are: Count, Bytes, Seconds, Percent, CountPerSecond, BytesPerSecond. :paramtype unit: str """ - super(SignalRUsage, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.current_value = current_value self.limit = limit @@ -2371,7 +2301,7 @@ def __init__( self.unit = unit -class SignalRUsageList(msrest.serialization.Model): +class SignalRUsageList(_serialization.Model): """Object that includes an array of the resource usages and a possible link for next set. :ivar value: List of the resource usages. @@ -2382,16 +2312,12 @@ class SignalRUsageList(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[SignalRUsage]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[SignalRUsage]"}, + "next_link": {"key": "nextLink", "type": "str"}, } def __init__( - self, - *, - value: Optional[List["SignalRUsage"]] = None, - next_link: Optional[str] = None, - **kwargs + self, *, value: Optional[List["_models.SignalRUsage"]] = None, next_link: Optional[str] = None, **kwargs ): """ :keyword value: List of the resource usages. @@ -2401,12 +2327,12 @@ def __init__( It's null for now, added for future use. :paramtype next_link: str """ - super(SignalRUsageList, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.next_link = next_link -class SignalRUsageName(msrest.serialization.Model): +class SignalRUsageName(_serialization.Model): """Localizable String object containing the name and a localized value. :ivar value: The identifier of the usage. @@ -2416,29 +2342,23 @@ class SignalRUsageName(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): """ :keyword value: The identifier of the usage. :paramtype value: str :keyword localized_value: Localized name of the usage. :paramtype localized_value: str """ - super(SignalRUsageName, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """Describes an available sku.". Variables are only populated by the server, and will be ignored when sending a request. @@ -2452,30 +2372,26 @@ class Sku(msrest.serialization.Model): """ _validation = { - 'resource_type': {'readonly': True}, - 'sku': {'readonly': True}, - 'capacity': {'readonly': True}, + "resource_type": {"readonly": True}, + "sku": {"readonly": True}, + "capacity": {"readonly": True}, } _attribute_map = { - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'ResourceSku'}, - 'capacity': {'key': 'capacity', 'type': 'SkuCapacity'}, + "resource_type": {"key": "resourceType", "type": "str"}, + "sku": {"key": "sku", "type": "ResourceSku"}, + "capacity": {"key": "capacity", "type": "SkuCapacity"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Sku, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.resource_type = None self.sku = None self.capacity = None -class SkuCapacity(msrest.serialization.Model): +class SkuCapacity(_serialization.Model): """Describes scaling information of a sku. Variables are only populated by the server, and will be ignored when sending a request. @@ -2488,34 +2404,30 @@ class SkuCapacity(msrest.serialization.Model): :vartype default: int :ivar allowed_values: Allows capacity value list. :vartype allowed_values: list[int] - :ivar scale_type: The scale type applicable to the sku. Possible values include: "None", - "Manual", "Automatic". + :ivar scale_type: The scale type applicable to the sku. Known values are: "None", "Manual", and + "Automatic". :vartype scale_type: str or ~azure.mgmt.signalr.models.ScaleType """ _validation = { - 'minimum': {'readonly': True}, - 'maximum': {'readonly': True}, - 'default': {'readonly': True}, - 'allowed_values': {'readonly': True}, - 'scale_type': {'readonly': True}, + "minimum": {"readonly": True}, + "maximum": {"readonly": True}, + "default": {"readonly": True}, + "allowed_values": {"readonly": True}, + "scale_type": {"readonly": True}, } _attribute_map = { - 'minimum': {'key': 'minimum', 'type': 'int'}, - 'maximum': {'key': 'maximum', 'type': 'int'}, - 'default': {'key': 'default', 'type': 'int'}, - 'allowed_values': {'key': 'allowedValues', 'type': '[int]'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, + "minimum": {"key": "minimum", "type": "int"}, + "maximum": {"key": "maximum", "type": "int"}, + "default": {"key": "default", "type": "int"}, + "allowed_values": {"key": "allowedValues", "type": "[int]"}, + "scale_type": {"key": "scaleType", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SkuCapacity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.minimum = None self.maximum = None self.default = None @@ -2523,7 +2435,7 @@ def __init__( self.scale_type = None -class SkuList(msrest.serialization.Model): +class SkuList(_serialization.Model): """The list skus operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -2536,82 +2448,78 @@ class SkuList(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Sku]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Sku]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SkuList, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class SystemData(msrest.serialization.Model): +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. Possible values include: - "User", "Application", "ManagedIdentity", "Key". + :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.signalr.models.CreatedByType :ivar created_at: The timestamp of resource creation (UTC). :vartype created_at: ~datetime.datetime :ivar last_modified_by: The identity that last modified the resource. :vartype last_modified_by: str - :ivar last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :ivar last_modified_by_type: The type of identity that last modified the resource. Known values + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.signalr.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'}, + "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, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): """ :keyword created_by: The identity that created the resource. :paramtype created_by: str - :keyword created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". + :keyword created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.signalr.models.CreatedByType :keyword created_at: The timestamp of resource creation (UTC). :paramtype created_at: ~datetime.datetime :keyword last_modified_by: The identity that last modified the resource. :paramtype last_modified_by: str - :keyword last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". + :keyword last_modified_by_type: The type of identity that last modified the resource. Known + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.signalr.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -2620,98 +2528,98 @@ def __init__( self.last_modified_at = last_modified_at -class UpstreamAuthSettings(msrest.serialization.Model): +class UpstreamAuthSettings(_serialization.Model): """Upstream auth settings. If not set, no auth is used for upstream messages. - :ivar type: Upstream auth type enum. Possible values include: "None", "ManagedIdentity". + :ivar type: Upstream auth type enum. Known values are: "None" and "ManagedIdentity". :vartype type: str or ~azure.mgmt.signalr.models.UpstreamAuthType :ivar managed_identity: Managed identity settings for upstream. :vartype managed_identity: ~azure.mgmt.signalr.models.ManagedIdentitySettings """ _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'managed_identity': {'key': 'managedIdentity', 'type': 'ManagedIdentitySettings'}, + "type": {"key": "type", "type": "str"}, + "managed_identity": {"key": "managedIdentity", "type": "ManagedIdentitySettings"}, } def __init__( self, *, - type: Optional[Union[str, "UpstreamAuthType"]] = None, - managed_identity: Optional["ManagedIdentitySettings"] = None, + type: Optional[Union[str, "_models.UpstreamAuthType"]] = None, + managed_identity: Optional["_models.ManagedIdentitySettings"] = None, **kwargs ): """ - :keyword type: Upstream auth type enum. Possible values include: "None", "ManagedIdentity". + :keyword type: Upstream auth type enum. Known values are: "None" and "ManagedIdentity". :paramtype type: str or ~azure.mgmt.signalr.models.UpstreamAuthType :keyword managed_identity: Managed identity settings for upstream. :paramtype managed_identity: ~azure.mgmt.signalr.models.ManagedIdentitySettings """ - super(UpstreamAuthSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = type self.managed_identity = managed_identity -class UpstreamTemplate(msrest.serialization.Model): +class UpstreamTemplate(_serialization.Model): """Upstream template item settings. It defines the Upstream URL of the incoming requests. -The template defines the pattern of the event, the hub or the category of the incoming request that matches current URL template. + The template defines the pattern of the event, the hub or the category of the incoming request that matches current URL template. - All required parameters must be populated in order to send to Azure. + All required parameters must be populated in order to send to Azure. + + :ivar hub_pattern: Gets or sets the matching pattern for hub names. If not set, it matches any + hub. + There are 3 kind of patterns supported: - :ivar hub_pattern: Gets or sets the matching pattern for hub names. If not set, it matches any - hub. - There are 3 kind of patterns supported: - - .. code-block:: - - 1. "*", it to matches any hub name. - 2. Combine multiple hubs with ",", for example "hub1,hub2", it matches "hub1" and "hub2". - 3. The single hub name, for example, "hub1", it matches "hub1". - :vartype hub_pattern: str - :ivar event_pattern: Gets or sets the matching pattern for event names. If not set, it matches - any event. - There are 3 kind of patterns supported: - - .. code-block:: - - 1. "*", it to matches any event name. - 2. Combine multiple events with ",", for example "connect,disconnect", it matches event - "connect" and "disconnect". - 3. The single event name, for example, "connect", it matches "connect". - :vartype event_pattern: str - :ivar category_pattern: Gets or sets the matching pattern for category names. If not set, it - matches any category. - There are 3 kind of patterns supported: - - .. code-block:: - - 1. "*", it to matches any category name. - 2. Combine multiple categories with ",", for example "connections,messages", it matches - category "connections" and "messages". - 3. The single category name, for example, "connections", it matches the category - "connections". - :vartype category_pattern: str - :ivar url_template: Required. Gets or sets the Upstream URL template. You can use 3 predefined - parameters {hub}, {category} {event} inside the template, the value of the Upstream URL is - dynamically calculated when the client request comes in. - For example, if the urlTemplate is ``http://example.com/{hub}/api/{event}``\ , with a client - request from hub ``chat`` connects, it will first POST to this URL: - ``http://example.com/chat/api/connect``. - :vartype url_template: str - :ivar auth: Upstream auth settings. If not set, no auth is used for upstream messages. - :vartype auth: ~azure.mgmt.signalr.models.UpstreamAuthSettings + .. code-block:: + + 1. "*", it to matches any hub name. + 2. Combine multiple hubs with ",", for example "hub1,hub2", it matches "hub1" and "hub2". + 3. The single hub name, for example, "hub1", it matches "hub1". + :vartype hub_pattern: str + :ivar event_pattern: Gets or sets the matching pattern for event names. If not set, it matches + any event. + There are 3 kind of patterns supported: + + .. code-block:: + + 1. "*", it to matches any event name. + 2. Combine multiple events with ",", for example "connect,disconnect", it matches event + "connect" and "disconnect". + 3. The single event name, for example, "connect", it matches "connect". + :vartype event_pattern: str + :ivar category_pattern: Gets or sets the matching pattern for category names. If not set, it + matches any category. + There are 3 kind of patterns supported: + + .. code-block:: + + 1. "*", it to matches any category name. + 2. Combine multiple categories with ",", for example "connections,messages", it matches + category "connections" and "messages". + 3. The single category name, for example, "connections", it matches the category + "connections". + :vartype category_pattern: str + :ivar url_template: Gets or sets the Upstream URL template. You can use 3 predefined parameters + {hub}, {category} {event} inside the template, the value of the Upstream URL is dynamically + calculated when the client request comes in. + For example, if the urlTemplate is ``http://example.com/{hub}/api/{event}``\ , with a client + request from hub ``chat`` connects, it will first POST to this URL: + ``http://example.com/chat/api/connect``. Required. + :vartype url_template: str + :ivar auth: Upstream auth settings. If not set, no auth is used for upstream messages. + :vartype auth: ~azure.mgmt.signalr.models.UpstreamAuthSettings """ _validation = { - 'url_template': {'required': True}, + "url_template": {"required": True}, } _attribute_map = { - 'hub_pattern': {'key': 'hubPattern', 'type': 'str'}, - 'event_pattern': {'key': 'eventPattern', 'type': 'str'}, - 'category_pattern': {'key': 'categoryPattern', 'type': 'str'}, - 'url_template': {'key': 'urlTemplate', 'type': 'str'}, - 'auth': {'key': 'auth', 'type': 'UpstreamAuthSettings'}, + "hub_pattern": {"key": "hubPattern", "type": "str"}, + "event_pattern": {"key": "eventPattern", "type": "str"}, + "category_pattern": {"key": "categoryPattern", "type": "str"}, + "url_template": {"key": "urlTemplate", "type": "str"}, + "auth": {"key": "auth", "type": "UpstreamAuthSettings"}, } def __init__( @@ -2721,16 +2629,16 @@ def __init__( hub_pattern: Optional[str] = None, event_pattern: Optional[str] = None, category_pattern: Optional[str] = None, - auth: Optional["UpstreamAuthSettings"] = None, + auth: Optional["_models.UpstreamAuthSettings"] = None, **kwargs ): """ :keyword hub_pattern: Gets or sets the matching pattern for hub names. If not set, it matches any hub. There are 3 kind of patterns supported: - + .. code-block:: - + 1. "*", it to matches any hub name. 2. Combine multiple hubs with ",", for example "hub1,hub2", it matches "hub1" and "hub2". 3. The single hub name, for example, "hub1", it matches "hub1". @@ -2738,9 +2646,9 @@ def __init__( :keyword event_pattern: Gets or sets the matching pattern for event names. If not set, it matches any event. There are 3 kind of patterns supported: - + .. code-block:: - + 1. "*", it to matches any event name. 2. Combine multiple events with ",", for example "connect,disconnect", it matches event "connect" and "disconnect". @@ -2749,26 +2657,26 @@ def __init__( :keyword category_pattern: Gets or sets the matching pattern for category names. If not set, it matches any category. There are 3 kind of patterns supported: - + .. code-block:: - + 1. "*", it to matches any category name. 2. Combine multiple categories with ",", for example "connections,messages", it matches category "connections" and "messages". 3. The single category name, for example, "connections", it matches the category "connections". :paramtype category_pattern: str - :keyword url_template: Required. Gets or sets the Upstream URL template. You can use 3 - predefined parameters {hub}, {category} {event} inside the template, the value of the Upstream - URL is dynamically calculated when the client request comes in. + :keyword url_template: Gets or sets the Upstream URL template. You can use 3 predefined + parameters {hub}, {category} {event} inside the template, the value of the Upstream URL is + dynamically calculated when the client request comes in. For example, if the urlTemplate is ``http://example.com/{hub}/api/{event}``\ , with a client request from hub ``chat`` connects, it will first POST to this URL: - ``http://example.com/chat/api/connect``. + ``http://example.com/chat/api/connect``. Required. :paramtype url_template: str :keyword auth: Upstream auth settings. If not set, no auth is used for upstream messages. :paramtype auth: ~azure.mgmt.signalr.models.UpstreamAuthSettings """ - super(UpstreamTemplate, self).__init__(**kwargs) + super().__init__(**kwargs) self.hub_pattern = hub_pattern self.event_pattern = event_pattern self.category_pattern = category_pattern @@ -2776,7 +2684,7 @@ def __init__( self.auth = auth -class UserAssignedIdentityProperty(msrest.serialization.Model): +class UserAssignedIdentityProperty(_serialization.Model): """Properties of user assigned identity. Variables are only populated by the server, and will be ignored when sending a request. @@ -2788,21 +2696,17 @@ class UserAssignedIdentityProperty(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentityProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_patch.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_signal_rmanagement_client_enums.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_signal_rmanagement_client_enums.py index cf7aa123655a..08ca30eb6629 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_signal_rmanagement_client_enums.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/models/_signal_rmanagement_client_enums.py @@ -7,30 +7,29 @@ # -------------------------------------------------------------------------- from enum import Enum -from six import with_metaclass from azure.core import CaseInsensitiveEnumMeta -class ACLAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Azure Networking ACL Action. - """ +class ACLAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Azure Networking ACL Action.""" ALLOW = "Allow" DENY = "Deny" -class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of identity that created the resource. - """ + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class FeatureFlags(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class FeatureFlags(str, Enum, metaclass=CaseInsensitiveEnumMeta): """FeatureFlags is the supported features of Azure SignalR service. - - + + * ServiceMode: Flag for backend server for SignalR service. Values allowed: "Default": have your own backend server; "Serverless": your application doesn't have a backend server; "Classic": for backward compatibility. Support both Default and Serverless mode but not @@ -51,23 +50,24 @@ class FeatureFlags(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): ENABLE_MESSAGING_LOGS = "EnableMessagingLogs" ENABLE_LIVE_TRACE = "EnableLiveTrace" -class KeyType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The type of access key. - """ + +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of access key.""" PRIMARY = "Primary" SECONDARY = "Secondary" SALT = "Salt" -class ManagedIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Represents the identity type: systemAssigned, userAssigned, None - """ + +class ManagedIdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Represents the identity type: systemAssigned, userAssigned, None.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" -class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class PrivateLinkServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Indicates whether the connection has been Approved/Rejected/Removed by the owner of the service. """ @@ -77,9 +77,9 @@ class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Provisioning state of the resource. - """ + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Provisioning state of the resource.""" UNKNOWN = "Unknown" SUCCEEDED = "Succeeded" @@ -91,24 +91,24 @@ class ProvisioningState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): DELETING = "Deleting" MOVING = "Moving" -class ScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The scale type applicable to the sku. - """ + +class ScaleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scale type applicable to the sku.""" NONE = "None" MANUAL = "Manual" AUTOMATIC = "Automatic" -class ServiceKind(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The kind of the service, it can be SignalR or RawWebSockets - """ + +class ServiceKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The kind of the service, it can be SignalR or RawWebSockets.""" SIGNAL_R = "SignalR" RAW_WEB_SOCKETS = "RawWebSockets" -class SharedPrivateLinkResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Status of the shared private link resource - """ + +class SharedPrivateLinkResourceStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Status of the shared private link resource.""" PENDING = "Pending" APPROVED = "Approved" @@ -116,18 +116,19 @@ class SharedPrivateLinkResourceStatus(with_metaclass(CaseInsensitiveEnumMeta, st DISCONNECTED = "Disconnected" TIMEOUT = "Timeout" -class SignalRRequestType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """The incoming request type to the service - """ + +class SignalRRequestType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The incoming request type to the service.""" CLIENT_CONNECTION = "ClientConnection" SERVER_CONNECTION = "ServerConnection" RESTAPI = "RESTAPI" TRACE = "Trace" -class SignalRSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + +class SignalRSkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Optional tier of this particular SKU. 'Standard' or 'Free'. - + ``Basic`` is deprecated, use ``Standard`` instead. """ @@ -136,9 +137,9 @@ class SignalRSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" PREMIUM = "Premium" -class UpstreamAuthType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): - """Upstream auth type enum. - """ + +class UpstreamAuthType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Upstream auth type enum.""" NONE = "None" MANAGED_IDENTITY = "ManagedIdentity" diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/__init__.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/__init__.py index bab1a78daafd..0fe4134b4d88 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/__init__.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/__init__.py @@ -15,13 +15,19 @@ from ._signal_rprivate_link_resources_operations import SignalRPrivateLinkResourcesOperations from ._signal_rshared_private_link_resources_operations import SignalRSharedPrivateLinkResourcesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SignalROperations', - 'UsagesOperations', - 'SignalRCustomCertificatesOperations', - 'SignalRCustomDomainsOperations', - 'SignalRPrivateEndpointConnectionsOperations', - 'SignalRPrivateLinkResourcesOperations', - 'SignalRSharedPrivateLinkResourcesOperations', + "Operations", + "SignalROperations", + "UsagesOperations", + "SignalRCustomCertificatesOperations", + "SignalRCustomDomainsOperations", + "SignalRPrivateEndpointConnectionsOperations", + "SignalRPrivateLinkResourcesOperations", + "SignalRSharedPrivateLinkResourcesOperations", ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_operations.py index fb83747d245f..7afd122a7616 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,106 +6,133 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) 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.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + +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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/providers/Microsoft.SignalRService/operations') + _url = kwargs.pop("template_url", "/providers/Microsoft.SignalRService/operations") # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class Operations(object): - """Operations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.SignalRManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.OperationList"]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available REST API operations of the Microsoft.SignalRService provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.OperationList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -118,7 +146,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -128,8 +158,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/providers/Microsoft.SignalRService/operations'} # type: ignore + list.metadata = {"url": "/providers/Microsoft.SignalRService/operations"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_patch.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_r_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_r_operations.py index 954d0a4f8fca..ab42176937a0 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_r_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_r_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,503 +6,527 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - location: str, - subscription_id: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] - api_version = "2022-02-01" - accept = "application/json" +def build_check_name_availability_request(location: 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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability", + ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_list_by_subscription_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_subscription_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/signalR') + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/signalR") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_list_by_resource_group_request( - subscription_id: str, - resource_group_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR", + ) # 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'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(resource_group_name: str, resource_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/listKeys') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/listKeys", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_regenerate_key_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_regenerate_key_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_restart_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restart_request( + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_skus_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/skus') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/skus", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class SignalROperations(object): - """SignalROperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SignalROperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.SignalRManagementClient`'s + :attr:`signal_r` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace + @overload def check_name_availability( self, location: str, - parameters: "_models.NameAvailabilityParameters", + parameters: _models.NameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any - ) -> "_models.NameAvailability": + ) -> _models.NameAvailability: """Checks that the resource name is valid and is not already in use. - :param location: the region. + :param location: the region. Required. :type location: str - :param parameters: Parameters supplied to the operation. + :param parameters: Parameters supplied to the operation. Required. :type parameters: ~azure.mgmt.signalr.models.NameAvailabilityParameters + :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: NameAvailability, or the result of cls(response) + :return: NameAvailability or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.NameAvailability - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + @overload + def check_name_availability( + self, location: str, parameters: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param parameters: Parameters supplied to the operation. Required. + :type parameters: IO + :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: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.signalr.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ - _json = self._serialize.body(parameters, 'NameAvailabilityParameters') + @distributed_trace + def check_name_availability( + self, location: str, parameters: Union[_models.NameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.NameAvailability: + """Checks that the resource name is valid and is not already in use. + + :param location: the region. Required. + :type location: str + :param parameters: Parameters supplied to the operation. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.signalr.models.NameAvailabilityParameters 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 + :return: NameAvailability or the result of cls(response) + :rtype: ~azure.mgmt.signalr.models.NameAvailability + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.NameAvailability] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "NameAvailabilityParameters") request = build_check_name_availability_request( location=location, subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -509,51 +534,68 @@ def check_name_availability( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('NameAvailability', pipeline_response) + deserialized = self._deserialize("NameAvailability", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability'} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/checkNameAvailability"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> Iterable["_models.SignalRResourceList"]: + def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SignalRResource"]: """Handles requests to list all resources in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SignalRResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SignalRResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SignalRResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, - template_url=self.list_by_subscription.metadata['url'], + api_version=api_version, + template_url=self.list_by_subscription.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_subscription_request( - subscription_id=self._config.subscription_id, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -567,7 +609,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -577,53 +621,67 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/signalR'} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/signalR"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable["_models.SignalRResourceList"]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SignalRResource"]: """Handles requests to list all resources in a resource group. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. 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 SignalRResourceList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SignalRResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SignalRResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, - template_url=self.list_by_resource_group.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_resource_group.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_resource_group_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -637,7 +695,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -647,48 +707,56 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR'} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.SignalRResource": + def get(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SignalRResource: """Get the resource and its properties. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SignalRResource, or the result of cls(response) + :return: SignalRResource or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SignalRResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRResource] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -696,83 +764,180 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.SignalRResource", + parameters: Union[_models.SignalRResource, IO], **kwargs: Any - ) -> Optional["_models.SignalRResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SignalRResource"]] + ) -> Optional[_models.SignalRResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'SignalRResource') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SignalRResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SignalRResource") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.SignalRResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SignalRResource]: + """Create or update a resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource + :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 SignalRResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SignalRResource]: + """Create or update a resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the create or update operation. Required. + :type parameters: IO + :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 SignalRResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.SignalRResource", + parameters: Union[_models.SignalRResource, IO], **kwargs: Any - ) -> LROPoller["_models.SignalRResource"]: + ) -> LROPoller[_models.SignalRResource]: """Create or update a resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param parameters: Parameters for the create or update operation. - :type parameters: ~azure.mgmt.signalr.models.SignalRResource + :param parameters: Parameters for the create or update operation. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource 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 @@ -784,98 +949,111 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore - def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore @distributed_trace - def begin_delete( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: """Operation to delete a resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_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. @@ -887,108 +1065,215 @@ def begin_delete( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore def _update_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.SignalRResource", + parameters: Union[_models.SignalRResource, IO], **kwargs: Any - ) -> Optional["_models.SignalRResource"]: - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.SignalRResource"]] + ) -> Optional[_models.SignalRResource]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'SignalRResource') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.SignalRResource]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SignalRResource") - request = build_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_update_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._update_initial.metadata['url'], + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore + _update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.SignalRResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SignalRResource]: + """Operation to update an exiting resource. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource + :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 SignalRResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_update( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SignalRResource]: + """Operation to update an exiting resource. + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameters for the update operation. Required. + :type parameters: IO + :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 SignalRResource or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_update( self, resource_group_name: str, resource_name: str, - parameters: "_models.SignalRResource", + parameters: Union[_models.SignalRResource, IO], **kwargs: Any - ) -> LROPoller["_models.SignalRResource"]: + ) -> LROPoller[_models.SignalRResource]: """Operation to update an exiting resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param parameters: Parameters for the update operation. - :type parameters: ~azure.mgmt.signalr.models.SignalRResource + :param parameters: Parameters for the update operation. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.signalr.models.SignalRResource 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 @@ -1000,86 +1285,102 @@ def begin_update( :return: An instance of LROPoller that returns either SignalRResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._update_initial( + raw_result = self._update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SignalRResource', pipeline_response) + deserialized = self._deserialize("SignalRResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}'} # type: ignore + begin_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}"} # type: ignore @distributed_trace - def list_keys( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.SignalRKeys": + def list_keys(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SignalRKeys: """Get the access keys of the resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SignalRKeys, or the result of cls(response) + :return: SignalRKeys or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SignalRKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRKeys"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRKeys] - request = build_list_keys_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_keys.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1087,79 +1388,178 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SignalRKeys', pipeline_response) + deserialized = self._deserialize("SignalRKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/listKeys'} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/listKeys"} # type: ignore def _regenerate_key_initial( self, resource_group_name: str, resource_name: str, - parameters: "_models.RegenerateKeyParameters", + parameters: Union[_models.RegenerateKeyParameters, IO], **kwargs: Any - ) -> "_models.SignalRKeys": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRKeys"] + ) -> _models.SignalRKeys: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'RegenerateKeyParameters') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRKeys] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "RegenerateKeyParameters") - request = build_regenerate_key_request_initial( - subscription_id=self._config.subscription_id, + request = build_regenerate_key_request( resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._regenerate_key_initial.metadata['url'], + content=_content, + template_url=self._regenerate_key_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SignalRKeys', pipeline_response) + deserialized = self._deserialize("SignalRKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _regenerate_key_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey'} # type: ignore + _regenerate_key_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey"} # type: ignore + + @overload + def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: _models.RegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SignalRKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Required. + :type parameters: ~azure.mgmt.signalr.models.RegenerateKeyParameters + :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 SignalRKeys or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + def begin_regenerate_key( + self, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SignalRKeys]: + """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated + at the same time. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: Parameter that describes the Regenerate Key Operation. Required. + :type parameters: IO + :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 SignalRKeys or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRKeys] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_regenerate_key( self, resource_group_name: str, resource_name: str, - parameters: "_models.RegenerateKeyParameters", + parameters: Union[_models.RegenerateKeyParameters, IO], **kwargs: Any - ) -> LROPoller["_models.SignalRKeys"]: + ) -> LROPoller[_models.SignalRKeys]: """Regenerate the access key for the resource. PrimaryKey and SecondaryKey cannot be regenerated at the same time. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param parameters: Parameter that describes the Regenerate Key Operation. - :type parameters: ~azure.mgmt.signalr.models.RegenerateKeyParameters + :param parameters: Parameter that describes the Regenerate Key Operation. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.signalr.models.RegenerateKeyParameters 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 @@ -1171,98 +1571,113 @@ def begin_regenerate_key( :return: An instance of LROPoller that returns either SignalRKeys or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SignalRKeys] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRKeys"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRKeys] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._regenerate_key_initial( + raw_result = self._regenerate_key_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SignalRKeys', pipeline_response) + deserialized = self._deserialize("SignalRKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_regenerate_key.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey'} # type: ignore + begin_regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/regenerateKey"} # type: ignore - def _restart_initial( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any + def _restart_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_restart_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_restart_request( resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._restart_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._restart_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart'} # type: ignore - + _restart_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart"} # type: ignore @distributed_trace - def begin_restart( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_restart(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> LROPoller[None]: """Operation to restart a resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_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. @@ -1274,80 +1689,99 @@ def begin_restart( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._restart_initial( + raw_result = self._restart_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "azure-async-operation"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart'} # type: ignore + begin_restart.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/restart"} # type: ignore @distributed_trace - def list_skus( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.SkuList": + def list_skus(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> _models.SkuList: """List all available skus of the resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SkuList, or the result of cls(response) + :return: SkuList or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SkuList - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SkuList"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SkuList] - request = build_list_skus_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list_skus.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_skus.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -1355,12 +1789,11 @@ def list_skus( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SkuList', pipeline_response) + deserialized = self._deserialize("SkuList", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/skus'} # type: ignore - + list_skus.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/skus"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_certificates_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_certificates_operations.py index 77ae54badc28..f22ee35d258e 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_certificates_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_certificates_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,253 +6,262 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, certificate_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class SignalRCustomCertificatesOperations(object): - """SignalRCustomCertificatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SignalRCustomCertificatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.SignalRManagementClient`'s + :attr:`signal_rcustom_certificates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.CustomCertificateList"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.CustomCertificate"]: """List all custom certificates. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomCertificateList or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.CustomCertificateList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either CustomCertificate or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomCertificateList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomCertificateList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -265,7 +275,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -275,52 +287,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any - ) -> "_models.CustomCertificate": + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any + ) -> _models.CustomCertificate: """Get a custom certificate. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param certificate_name: Custom certificate name. + :param certificate_name: Custom certificate name. Required. :type certificate_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomCertificate, or the result of cls(response) + :return: CustomCertificate or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.CustomCertificate - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomCertificate"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomCertificate] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -328,66 +349,165 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomCertificate', pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, certificate_name: str, - parameters: "_models.CustomCertificate", + parameters: Union[_models.CustomCertificate, IO], **kwargs: Any - ) -> "_models.CustomCertificate": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomCertificate"] + ) -> _models.CustomCertificate: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'CustomCertificate') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomCertificate] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CustomCertificate") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('CustomCertificate', pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('CustomCertificate', pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: _models.CustomCertificate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.signalr.models.CustomCertificate + :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 CustomCertificate or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + certificate_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomCertificate]: + """Create or update a custom certificate. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param certificate_name: Custom certificate name. Required. + :type certificate_name: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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 CustomCertificate or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomCertificate] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -395,20 +515,23 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, certificate_name: str, - parameters: "_models.CustomCertificate", + parameters: Union[_models.CustomCertificate, IO], **kwargs: Any - ) -> LROPoller["_models.CustomCertificate"]: + ) -> LROPoller[_models.CustomCertificate]: """Create or update a custom certificate. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param certificate_name: Custom certificate name. + :param certificate_name: Custom certificate name. Required. :type certificate_name: str - :param parameters: - :type parameters: ~azure.mgmt.signalr.models.CustomCertificate + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.signalr.models.CustomCertificate or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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 @@ -420,91 +543,108 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either CustomCertificate or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomCertificate] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomCertificate"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomCertificate] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomCertificate', pipeline_response) + deserialized = self._deserialize("CustomCertificate", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}"} # type: ignore @distributed_trace - def delete( - self, - resource_group_name: str, - resource_name: str, - certificate_name: str, - **kwargs: Any + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, certificate_name: str, **kwargs: Any ) -> None: """Delete a custom certificate. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param certificate_name: Custom certificate name. + :param certificate_name: Custom certificate name. Required. :type certificate_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, certificate_name=certificate_name, - template_url=self.delete.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.delete.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -515,5 +655,4 @@ def delete( if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}'} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customCertificates/{certificateName}"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_domains_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_domains_operations.py index 2e112e899d37..84dad519387b 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_domains_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rcustom_domains_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,252 +6,260 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - - -def build_create_or_update_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - name: str, - *, - json: JSONType = None, - content: Any = None, - **kwargs: Any + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request( + resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) - - -def build_delete_request_initial( - subscription_id: str, - resource_group_name: str, - resource_name: str, - name: str, - **kwargs: Any + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, resource_name: str, name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), - "name": _SERIALIZER.url("name", name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), + "name": _SERIALIZER.url("name", name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class SignalRCustomDomainsOperations(object): - """SignalRCustomDomainsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SignalRCustomDomainsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.SignalRManagementClient`'s + :attr:`signal_rcustom_domains` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.CustomDomainList"]: + def list(self, resource_group_name: str, resource_name: str, **kwargs: Any) -> Iterable["_models.CustomDomain"]: """List all custom domains. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either CustomDomainList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.CustomDomainList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either CustomDomain or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomainList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomainList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -264,7 +273,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -274,52 +285,59 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - resource_name: str, - name: str, - **kwargs: Any - ) -> "_models.CustomDomain": + def get(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> _models.CustomDomain: """Get a custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param name: Custom domain name. + :param name: Custom domain name. Required. :type name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: CustomDomain, or the result of cls(response) + :return: CustomDomain or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.CustomDomain - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomain"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomain] - request = build_get_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, name=name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -327,62 +345,161 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomain', pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}"} # type: ignore def _create_or_update_initial( self, resource_group_name: str, resource_name: str, name: str, - parameters: "_models.CustomDomain", + parameters: Union[_models.CustomDomain, IO], **kwargs: Any - ) -> "_models.CustomDomain": - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomain"] + ) -> _models.CustomDomain: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'CustomDomain') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomain] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "CustomDomain") - request = build_create_or_update_request_initial( - subscription_id=self._config.subscription_id, + request = build_create_or_update_request( resource_group_name=resource_group_name, resource_name=resource_name, name=name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('CustomDomain', pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}"} # type: ignore + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: _models.CustomDomain, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Required. + :type parameters: ~azure.mgmt.signalr.models.CustomDomain + :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 CustomDomain or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + resource_group_name: str, + resource_name: str, + name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.CustomDomain]: + """Create or update a custom domain. + + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param name: Custom domain name. Required. + :type name: str + :param parameters: Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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 CustomDomain or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomDomain] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -390,20 +507,23 @@ def begin_create_or_update( resource_group_name: str, resource_name: str, name: str, - parameters: "_models.CustomDomain", + parameters: Union[_models.CustomDomain, IO], **kwargs: Any - ) -> LROPoller["_models.CustomDomain"]: + ) -> LROPoller[_models.CustomDomain]: """Create or update a custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param name: Custom domain name. + :param name: Custom domain name. Required. :type name: str - :param parameters: - :type parameters: ~azure.mgmt.signalr.models.CustomDomain + :param parameters: Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.signalr.models.CustomDomain or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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 @@ -415,104 +535,115 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either CustomDomain or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.CustomDomain] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.CustomDomain"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomDomain] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, name=name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('CustomDomain', pipeline_response) + deserialized = self._deserialize("CustomDomain", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}"} # type: ignore - def _delete_initial( - self, - resource_group_name: str, - resource_name: str, - name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) - - request = build_delete_request_initial( - subscription_id=self._config.subscription_id, + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( resource_group_name=resource_group_name, resource_name=resource_name, name=name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}"} # type: ignore @distributed_trace - def begin_delete( - self, - resource_group_name: str, - resource_name: str, - name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_delete(self, resource_group_name: str, resource_name: str, name: str, **kwargs: Any) -> LROPoller[None]: """Delete a custom domain. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param name: Custom domain name. + :param name: Custom domain name. Required. :type 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. @@ -524,41 +655,50 @@ def begin_delete( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore resource_group_name=resource_group_name, resource_name=resource_name, name=name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/customDomains/{name}"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_endpoint_connections_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_endpoint_connections_operations.py index c166e468a954..bfda2b3e4564 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_endpoint_connections_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_endpoint_connections_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,253 +6,281 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( private_endpoint_connection_name: str, - subscription_id: str, resource_group_name: str, resource_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( private_endpoint_connection_name: str, - subscription_id: str, resource_group_name: str, resource_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( private_endpoint_connection_name: str, - subscription_id: str, resource_group_name: str, resource_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class SignalRPrivateEndpointConnectionsOperations(object): - """SignalRPrivateEndpointConnectionsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SignalRPrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.SignalRManagementClient`'s + :attr:`signal_rprivate_endpoint_connections` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateEndpointConnectionList"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List private endpoint connections. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateEndpointConnectionList or the result of + :return: An iterator like instance of either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.PrivateEndpointConnectionList] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnectionList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -265,7 +294,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -275,52 +306,61 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: """Get the specified private endpoint connection. - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -328,15 +368,76 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + @overload + def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Required. + :type parameters: ~azure.mgmt.signalr.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + private_endpoint_connection_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection. + + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. + :type private_endpoint_connection_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The resource of private endpoint and its properties. Required. + :type parameters: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( @@ -344,48 +445,74 @@ def update( private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, - parameters: "_models.PrivateEndpointConnection", + parameters: Union[_models.PrivateEndpointConnection, IO], **kwargs: Any - ) -> "_models.PrivateEndpointConnection": + ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection. - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param parameters: The resource of private endpoint and its properties. - :type parameters: ~azure.mgmt.signalr.models.PrivateEndpointConnection + :param parameters: The resource of private endpoint and its properties. Is either a model type + or a IO type. Required. + :type parameters: ~azure.mgmt.signalr.models.PrivateEndpointConnection 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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'PrivateEndpointConnection') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "PrivateEndpointConnection") request = build_update_request( private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -393,69 +520,75 @@ def update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - def _delete_initial( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( private_endpoint_connection_name=private_endpoint_connection_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def begin_delete( - self, - private_endpoint_connection_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + self, private_endpoint_connection_name: str, resource_group_name: str, resource_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the specified private endpoint connection. - :param private_endpoint_connection_name: The name of the private endpoint connection. + :param private_endpoint_connection_name: The name of the private endpoint connection. Required. :type private_endpoint_connection_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_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. @@ -467,41 +600,50 @@ def begin_delete( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore private_endpoint_connection_name=private_endpoint_connection_name, resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_link_resources_operations.py index 862b2d70c199..a8a15c4c1baa 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_link_resources_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rprivate_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,130 +6,155 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) 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.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateLinkResources') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateLinkResources", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class SignalRPrivateLinkResourcesOperations(object): - """SignalRPrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class SignalRPrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.SignalRManagementClient`'s + :attr:`signal_rprivate_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.PrivateLinkResourceList"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateLinkResource"]: """Get the private link resources that need to be created for a resource. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either PrivateLinkResourceList or the result of - cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.PrivateLinkResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either PrivateLinkResource or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.PrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateLinkResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -142,7 +168,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -152,8 +180,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateLinkResources'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/privateLinkResources"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rshared_private_link_resources_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rshared_private_link_resources_operations.py index f5cacae3efa7..c2bd81da017b 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rshared_private_link_resources_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_signal_rshared_private_link_resources_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,253 +6,281 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.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 msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') -JSONType = Any + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( - subscription_id: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + resource_group_name: str, resource_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources", + ) # 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'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( shared_private_link_resource_name: str, - subscription_id: str, resource_group_name: str, resource_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "sharedPrivateLinkResourceName": _SERIALIZER.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "sharedPrivateLinkResourceName": _SERIALIZER.url( + "shared_private_link_resource_name", shared_private_link_resource_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_or_update_request_initial( +def build_create_or_update_request( shared_private_link_resource_name: str, - subscription_id: str, resource_group_name: str, resource_name: str, - *, - json: JSONType = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - content_type = kwargs.pop('content_type', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") - api_version = "2022-02-01" - accept = "application/json" # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "sharedPrivateLinkResourceName": _SERIALIZER.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "sharedPrivateLinkResourceName": _SERIALIZER.url( + "shared_private_link_resource_name", shared_private_link_resource_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] if content_type is not None: - header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=url, - params=query_parameters, - headers=header_parameters, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_delete_request_initial( +def build_delete_request( shared_private_link_resource_name: str, - subscription_id: str, resource_group_name: str, resource_name: str, + subscription_id: str, **kwargs: Any ) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}') + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "sharedPrivateLinkResourceName": _SERIALIZER.url("shared_private_link_resource_name", shared_private_link_resource_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "sharedPrivateLinkResourceName": _SERIALIZER.url( + "shared_private_link_resource_name", shared_private_link_resource_name, "str" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "resourceName": _SERIALIZER.url("resource_name", resource_name, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class SignalRSharedPrivateLinkResourcesOperations(object): - """SignalRSharedPrivateLinkResourcesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SignalRSharedPrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.SignalRManagementClient`'s + :attr:`signal_rshared_private_link_resources` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace def list( - self, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> Iterable["_models.SharedPrivateLinkResourceList"]: + self, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> Iterable["_models.SharedPrivateLinkResource"]: """List shared private link resources. :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedPrivateLinkResourceList or the result of + :return: An iterator like instance of either SharedPrivateLinkResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SharedPrivateLinkResourceList] - :raises: ~azure.core.exceptions.HttpResponseError + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResourceList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedPrivateLinkResourceList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.list.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - resource_group_name=resource_group_name, - resource_name=resource_name, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -265,7 +294,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -275,52 +306,62 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources"} # type: ignore @distributed_trace def get( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any - ) -> "_models.SharedPrivateLinkResource": + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any + ) -> _models.SharedPrivateLinkResource: """Get the specified shared private link resource. :param shared_private_link_resource_name: The name of the shared private link resource. + Required. :type shared_private_link_resource_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedPrivateLinkResource, or the result of cls(response) + :return: SharedPrivateLinkResource or the result of cls(response) :rtype: ~azure.mgmt.signalr.models.SharedPrivateLinkResource - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResource"] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedPrivateLinkResource] - request = build_get_request( shared_private_link_resource_name=shared_private_link_resource_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self.get.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.get.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: @@ -328,66 +369,167 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('SharedPrivateLinkResource', pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"} # type: ignore def _create_or_update_initial( self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, - parameters: "_models.SharedPrivateLinkResource", + parameters: Union[_models.SharedPrivateLinkResource, IO], **kwargs: Any - ) -> "_models.SharedPrivateLinkResource": - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResource"] + ) -> _models.SharedPrivateLinkResource: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) - - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - - _json = self._serialize.body(parameters, 'SharedPrivateLinkResource') + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedPrivateLinkResource] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "SharedPrivateLinkResource") - request = build_create_or_update_request_initial( + request = build_create_or_update_request( shared_private_link_resource_name=shared_private_link_resource_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, + subscription_id=self._config.subscription_id, + api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_or_update_initial.metadata['url'], + content=_content, + template_url=self._create_or_update_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SharedPrivateLinkResource', pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SharedPrivateLinkResource', pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + _create_or_update_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"} # type: ignore + @overload + def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: _models.SharedPrivateLinkResource, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource + :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 SharedPrivateLinkResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_or_update( + self, + shared_private_link_resource_name: str, + resource_group_name: str, + resource_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.SharedPrivateLinkResource]: + """Create or update a shared private link resource. + + :param shared_private_link_resource_name: The name of the shared private link resource. + Required. + :type shared_private_link_resource_name: str + :param resource_group_name: The name of the resource group that contains the resource. You can + obtain this value from the Azure Resource Manager API or the portal. Required. + :type resource_group_name: str + :param resource_name: The name of the resource. Required. + :type resource_name: str + :param parameters: The shared private link resource. Required. + :type parameters: IO + :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 SharedPrivateLinkResource or the result + of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create_or_update( @@ -395,20 +537,25 @@ def begin_create_or_update( shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, - parameters: "_models.SharedPrivateLinkResource", + parameters: Union[_models.SharedPrivateLinkResource, IO], **kwargs: Any - ) -> LROPoller["_models.SharedPrivateLinkResource"]: + ) -> LROPoller[_models.SharedPrivateLinkResource]: """Create or update a shared private link resource. :param shared_private_link_resource_name: The name of the shared private link resource. + Required. :type shared_private_link_resource_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_name: str - :param parameters: The shared private link resource. - :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource + :param parameters: The shared private link resource. Is either a model type or a IO type. + Required. + :type parameters: ~azure.mgmt.signalr.models.SharedPrivateLinkResource 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 @@ -420,104 +567,118 @@ def begin_create_or_update( :return: An instance of LROPoller that returns either SharedPrivateLinkResource or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.signalr.models.SharedPrivateLinkResource] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedPrivateLinkResource"] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SharedPrivateLinkResource] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._create_or_update_initial( + raw_result = self._create_or_update_initial( # type: ignore shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, parameters=parameters, + api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - response = pipeline_response.http_response - deserialized = self._deserialize('SharedPrivateLinkResource', pipeline_response) + deserialized = self._deserialize("SharedPrivateLinkResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + begin_create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"} # type: ignore - def _delete_initial( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + def _delete_initial( # pylint: disable=inconsistent-return-statements + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any ) -> None: - cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - request = build_delete_request_initial( + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( shared_private_link_resource_name=shared_private_link_resource_name, - subscription_id=self._config.subscription_id, resource_group_name=resource_group_name, resource_name=resource_name, - template_url=self._delete_initial.metadata['url'], + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._delete_initial.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"} # type: ignore @distributed_trace def begin_delete( - self, - shared_private_link_resource_name: str, - resource_group_name: str, - resource_name: str, - **kwargs: Any + self, shared_private_link_resource_name: str, resource_group_name: str, resource_name: str, **kwargs: Any ) -> LROPoller[None]: """Delete the specified shared private link resource. :param shared_private_link_resource_name: The name of the shared private link resource. + Required. :type shared_private_link_resource_name: str :param resource_group_name: The name of the resource group that contains the resource. You can - obtain this value from the Azure Resource Manager API or the portal. + obtain this value from the Azure Resource Manager API or the portal. Required. :type resource_group_name: str - :param resource_name: The name of the resource. + :param resource_name: The name of the resource. Required. :type resource_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. @@ -529,41 +690,50 @@ def begin_delete( 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 + :raises ~azure.core.exceptions.HttpResponseError: """ - polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] - cls = kwargs.pop('cls', None) # type: ClsType[None] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: - raw_result = self._delete_initial( + raw_result = self._delete_initial( # type: ignore shared_private_link_resource_name=shared_private_link_resource_name, resource_group_name=resource_group_name, resource_name=resource_name, - cls=lambda x,y,z: x, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - - if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) - elif polling is False: polling_method = NoPolling() - else: polling_method = polling + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) - else: - return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}'} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.SignalRService/signalR/{resourceName}/sharedPrivateLinkResources/{sharedPrivateLinkResourceName}"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_usages_operations.py b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_usages_operations.py index 89fd41bb95d4..70a42fa6a7cc 100644 --- a/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_usages_operations.py +++ b/sdk/signalr/azure-mgmt-signalr/azure/mgmt/signalr/operations/_usages_operations.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,121 +6,145 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -import functools -from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar -import warnings - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) 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.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat -from msrest import Serializer from .. import models as _models +from .._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - location: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: - api_version = "2022-02-01" - accept = "application/json" + +def build_list_request(location: 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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + # Construct URL - url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages') + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "location": _SERIALIZER.url("location", location, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } - url = _format_url_section(url, **path_format_arguments) + _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] - query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] - header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=url, - params=query_parameters, - headers=header_parameters, - **kwargs - ) - -class UsagesOperations(object): - """UsagesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.signalr.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.signalr.SignalRManagementClient`'s + :attr:`usages` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list( - self, - location: str, - **kwargs: Any - ) -> Iterable["_models.SignalRUsageList"]: + def list(self, location: str, **kwargs: Any) -> Iterable["_models.SignalRUsage"]: """List resource usage quotas by location. - :param location: the location like "eastus". + :param location: the location like "eastus". Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SignalRUsageList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SignalRUsageList] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SignalRUsage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.signalr.models.SignalRUsage] + :raises ~azure.core.exceptions.HttpResponseError: """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.SignalRUsageList"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", self._config.api_version) + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SignalRUsageList] + error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {})) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( location=location, subscription_id=self._config.subscription_id, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], + headers=_headers, + params=_params, ) request = _convert_request(request) - request.url = self._client.format_url(request.url) + request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - location=location, - subscription_id=self._config.subscription_id, - template_url=next_link, + # 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.url = self._client.format_url(request.url) # type: ignore request.method = "GET" return request @@ -133,7 +158,9 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) response = pipeline_response.http_response if response.status_code not in [200]: @@ -143,8 +170,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages'} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.SignalRService/locations/{location}/usages"} # type: ignore diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/operations_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/operations_list.py new file mode 100644 index 000000000000..6e255f315803 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/operations_list.py @@ -0,0 +1,39 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python operations_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="SUBSCRIPTION_ID", + ) + + response = client.operations.list() + for item in response: + print(item) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/Operations_List.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_check_name_availability.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_check_name_availability.py new file mode 100644 index 000000000000..349215031872 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_check_name_availability.py @@ -0,0 +1,41 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_r_check_name_availability.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_r.check_name_availability( + location="eastus", + parameters={"name": "mySignalRService", "type": "Microsoft.SignalRService/SignalR"}, + ) + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalR_CheckNameAvailability.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_create_or_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_create_or_update.py new file mode 100644 index 000000000000..66ea1660d228 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_create_or_update.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_r_create_or_update.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_r.begin_create_or_update( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + parameters={ + "identity": {"type": "SystemAssigned"}, + "kind": "SignalR", + "location": "eastus", + "properties": { + "cors": {"allowedOrigins": ["https://foo.com", "https://bar.com"]}, + "disableAadAuth": False, + "disableLocalAuth": False, + "features": [ + {"flag": "ServiceMode", "properties": {}, "value": "Serverless"}, + {"flag": "EnableConnectivityLogs", "properties": {}, "value": "True"}, + {"flag": "EnableMessagingLogs", "properties": {}, "value": "False"}, + {"flag": "EnableLiveTrace", "properties": {}, "value": "False"}, + ], + "liveTraceConfiguration": { + "categories": [{"enabled": "true", "name": "ConnectivityLogs"}], + "enabled": "false", + }, + "networkACLs": { + "defaultAction": "Deny", + "privateEndpoints": [ + {"allow": ["ServerConnection"], "name": "mysignalrservice.1fa229cd-bf3f-47f0-8c49-afb36723997e"} + ], + "publicNetwork": {"allow": ["ClientConnection"]}, + }, + "publicNetworkAccess": "Enabled", + "serverless": {"connectionTimeoutInSeconds": 5}, + "tls": {"clientCertEnabled": False}, + "upstream": { + "templates": [ + { + "auth": {"managedIdentity": {"resource": "api://example"}, "type": "ManagedIdentity"}, + "categoryPattern": "*", + "eventPattern": "connect,disconnect", + "hubPattern": "*", + "urlTemplate": "https://example.com/chat/api/connect", + } + ] + }, + }, + "sku": {"capacity": 1, "name": "Standard_S1", "tier": "Standard"}, + "tags": {"key1": "value1"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalR_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_delete.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_delete.py new file mode 100644 index 000000000000..c56ec2bbaa06 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_delete.py @@ -0,0 +1,41 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_r_delete.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_r.begin_delete( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalR_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_get.py new file mode 100644 index 000000000000..5e937d89b156 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_get.py @@ -0,0 +1,41 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_r_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_r.get( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ) + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalR_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_resource_group.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_resource_group.py new file mode 100644 index 000000000000..bd1291061e07 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_resource_group.py @@ -0,0 +1,41 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_r_list_by_resource_group.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_r.list_by_resource_group( + resource_group_name="myResourceGroup", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalR_ListByResourceGroup.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_subscription.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_subscription.py new file mode 100644 index 000000000000..13451b84caad --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_by_subscription.py @@ -0,0 +1,39 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_r_list_by_subscription.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_r.list_by_subscription() + for item in response: + print(item) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalR_ListBySubscription.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_keys.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_keys.py new file mode 100644 index 000000000000..3724489c92ce --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_keys.py @@ -0,0 +1,41 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_r_list_keys.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_r.list_keys( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ) + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalR_ListKeys.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_skus.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_skus.py new file mode 100644 index 000000000000..128ed23892f6 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_list_skus.py @@ -0,0 +1,41 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_r_list_skus.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_r.list_skus( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ) + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalR_ListSkus.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_regenerate_key.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_regenerate_key.py new file mode 100644 index 000000000000..a6e4ad07bb0d --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_regenerate_key.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_r_regenerate_key.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_r.begin_regenerate_key( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + parameters={"keyType": "Primary"}, + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalR_RegenerateKey.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_restart.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_restart.py new file mode 100644 index 000000000000..f3a7153bc835 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_restart.py @@ -0,0 +1,41 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_r_restart.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_r.begin_restart( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalR_Restart.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_update.py new file mode 100644 index 000000000000..34d466097258 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_r_update.py @@ -0,0 +1,84 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.identity import DefaultAzureCredential +from azure.mgmt.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_r_update.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_r.begin_update( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + parameters={ + "identity": {"type": "SystemAssigned"}, + "kind": "SignalR", + "location": "eastus", + "properties": { + "cors": {"allowedOrigins": ["https://foo.com", "https://bar.com"]}, + "disableAadAuth": False, + "disableLocalAuth": False, + "features": [ + {"flag": "ServiceMode", "properties": {}, "value": "Serverless"}, + {"flag": "EnableConnectivityLogs", "properties": {}, "value": "True"}, + {"flag": "EnableMessagingLogs", "properties": {}, "value": "False"}, + {"flag": "EnableLiveTrace", "properties": {}, "value": "False"}, + ], + "liveTraceConfiguration": { + "categories": [{"enabled": "true", "name": "ConnectivityLogs"}], + "enabled": "false", + }, + "networkACLs": { + "defaultAction": "Deny", + "privateEndpoints": [ + {"allow": ["ServerConnection"], "name": "mysignalrservice.1fa229cd-bf3f-47f0-8c49-afb36723997e"} + ], + "publicNetwork": {"allow": ["ClientConnection"]}, + }, + "publicNetworkAccess": "Enabled", + "serverless": {"connectionTimeoutInSeconds": 5}, + "tls": {"clientCertEnabled": False}, + "upstream": { + "templates": [ + { + "auth": {"managedIdentity": {"resource": "api://example"}, "type": "ManagedIdentity"}, + "categoryPattern": "*", + "eventPattern": "connect,disconnect", + "hubPattern": "*", + "urlTemplate": "https://example.com/chat/api/connect", + } + ] + }, + }, + "sku": {"capacity": 1, "name": "Standard_S1", "tier": "Standard"}, + "tags": {"key1": "value1"}, + }, + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalR_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_create_or_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_create_or_update.py new file mode 100644 index 000000000000..99bfa59988c2 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_create_or_update.py @@ -0,0 +1,49 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rcustom_certificates_create_or_update.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rcustom_certificates.begin_create_or_update( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + certificate_name="myCert", + parameters={ + "properties": { + "keyVaultBaseUri": "https://myvault.keyvault.azure.net/", + "keyVaultSecretName": "mycert", + "keyVaultSecretVersion": "bb6a44b2743f47f68dad0d6cc9756432", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRCustomCertificates_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_delete.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_delete.py new file mode 100644 index 000000000000..5b69269cad3b --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_delete.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rcustom_certificates_delete.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rcustom_certificates.delete( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + certificate_name="myCert", + ) + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRCustomCertificates_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_get.py new file mode 100644 index 000000000000..75c924795177 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_get.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rcustom_certificates_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rcustom_certificates.get( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + certificate_name="myCert", + ) + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRCustomCertificates_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_list.py new file mode 100644 index 000000000000..1dd67c6d8993 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_certificates_list.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rcustom_certificates_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rcustom_certificates.list( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRCustomCertificates_List.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_create_or_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_create_or_update.py new file mode 100644 index 000000000000..0aeaf9cf1bfd --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_create_or_update.py @@ -0,0 +1,50 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rcustom_domains_create_or_update.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rcustom_domains.begin_create_or_update( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + name="myDomain", + parameters={ + "properties": { + "customCertificate": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.SignalRService/SignalR/mySignalRService/customCertificates/myCert" + }, + "domainName": "example.com", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRCustomDomains_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_delete.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_delete.py new file mode 100644 index 000000000000..828e57b6cc47 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_delete.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rcustom_domains_delete.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rcustom_domains.begin_delete( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + name="example", + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRCustomDomains_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_get.py new file mode 100644 index 000000000000..320855403c3f --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_get.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rcustom_domains_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rcustom_domains.get( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + name="example", + ) + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRCustomDomains_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_list.py new file mode 100644 index 000000000000..99b79b6a12a3 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rcustom_domains_list.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rcustom_domains_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rcustom_domains.list( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRCustomDomains_List.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_delete.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_delete.py new file mode 100644 index 000000000000..ed708252b100 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_delete.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rprivate_endpoint_connections_delete.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rprivate_endpoint_connections.begin_delete( + private_endpoint_connection_name="mysignalrservice.1fa229cd-bf3f-47f0-8c49-afb36723997e", + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRPrivateEndpointConnections_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_get.py new file mode 100644 index 000000000000..459f0e0d1695 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_get.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rprivate_endpoint_connections_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rprivate_endpoint_connections.get( + private_endpoint_connection_name="mysignalrservice.1fa229cd-bf3f-47f0-8c49-afb36723997e", + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ) + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRPrivateEndpointConnections_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_list.py new file mode 100644 index 000000000000..aef738802dd3 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_list.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rprivate_endpoint_connections_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rprivate_endpoint_connections.list( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRPrivateEndpointConnections_List.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_update.py new file mode 100644 index 000000000000..35d8fd1c09db --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_endpoint_connections_update.py @@ -0,0 +1,50 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rprivate_endpoint_connections_update.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rprivate_endpoint_connections.update( + private_endpoint_connection_name="mysignalrservice.1fa229cd-bf3f-47f0-8c49-afb36723997e", + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + parameters={ + "properties": { + "privateEndpoint": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Network/privateEndpoints/myPrivateEndpoint" + }, + "privateLinkServiceConnectionState": {"actionsRequired": "None", "status": "Approved"}, + } + }, + ) + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRPrivateEndpointConnections_Update.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_link_resources_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_link_resources_list.py new file mode 100644 index 000000000000..fb77ad453990 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rprivate_link_resources_list.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rprivate_link_resources_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rprivate_link_resources.list( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRPrivateLinkResources_List.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_create_or_update.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_create_or_update.py new file mode 100644 index 000000000000..20ffa61afc54 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_create_or_update.py @@ -0,0 +1,49 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rshared_private_link_resources_create_or_update.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rshared_private_link_resources.begin_create_or_update( + shared_private_link_resource_name="upstream", + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + parameters={ + "properties": { + "groupId": "sites", + "privateLinkResourceId": "/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/myResourceGroup/providers/Microsoft.Web/sites/myWebApp", + "requestMessage": "Please approve", + } + }, + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRSharedPrivateLinkResources_CreateOrUpdate.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_delete.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_delete.py new file mode 100644 index 000000000000..de20c46919c0 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_delete.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rshared_private_link_resources_delete.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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rshared_private_link_resources.begin_delete( + shared_private_link_resource_name="upstream", + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ).result() + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRSharedPrivateLinkResources_Delete.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_get.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_get.py new file mode 100644 index 000000000000..0cba89c525af --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_get.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rshared_private_link_resources_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rshared_private_link_resources.get( + shared_private_link_resource_name="upstream", + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ) + print(response) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRSharedPrivateLinkResources_Get.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_list.py new file mode 100644 index 000000000000..533a16915856 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/signal_rshared_private_link_resources_list.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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python signal_rshared_private_link_resources_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.signal_rshared_private_link_resources.list( + resource_group_name="myResourceGroup", + resource_name="mySignalRService", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/SignalRSharedPrivateLinkResources_List.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/generated_samples/usages_list.py b/sdk/signalr/azure-mgmt-signalr/generated_samples/usages_list.py new file mode 100644 index 000000000000..68a29a4eb042 --- /dev/null +++ b/sdk/signalr/azure-mgmt-signalr/generated_samples/usages_list.py @@ -0,0 +1,41 @@ +# 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.signalr import SignalRManagementClient + +""" +# PREREQUISITES + pip install azure-identity + pip install azure-mgmt-signalr +# USAGE + python usages_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, + 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 = SignalRManagementClient( + credential=DefaultAzureCredential(), + subscription_id="00000000-0000-0000-0000-000000000000", + ) + + response = client.usages.list( + location="eastus", + ) + for item in response: + print(item) + + +# x-ms-original-file: specification/signalr/resource-manager/Microsoft.SignalRService/preview/2022-08-01-preview/examples/Usages_List.json +if __name__ == "__main__": + main() diff --git a/sdk/signalr/azure-mgmt-signalr/setup.py b/sdk/signalr/azure-mgmt-signalr/setup.py index cb9f8969e77e..d88f4048968f 100644 --- a/sdk/signalr/azure-mgmt-signalr/setup.py +++ b/sdk/signalr/azure-mgmt-signalr/setup.py @@ -51,11 +51,11 @@ 'Programming Language :: Python', 'Programming Language :: Python :: 3 :: Only', 'Programming Language :: Python :: 3', - 'Programming Language :: Python :: 3.6', 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'License :: OSI Approved :: MIT License', ], zip_safe=False, @@ -65,10 +65,15 @@ 'azure', 'azure.mgmt', ]), + include_package_data=True, + package_data={ + 'pytyped': ['py.typed'], + }, install_requires=[ - 'msrest>=0.6.21', - 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.0,<2.0.0', + "msrest>=0.7.1", + "azure-common~=1.1", + "azure-mgmt-core>=1.3.2,<2.0.0", + "typing-extensions>=4.3.0; python_version<'3.8.0'", ], - python_requires=">=3.6" + python_requires=">=3.7" ) diff --git a/shared_requirements.txt b/shared_requirements.txt index ea3708929ddb..8c88df504850 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -493,8 +493,8 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-eventgrid azure-mgmt-core>=1.3.2,<2.0.0 #override azure-mgmt-frontdoor msrest>=0.6.21 #override azure-mgmt-frontdoor azure-mgmt-core>=1.3.0,<2.0.0 -#override azure-mgmt-signalr msrest>=0.6.21 -#override azure-mgmt-signalr azure-mgmt-core>=1.3.0,<2.0.0 +#override azure-mgmt-signalr msrest>=0.7.1 +#override azure-mgmt-signalr azure-mgmt-core>=1.3.2,<2.0.0 #override azure-mgmt-machinelearningcompute typing-extensions>=4.3.0; python_version<'3.8.0' #override azure-mgmt-iotcentral msrest>=0.6.21 #override azure-mgmt-iotcentral azure-mgmt-core>=1.3.0,<2.0.0 @@ -694,6 +694,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-resourcegraph msrest>=0.7.1 #override azure-core-experimental azure-core<2.0.0,>=1.25.0 #override azure-developer-devcenter isodate<1.0.0,>=0.6.1 +#override azure-mgmt-signalr typing-extensions>=4.3.0; python_version<'3.8.0' #override azure-developer-devcenter azure-core<2.0.0,>=1.24.0 #override azure-ai-anomalydetector isodate<1.0.0,>=0.6.1 #override azure-ai-anomalydetector azure-core<2.0.0,>=1.24.0 From 7080e2af45d1cc6f03ab720ee97fe76ddf7d3e81 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 16 Nov 2022 21:27:46 -0500 Subject: [PATCH 5/7] [AutoRelease] t2-security-2022-11-10-60439(can only be merged by SDK owner) (#27420) * code and test * Update CHANGELOG.md Co-authored-by: PythonSdkPipelines Co-authored-by: zhenbiao wei <424401670@qq.com> --- sdk/security/azure-mgmt-security/CHANGELOG.md | 13 + sdk/security/azure-mgmt-security/_meta.json | 12 +- .../azure/mgmt/security/_security_center.py | 67 + .../azure/mgmt/security/_version.py | 2 +- .../mgmt/security/aio/_security_center.py | 67 + .../security/v2015_06_01_preview/__init__.py | 4 +- .../v2015_06_01_preview/_configuration.py | 8 +- .../v2015_06_01_preview/_metadata.json | 2 +- .../security/v2015_06_01_preview/_version.py | 2 +- .../v2015_06_01_preview/aio/__init__.py | 4 +- .../v2015_06_01_preview/aio/_configuration.py | 8 +- .../aio/operations/_locations_operations.py | 28 +- .../aio/operations/_operations.py | 24 +- .../aio/operations/_tasks_operations.py | 78 +- .../v2015_06_01_preview/models/_models_py3.py | 7 +- .../operations/_locations_operations.py | 36 +- .../operations/_operations.py | 28 +- .../operations/_tasks_operations.py | 110 +- .../mgmt/security/v2017_08_01/__init__.py | 4 +- .../security/v2017_08_01/_configuration.py | 8 +- .../mgmt/security/v2017_08_01/_metadata.json | 2 +- .../mgmt/security/v2017_08_01/_version.py | 2 +- .../mgmt/security/v2017_08_01/aio/__init__.py | 4 +- .../v2017_08_01/aio/_configuration.py | 8 +- .../_compliance_results_operations.py | 24 +- .../_compliance_results_operations.py | 28 +- .../security/v2017_08_01_preview/__init__.py | 4 +- .../v2017_08_01_preview/_configuration.py | 8 +- .../v2017_08_01_preview/_metadata.json | 2 +- .../security/v2017_08_01_preview/_version.py | 2 +- .../v2017_08_01_preview/aio/__init__.py | 4 +- .../v2017_08_01_preview/aio/_configuration.py | 8 +- .../_auto_provisioning_settings_operations.py | 32 +- .../aio/operations/_compliances_operations.py | 28 +- ...ormation_protection_policies_operations.py | 40 +- .../_security_contacts_operations.py | 40 +- .../_workspace_settings_operations.py | 40 +- .../_auto_provisioning_settings_operations.py | 44 +- .../operations/_compliances_operations.py | 36 +- ...ormation_protection_policies_operations.py | 56 +- .../_security_contacts_operations.py | 60 +- .../_workspace_settings_operations.py | 60 +- .../mgmt/security/v2018_06_01/__init__.py | 4 +- .../security/v2018_06_01/_configuration.py | 8 +- .../mgmt/security/v2018_06_01/_metadata.json | 2 +- .../mgmt/security/v2018_06_01/_version.py | 2 +- .../mgmt/security/v2018_06_01/aio/__init__.py | 4 +- .../v2018_06_01/aio/_configuration.py | 8 +- .../aio/operations/_pricings_operations.py | 11 +- .../operations/_pricings_operations.py | 17 +- .../mgmt/security/v2019_01_01/__init__.py | 4 +- .../security/v2019_01_01/_configuration.py | 8 +- .../mgmt/security/v2019_01_01/_metadata.json | 2 +- .../mgmt/security/v2019_01_01/_version.py | 2 +- .../mgmt/security/v2019_01_01/aio/__init__.py | 4 +- .../v2019_01_01/aio/_configuration.py | 8 +- .../_advanced_threat_protection_operations.py | 13 +- .../_advanced_threat_protection_operations.py | 21 +- .../security/v2019_01_01_preview/__init__.py | 4 +- .../v2019_01_01_preview/_configuration.py | 8 +- .../v2019_01_01_preview/_metadata.json | 2 +- .../security/v2019_01_01_preview/_version.py | 2 +- .../v2019_01_01_preview/aio/__init__.py | 4 +- .../v2019_01_01_preview/aio/_configuration.py | 8 +- .../_alerts_suppression_rules_operations.py | 36 +- .../aio/operations/_automations_operations.py | 57 +- ...atory_compliance_assessments_operations.py | 28 +- ...gulatory_compliance_controls_operations.py | 28 +- ...ulatory_compliance_standards_operations.py | 28 +- .../operations/_sub_assessments_operations.py | 45 +- .../_alerts_suppression_rules_operations.py | 52 +- .../operations/_automations_operations.py | 81 +- ...atory_compliance_assessments_operations.py | 36 +- ...gulatory_compliance_controls_operations.py | 36 +- ...ulatory_compliance_standards_operations.py | 36 +- .../operations/_sub_assessments_operations.py | 57 +- .../mgmt/security/v2019_08_01/__init__.py | 4 +- .../security/v2019_08_01/_configuration.py | 8 +- .../mgmt/security/v2019_08_01/_metadata.json | 2 +- .../mgmt/security/v2019_08_01/_version.py | 2 +- .../mgmt/security/v2019_08_01/aio/__init__.py | 4 +- .../v2019_08_01/aio/_configuration.py | 8 +- .../_device_security_groups_operations.py | 28 +- ..._security_solution_analytics_operations.py | 9 +- .../_iot_security_solution_operations.py | 45 +- ...s_analytics_aggregated_alert_operations.py | 26 +- ...ons_analytics_recommendation_operations.py | 24 +- .../_device_security_groups_operations.py | 36 +- ..._security_solution_analytics_operations.py | 13 +- .../_iot_security_solution_operations.py | 57 +- ...s_analytics_aggregated_alert_operations.py | 32 +- ...ons_analytics_recommendation_operations.py | 28 +- .../mgmt/security/v2020_01_01/__init__.py | 4 +- .../security/v2020_01_01/_configuration.py | 8 +- .../mgmt/security/v2020_01_01/_metadata.json | 2 +- .../mgmt/security/v2020_01_01/_version.py | 2 +- .../mgmt/security/v2020_01_01/aio/__init__.py | 4 +- .../v2020_01_01/aio/_configuration.py | 8 +- .../v2020_01_01/aio/operations/__init__.py | 33 +- ...daptive_application_controls_operations.py | 145 +- ..._adaptive_network_hardenings_operations.py | 166 +- .../_allowed_connections_operations.py | 139 +- .../_assessments_metadata_operations.py | 226 +- .../aio/operations/_assessments_operations.py | 159 +- ...iscovered_security_solutions_operations.py | 143 +- ..._external_security_solutions_operations.py | 143 +- ..._jit_network_access_policies_operations.py | 322 +- .../v2020_01_01/aio/operations/_patch.py | 1 + ...re_score_control_definitions_operations.py | 114 +- .../_secure_score_controls_operations.py | 108 +- .../operations/_secure_scores_operations.py | 94 +- .../_security_solutions_operations.py | 94 +- ...ity_solutions_reference_data_operations.py | 81 +- ...ver_vulnerability_assessment_operations.py | 204 +- .../aio/operations/_topology_operations.py | 139 +- .../security/v2020_01_01/models/__init__.py | 223 +- .../v2020_01_01/models/_models_py3.py | 813 ++--- .../models/_security_center_enums.py | 120 +- ...daptive_application_controls_operations.py | 21 +- ..._adaptive_network_hardenings_operations.py | 40 +- .../_allowed_connections_operations.py | 49 +- .../_assessments_metadata_operations.py | 57 +- .../operations/_assessments_operations.py | 40 +- ...iscovered_security_solutions_operations.py | 45 +- ..._external_security_solutions_operations.py | 45 +- ..._jit_network_access_policies_operations.py | 95 +- ...re_score_control_definitions_operations.py | 41 +- .../_secure_score_controls_operations.py | 49 +- .../operations/_secure_scores_operations.py | 28 +- .../_security_solutions_operations.py | 28 +- ...ity_solutions_reference_data_operations.py | 13 +- ...ver_vulnerability_assessment_operations.py | 51 +- .../operations/_topology_operations.py | 45 +- .../security/v2020_01_01_preview/__init__.py | 4 +- .../v2020_01_01_preview/_configuration.py | 8 +- .../v2020_01_01_preview/_metadata.json | 2 +- .../security/v2020_01_01_preview/_version.py | 2 +- .../v2020_01_01_preview/aio/__init__.py | 5 +- .../v2020_01_01_preview/aio/_configuration.py | 46 +- .../aio/_security_center.py | 12 +- .../aio/operations/__init__.py | 5 +- .../aio/operations/_connectors_operations.py | 173 +- .../aio/operations/_patch.py | 1 + .../v2020_01_01_preview/models/__init__.py | 37 +- .../v2020_01_01_preview/models/_models_py3.py | 183 +- .../models/_security_center_enums.py | 16 +- .../operations/__init__.py | 5 +- .../operations/_connectors_operations.py | 321 +- .../security/v2020_07_01_preview/__init__.py | 4 +- .../v2020_07_01_preview/_configuration.py | 8 +- .../v2020_07_01_preview/_metadata.json | 2 +- .../security/v2020_07_01_preview/_version.py | 2 +- .../v2020_07_01_preview/aio/__init__.py | 4 +- .../v2020_07_01_preview/aio/_configuration.py | 8 +- ...ty_assessment_baseline_rules_operations.py | 25 +- ...lity_assessment_scan_results_operations.py | 13 +- ...lnerability_assessment_scans_operations.py | 13 +- ...ty_assessment_baseline_rules_operations.py | 45 +- ...lity_assessment_scan_results_operations.py | 21 +- ...lnerability_assessment_scans_operations.py | 21 +- .../mgmt/security/v2021_01_01/__init__.py | 4 +- .../security/v2021_01_01/_configuration.py | 8 +- .../mgmt/security/v2021_01_01/_metadata.json | 2 +- .../mgmt/security/v2021_01_01/_version.py | 2 +- .../mgmt/security/v2021_01_01/aio/__init__.py | 4 +- .../v2021_01_01/aio/_configuration.py | 8 +- .../aio/operations/_alerts_operations.py | 87 +- .../v2021_01_01/models/_models_py3.py | 7 +- .../operations/_alerts_operations.py | 113 +- .../security/v2021_01_15_preview/__init__.py | 4 +- .../v2021_01_15_preview/_configuration.py | 8 +- .../v2021_01_15_preview/_metadata.json | 2 +- .../security/v2021_01_15_preview/_version.py | 2 +- .../v2021_01_15_preview/aio/__init__.py | 4 +- .../v2021_01_15_preview/aio/_configuration.py | 8 +- .../_ingestion_settings_operations.py | 44 +- .../_ingestion_settings_operations.py | 68 +- .../security/v2021_05_01_preview/__init__.py | 4 +- .../v2021_05_01_preview/_configuration.py | 8 +- .../v2021_05_01_preview/_metadata.json | 2 +- .../security/v2021_05_01_preview/_version.py | 2 +- .../v2021_05_01_preview/aio/__init__.py | 4 +- .../v2021_05_01_preview/aio/_configuration.py | 8 +- .../_software_inventories_operations.py | 45 +- .../_software_inventories_operations.py | 57 +- .../mgmt/security/v2021_06_01/__init__.py | 4 +- .../security/v2021_06_01/_configuration.py | 8 +- .../mgmt/security/v2021_06_01/_metadata.json | 2 +- .../mgmt/security/v2021_06_01/_version.py | 2 +- .../mgmt/security/v2021_06_01/aio/__init__.py | 4 +- .../v2021_06_01/aio/_configuration.py | 8 +- .../_assessments_metadata_operations.py | 45 +- .../aio/operations/_assessments_operations.py | 30 +- .../aio/operations/_settings_operations.py | 34 +- .../_assessments_metadata_operations.py | 57 +- .../operations/_assessments_operations.py | 40 +- .../operations/_settings_operations.py | 44 +- .../mgmt/security/v2021_07_01/__init__.py | 4 +- .../security/v2021_07_01/_configuration.py | 8 +- .../mgmt/security/v2021_07_01/_metadata.json | 2 +- .../mgmt/security/v2021_07_01/_version.py | 2 +- .../mgmt/security/v2021_07_01/aio/__init__.py | 5 +- .../v2021_07_01/aio/_configuration.py | 46 +- .../mgmt/security/v2021_07_01/aio/_patch.py | 1 + .../v2021_07_01/aio/_security_center.py | 12 +- .../v2021_07_01/aio/operations/__init__.py | 5 +- .../v2021_07_01/aio/operations/_patch.py | 1 + .../aio/operations/_settings_operations.py | 130 +- .../security/v2021_07_01/models/__init__.py | 21 +- .../v2021_07_01/models/_models_py3.py | 107 +- .../security/v2021_07_01/models/_patch.py | 1 + .../models/_security_center_enums.py | 7 +- .../v2021_07_01/operations/__init__.py | 5 +- .../security/v2021_07_01/operations/_patch.py | 1 + .../operations/_settings_operations.py | 227 +- .../security/v2021_07_01_preview/__init__.py | 4 +- .../v2021_07_01_preview/_configuration.py | 8 +- .../v2021_07_01_preview/_metadata.json | 2 +- .../security/v2021_07_01_preview/_version.py | 2 +- .../v2021_07_01_preview/aio/__init__.py | 4 +- .../v2021_07_01_preview/aio/_configuration.py | 8 +- ...ustom_assessment_automations_operations.py | 53 +- ...tom_entity_store_assignments_operations.py | 53 +- .../_security_connectors_operations.py | 57 +- ...ustom_assessment_automations_operations.py | 73 +- ...tom_entity_store_assignments_operations.py | 73 +- .../_security_connectors_operations.py | 81 +- .../security/v2021_10_01_preview/__init__.py | 4 +- .../v2021_10_01_preview/_configuration.py | 8 +- .../v2021_10_01_preview/_metadata.json | 2 +- .../security/v2021_10_01_preview/_version.py | 2 +- .../v2021_10_01_preview/aio/__init__.py | 4 +- .../v2021_10_01_preview/aio/_configuration.py | 8 +- .../operations/_mde_onboardings_operations.py | 13 +- .../operations/_mde_onboardings_operations.py | 21 +- .../mgmt/security/v2022_01_01/__init__.py | 4 +- .../security/v2022_01_01/_configuration.py | 8 +- .../mgmt/security/v2022_01_01/_metadata.json | 2 +- .../mgmt/security/v2022_01_01/_version.py | 2 +- .../mgmt/security/v2022_01_01/aio/__init__.py | 4 +- .../v2022_01_01/aio/_configuration.py | 8 +- .../aio/operations/_alerts_operations.py | 91 +- .../v2022_01_01/models/_models_py3.py | 7 +- .../operations/_alerts_operations.py | 121 +- .../security/v2022_01_01_preview/__init__.py | 4 +- .../v2022_01_01_preview/_configuration.py | 8 +- .../v2022_01_01_preview/_metadata.json | 2 +- .../security/v2022_01_01_preview/_version.py | 2 +- .../v2022_01_01_preview/aio/__init__.py | 4 +- .../v2022_01_01_preview/aio/_configuration.py | 8 +- .../_governance_assignments_operations.py | 36 +- .../operations/_governance_rule_operations.py | 24 +- .../_governance_rules_operations.py | 33 +- ...ty_connector_governance_rule_operations.py | 24 +- ...ernance_rules_execute_status_operations.py | 13 +- ...y_connector_governance_rules_operations.py | 17 +- ...ernance_rules_execute_status_operations.py | 13 +- .../v2022_01_01_preview/models/_models_py3.py | 7 +- .../_governance_assignments_operations.py | 52 +- .../operations/_governance_rule_operations.py | 28 +- .../_governance_rules_operations.py | 53 +- ...ty_connector_governance_rule_operations.py | 28 +- ...ernance_rules_execute_status_operations.py | 17 +- ...y_connector_governance_rules_operations.py | 29 +- ...ernance_rules_execute_status_operations.py | 17 +- .../mgmt/security/v2022_03_01/__init__.py | 4 +- .../security/v2022_03_01/_configuration.py | 8 +- .../mgmt/security/v2022_03_01/_metadata.json | 2 +- .../mgmt/security/v2022_03_01/_version.py | 2 +- .../mgmt/security/v2022_03_01/aio/__init__.py | 4 +- .../v2022_03_01/aio/_configuration.py | 8 +- .../aio/operations/_pricings_operations.py | 11 +- .../operations/_pricings_operations.py | 17 +- .../mgmt/security/v2022_05_01/__init__.py | 4 +- .../security/v2022_05_01/_configuration.py | 8 +- .../mgmt/security/v2022_05_01/_metadata.json | 2 +- .../mgmt/security/v2022_05_01/_version.py | 2 +- .../mgmt/security/v2022_05_01/aio/__init__.py | 4 +- .../v2022_05_01/aio/_configuration.py | 8 +- .../aio/operations/_settings_operations.py | 34 +- .../operations/_settings_operations.py | 44 +- .../security/v2022_05_01_preview/__init__.py | 4 +- .../v2022_05_01_preview/_configuration.py | 8 +- .../v2022_05_01_preview/_metadata.json | 2 +- .../security/v2022_05_01_preview/_version.py | 2 +- .../v2022_05_01_preview/aio/__init__.py | 4 +- .../v2022_05_01_preview/aio/_configuration.py | 8 +- .../_security_connectors_operations.py | 57 +- .../v2022_05_01_preview/models/_models_py3.py | 7 +- .../_security_connectors_operations.py | 81 +- .../security/v2022_07_01_preview/__init__.py | 4 +- .../v2022_07_01_preview/_configuration.py | 8 +- .../v2022_07_01_preview/_metadata.json | 2 +- .../security/v2022_07_01_preview/_version.py | 2 +- .../v2022_07_01_preview/aio/__init__.py | 4 +- .../v2022_07_01_preview/aio/_configuration.py | 8 +- .../aio/operations/_application_operations.py | 17 +- .../operations/_applications_operations.py | 24 +- ...curity_connector_application_operations.py | 17 +- ...urity_connector_applications_operations.py | 24 +- .../v2022_07_01_preview/models/_models_py3.py | 11 +- .../models/_security_center_enums.py | 2 + .../operations/_application_operations.py | 29 +- .../operations/_applications_operations.py | 28 +- ...curity_connector_application_operations.py | 29 +- ...urity_connector_applications_operations.py | 28 +- .../security/v2022_08_01_preview/__init__.py | 26 + .../v2022_08_01_preview/_configuration.py | 75 + .../v2022_08_01_preview/_metadata.json | 102 + .../security/v2022_08_01_preview/_patch.py | 20 + .../v2022_08_01_preview/_security_center.py | 93 + .../security/v2022_08_01_preview/_vendor.py | 27 + .../security/v2022_08_01_preview/_version.py | 9 + .../v2022_08_01_preview/aio/__init__.py | 23 + .../v2022_08_01_preview/aio/_configuration.py | 72 + .../v2022_08_01_preview/aio/_patch.py | 20 + .../aio/_security_center.py | 90 + .../aio/operations/__init__.py | 19 + .../aio/operations/_patch.py | 20 + .../_security_connectors_operations.py | 651 ++++ .../v2022_08_01_preview/models/__init__.py | 173 ++ .../v2022_08_01_preview/models/_models_py3.py | 2767 +++++++++++++++++ .../v2022_08_01_preview/models/_patch.py | 20 + .../models/_security_center_enums.py | 85 + .../operations/__init__.py | 19 + .../v2022_08_01_preview/operations/_patch.py | 20 + .../_security_connectors_operations.py | 858 +++++ .../security/v2022_08_01_preview/py.typed | 1 + sdk/security/azure-mgmt-security/setup.py | 8 +- shared_requirements.txt | 1 + 330 files changed, 11651 insertions(+), 3798 deletions(-) create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/__init__.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_configuration.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_metadata.json create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_patch.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_security_center.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_vendor.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_version.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/__init__.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_configuration.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_patch.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_security_center.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/__init__.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_patch.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_security_connectors_operations.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/__init__.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_models_py3.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_patch.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_security_center_enums.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/__init__.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_patch.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_security_connectors_operations.py create mode 100644 sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/py.typed diff --git a/sdk/security/azure-mgmt-security/CHANGELOG.md b/sdk/security/azure-mgmt-security/CHANGELOG.md index d99aeb40e59f..9628dc43d174 100644 --- a/sdk/security/azure-mgmt-security/CHANGELOG.md +++ b/sdk/security/azure-mgmt-security/CHANGELOG.md @@ -1,5 +1,18 @@ # Release History +## 3.0.0 (2022-11-17) + +### Features Added + + - Model DefenderFoDatabasesAwsOffering has a new parameter rds + +### Breaking Changes + + - Model DefenderFoDatabasesAwsOfferingArcAutoProvisioning no longer has parameter service_principal_secret_metadata + - Model DefenderForDatabasesGcpOfferingArcAutoProvisioning no longer has parameter configuration + - Model DefenderForServersAwsOfferingArcAutoProvisioning no longer has parameter service_principal_secret_metadata + - Model DefenderForServersGcpOfferingArcAutoProvisioning no longer has parameter configuration + ## 2.0.0 (2022-09-28) ### Features Added diff --git a/sdk/security/azure-mgmt-security/_meta.json b/sdk/security/azure-mgmt-security/_meta.json index 00c8bc4daefe..a57d3149f444 100644 --- a/sdk/security/azure-mgmt-security/_meta.json +++ b/sdk/security/azure-mgmt-security/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.8.4", + "commit": "8a20cee044fafde7ae0364edab45a577aa80d20f", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@6.1.5", - "@autorest/modelerfour@4.23.5" + "@autorest/python@6.2.1", + "@autorest/modelerfour@4.24.3" ], - "commit": "e21f2da8dacad060a3612dc8ae0fe6de48b15986", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/security/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/python@6.1.5 --use=@autorest/modelerfour@4.23.5 --version=3.8.4 --version-tolerant=False", + "autorest_command": "autorest specification/security/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.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/security/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/_security_center.py index ec01da6ea1fa..a9cabbbfa717 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_security_center.py @@ -163,6 +163,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-05-01: :mod:`v2022_05_01.models` * 2022-05-01-preview: :mod:`v2022_05_01_preview.models` * 2022-07-01-preview: :mod:`v2022_07_01_preview.models` + * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` """ if api_version == '2015-06-01-preview': from .v2015_06_01_preview import models @@ -233,6 +234,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-07-01-preview': from .v2022_07_01_preview import models return models + elif api_version == '2022-08-01-preview': + from .v2022_08_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -246,6 +250,7 @@ def adaptive_application_controls(self): from .v2020_01_01.operations import AdaptiveApplicationControlsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'adaptive_application_controls'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -259,6 +264,7 @@ def adaptive_network_hardenings(self): from .v2020_01_01.operations import AdaptiveNetworkHardeningsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'adaptive_network_hardenings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -272,6 +278,7 @@ def advanced_threat_protection(self): from .v2019_01_01.operations import AdvancedThreatProtectionOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'advanced_threat_protection'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -288,6 +295,7 @@ def alerts(self): from .v2022_01_01.operations import AlertsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -301,6 +309,7 @@ def alerts_suppression_rules(self): from .v2019_01_01_preview.operations import AlertsSuppressionRulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alerts_suppression_rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -314,6 +323,7 @@ def allowed_connections(self): from .v2020_01_01.operations import AllowedConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'allowed_connections'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -327,6 +337,7 @@ def application(self): from .v2022_07_01_preview.operations import ApplicationOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'application'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -340,6 +351,7 @@ def applications(self): from .v2022_07_01_preview.operations import ApplicationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'applications'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -356,6 +368,7 @@ def assessments(self): from .v2021_06_01.operations import AssessmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'assessments'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -372,6 +385,7 @@ def assessments_metadata(self): from .v2021_06_01.operations import AssessmentsMetadataOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'assessments_metadata'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -385,6 +399,7 @@ def auto_provisioning_settings(self): from .v2017_08_01_preview.operations import AutoProvisioningSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'auto_provisioning_settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -398,6 +413,7 @@ def automations(self): from .v2019_01_01_preview.operations import AutomationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'automations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -411,6 +427,7 @@ def compliance_results(self): from .v2017_08_01.operations import ComplianceResultsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'compliance_results'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -424,6 +441,7 @@ def compliances(self): from .v2017_08_01_preview.operations import CompliancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'compliances'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -437,6 +455,7 @@ def connectors(self): from .v2020_01_01_preview.operations import ConnectorsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'connectors'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -450,6 +469,7 @@ def custom_assessment_automations(self): from .v2021_07_01_preview.operations import CustomAssessmentAutomationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'custom_assessment_automations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -463,6 +483,7 @@ def custom_entity_store_assignments(self): from .v2021_07_01_preview.operations import CustomEntityStoreAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'custom_entity_store_assignments'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -476,6 +497,7 @@ def device_security_groups(self): from .v2019_08_01.operations import DeviceSecurityGroupsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'device_security_groups'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -489,6 +511,7 @@ def discovered_security_solutions(self): from .v2020_01_01.operations import DiscoveredSecuritySolutionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'discovered_security_solutions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -502,6 +525,7 @@ def external_security_solutions(self): from .v2020_01_01.operations import ExternalSecuritySolutionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'external_security_solutions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -515,6 +539,7 @@ def governance_assignments(self): from .v2022_01_01_preview.operations import GovernanceAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'governance_assignments'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -528,6 +553,7 @@ def governance_rule(self): from .v2022_01_01_preview.operations import GovernanceRuleOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'governance_rule'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -541,6 +567,7 @@ def governance_rules(self): from .v2022_01_01_preview.operations import GovernanceRulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'governance_rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -554,6 +581,7 @@ def information_protection_policies(self): from .v2017_08_01_preview.operations import InformationProtectionPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'information_protection_policies'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -567,6 +595,7 @@ def ingestion_settings(self): from .v2021_01_15_preview.operations import IngestionSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'ingestion_settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -580,6 +609,7 @@ def iot_security_solution(self): from .v2019_08_01.operations import IotSecuritySolutionOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_security_solution'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -593,6 +623,7 @@ def iot_security_solution_analytics(self): from .v2019_08_01.operations import IotSecuritySolutionAnalyticsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_security_solution_analytics'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -606,6 +637,7 @@ def iot_security_solutions_analytics_aggregated_alert(self): from .v2019_08_01.operations import IotSecuritySolutionsAnalyticsAggregatedAlertOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_aggregated_alert'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -619,6 +651,7 @@ def iot_security_solutions_analytics_recommendation(self): from .v2019_08_01.operations import IotSecuritySolutionsAnalyticsRecommendationOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_recommendation'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -632,6 +665,7 @@ def jit_network_access_policies(self): from .v2020_01_01.operations import JitNetworkAccessPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'jit_network_access_policies'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -645,6 +679,7 @@ def locations(self): from .v2015_06_01_preview.operations import LocationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'locations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -658,6 +693,7 @@ def mde_onboardings(self): from .v2021_10_01_preview.operations import MdeOnboardingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'mde_onboardings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -671,6 +707,7 @@ def operations(self): from .v2015_06_01_preview.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -687,6 +724,7 @@ def pricings(self): from .v2022_03_01.operations import PricingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'pricings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -700,6 +738,7 @@ def regulatory_compliance_assessments(self): from .v2019_01_01_preview.operations import RegulatoryComplianceAssessmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_assessments'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -713,6 +752,7 @@ def regulatory_compliance_controls(self): from .v2019_01_01_preview.operations import RegulatoryComplianceControlsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_controls'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -726,6 +766,7 @@ def regulatory_compliance_standards(self): from .v2019_01_01_preview.operations import RegulatoryComplianceStandardsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_standards'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -739,6 +780,7 @@ def secure_score_control_definitions(self): from .v2020_01_01.operations import SecureScoreControlDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'secure_score_control_definitions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -752,6 +794,7 @@ def secure_score_controls(self): from .v2020_01_01.operations import SecureScoreControlsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'secure_score_controls'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -765,6 +808,7 @@ def secure_scores(self): from .v2020_01_01.operations import SecureScoresOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'secure_scores'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -778,6 +822,7 @@ def security_connector_application(self): from .v2022_07_01_preview.operations import SecurityConnectorApplicationOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connector_application'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -791,6 +836,7 @@ def security_connector_applications(self): from .v2022_07_01_preview.operations import SecurityConnectorApplicationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connector_applications'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -804,6 +850,7 @@ def security_connector_governance_rule(self): from .v2022_01_01_preview.operations import SecurityConnectorGovernanceRuleOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connector_governance_rule'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -817,6 +864,7 @@ def security_connector_governance_rules(self): from .v2022_01_01_preview.operations import SecurityConnectorGovernanceRulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connector_governance_rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -830,6 +878,7 @@ def security_connector_governance_rules_execute_status(self): from .v2022_01_01_preview.operations import SecurityConnectorGovernanceRulesExecuteStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connector_governance_rules_execute_status'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -838,14 +887,18 @@ def security_connectors(self): * 2021-07-01-preview: :class:`SecurityConnectorsOperations` * 2022-05-01-preview: :class:`SecurityConnectorsOperations` + * 2022-08-01-preview: :class:`SecurityConnectorsOperations` """ api_version = self._get_api_version('security_connectors') if api_version == '2021-07-01-preview': from .v2021_07_01_preview.operations import SecurityConnectorsOperations as OperationClass elif api_version == '2022-05-01-preview': from .v2022_05_01_preview.operations import SecurityConnectorsOperations as OperationClass + elif api_version == '2022-08-01-preview': + from .v2022_08_01_preview.operations import SecurityConnectorsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connectors'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -859,6 +912,7 @@ def security_contacts(self): from .v2017_08_01_preview.operations import SecurityContactsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_contacts'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -872,6 +926,7 @@ def security_solutions(self): from .v2020_01_01.operations import SecuritySolutionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_solutions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -885,6 +940,7 @@ def security_solutions_reference_data(self): from .v2020_01_01.operations import SecuritySolutionsReferenceDataOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_solutions_reference_data'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -898,6 +954,7 @@ def server_vulnerability_assessment(self): from .v2020_01_01.operations import ServerVulnerabilityAssessmentOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'server_vulnerability_assessment'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -917,6 +974,7 @@ def settings(self): from .v2022_05_01.operations import SettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -930,6 +988,7 @@ def software_inventories(self): from .v2021_05_01_preview.operations import SoftwareInventoriesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'software_inventories'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -943,6 +1002,7 @@ def sql_vulnerability_assessment_baseline_rules(self): from .v2020_07_01_preview.operations import SqlVulnerabilityAssessmentBaselineRulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_baseline_rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -956,6 +1016,7 @@ def sql_vulnerability_assessment_scan_results(self): from .v2020_07_01_preview.operations import SqlVulnerabilityAssessmentScanResultsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scan_results'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -969,6 +1030,7 @@ def sql_vulnerability_assessment_scans(self): from .v2020_07_01_preview.operations import SqlVulnerabilityAssessmentScansOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scans'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -982,6 +1044,7 @@ def sub_assessments(self): from .v2019_01_01_preview.operations import SubAssessmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'sub_assessments'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -995,6 +1058,7 @@ def subscription_governance_rules_execute_status(self): from .v2022_01_01_preview.operations import SubscriptionGovernanceRulesExecuteStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'subscription_governance_rules_execute_status'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -1008,6 +1072,7 @@ def tasks(self): from .v2015_06_01_preview.operations import TasksOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tasks'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -1021,6 +1086,7 @@ def topology(self): from .v2020_01_01.operations import TopologyOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'topology'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -1034,6 +1100,7 @@ def workspace_settings(self): from .v2017_08_01_preview.operations import WorkspaceSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'workspace_settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) def close(self): diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_security_center.py index 0e3e80c256c6..88bde0dbc421 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/aio/_security_center.py @@ -163,6 +163,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2022-05-01: :mod:`v2022_05_01.models` * 2022-05-01-preview: :mod:`v2022_05_01_preview.models` * 2022-07-01-preview: :mod:`v2022_07_01_preview.models` + * 2022-08-01-preview: :mod:`v2022_08_01_preview.models` """ if api_version == '2015-06-01-preview': from ..v2015_06_01_preview import models @@ -233,6 +234,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-07-01-preview': from ..v2022_07_01_preview import models return models + elif api_version == '2022-08-01-preview': + from ..v2022_08_01_preview import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -246,6 +250,7 @@ def adaptive_application_controls(self): from ..v2020_01_01.aio.operations import AdaptiveApplicationControlsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'adaptive_application_controls'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -259,6 +264,7 @@ def adaptive_network_hardenings(self): from ..v2020_01_01.aio.operations import AdaptiveNetworkHardeningsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'adaptive_network_hardenings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -272,6 +278,7 @@ def advanced_threat_protection(self): from ..v2019_01_01.aio.operations import AdvancedThreatProtectionOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'advanced_threat_protection'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -288,6 +295,7 @@ def alerts(self): from ..v2022_01_01.aio.operations import AlertsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alerts'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -301,6 +309,7 @@ def alerts_suppression_rules(self): from ..v2019_01_01_preview.aio.operations import AlertsSuppressionRulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'alerts_suppression_rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -314,6 +323,7 @@ def allowed_connections(self): from ..v2020_01_01.aio.operations import AllowedConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'allowed_connections'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -327,6 +337,7 @@ def application(self): from ..v2022_07_01_preview.aio.operations import ApplicationOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'application'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -340,6 +351,7 @@ def applications(self): from ..v2022_07_01_preview.aio.operations import ApplicationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'applications'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -356,6 +368,7 @@ def assessments(self): from ..v2021_06_01.aio.operations import AssessmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'assessments'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -372,6 +385,7 @@ def assessments_metadata(self): from ..v2021_06_01.aio.operations import AssessmentsMetadataOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'assessments_metadata'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -385,6 +399,7 @@ def auto_provisioning_settings(self): from ..v2017_08_01_preview.aio.operations import AutoProvisioningSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'auto_provisioning_settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -398,6 +413,7 @@ def automations(self): from ..v2019_01_01_preview.aio.operations import AutomationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'automations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -411,6 +427,7 @@ def compliance_results(self): from ..v2017_08_01.aio.operations import ComplianceResultsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'compliance_results'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -424,6 +441,7 @@ def compliances(self): from ..v2017_08_01_preview.aio.operations import CompliancesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'compliances'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -437,6 +455,7 @@ def connectors(self): from ..v2020_01_01_preview.aio.operations import ConnectorsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'connectors'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -450,6 +469,7 @@ def custom_assessment_automations(self): from ..v2021_07_01_preview.aio.operations import CustomAssessmentAutomationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'custom_assessment_automations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -463,6 +483,7 @@ def custom_entity_store_assignments(self): from ..v2021_07_01_preview.aio.operations import CustomEntityStoreAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'custom_entity_store_assignments'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -476,6 +497,7 @@ def device_security_groups(self): from ..v2019_08_01.aio.operations import DeviceSecurityGroupsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'device_security_groups'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -489,6 +511,7 @@ def discovered_security_solutions(self): from ..v2020_01_01.aio.operations import DiscoveredSecuritySolutionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'discovered_security_solutions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -502,6 +525,7 @@ def external_security_solutions(self): from ..v2020_01_01.aio.operations import ExternalSecuritySolutionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'external_security_solutions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -515,6 +539,7 @@ def governance_assignments(self): from ..v2022_01_01_preview.aio.operations import GovernanceAssignmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'governance_assignments'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -528,6 +553,7 @@ def governance_rule(self): from ..v2022_01_01_preview.aio.operations import GovernanceRuleOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'governance_rule'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -541,6 +567,7 @@ def governance_rules(self): from ..v2022_01_01_preview.aio.operations import GovernanceRulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'governance_rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -554,6 +581,7 @@ def information_protection_policies(self): from ..v2017_08_01_preview.aio.operations import InformationProtectionPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'information_protection_policies'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -567,6 +595,7 @@ def ingestion_settings(self): from ..v2021_01_15_preview.aio.operations import IngestionSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'ingestion_settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -580,6 +609,7 @@ def iot_security_solution(self): from ..v2019_08_01.aio.operations import IotSecuritySolutionOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_security_solution'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -593,6 +623,7 @@ def iot_security_solution_analytics(self): from ..v2019_08_01.aio.operations import IotSecuritySolutionAnalyticsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_security_solution_analytics'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -606,6 +637,7 @@ def iot_security_solutions_analytics_aggregated_alert(self): from ..v2019_08_01.aio.operations import IotSecuritySolutionsAnalyticsAggregatedAlertOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_aggregated_alert'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -619,6 +651,7 @@ def iot_security_solutions_analytics_recommendation(self): from ..v2019_08_01.aio.operations import IotSecuritySolutionsAnalyticsRecommendationOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'iot_security_solutions_analytics_recommendation'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -632,6 +665,7 @@ def jit_network_access_policies(self): from ..v2020_01_01.aio.operations import JitNetworkAccessPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'jit_network_access_policies'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -645,6 +679,7 @@ def locations(self): from ..v2015_06_01_preview.aio.operations import LocationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'locations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -658,6 +693,7 @@ def mde_onboardings(self): from ..v2021_10_01_preview.aio.operations import MdeOnboardingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'mde_onboardings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -671,6 +707,7 @@ def operations(self): from ..v2015_06_01_preview.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -687,6 +724,7 @@ def pricings(self): from ..v2022_03_01.aio.operations import PricingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'pricings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -700,6 +738,7 @@ def regulatory_compliance_assessments(self): from ..v2019_01_01_preview.aio.operations import RegulatoryComplianceAssessmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_assessments'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -713,6 +752,7 @@ def regulatory_compliance_controls(self): from ..v2019_01_01_preview.aio.operations import RegulatoryComplianceControlsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_controls'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -726,6 +766,7 @@ def regulatory_compliance_standards(self): from ..v2019_01_01_preview.aio.operations import RegulatoryComplianceStandardsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'regulatory_compliance_standards'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -739,6 +780,7 @@ def secure_score_control_definitions(self): from ..v2020_01_01.aio.operations import SecureScoreControlDefinitionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'secure_score_control_definitions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -752,6 +794,7 @@ def secure_score_controls(self): from ..v2020_01_01.aio.operations import SecureScoreControlsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'secure_score_controls'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -765,6 +808,7 @@ def secure_scores(self): from ..v2020_01_01.aio.operations import SecureScoresOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'secure_scores'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -778,6 +822,7 @@ def security_connector_application(self): from ..v2022_07_01_preview.aio.operations import SecurityConnectorApplicationOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connector_application'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -791,6 +836,7 @@ def security_connector_applications(self): from ..v2022_07_01_preview.aio.operations import SecurityConnectorApplicationsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connector_applications'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -804,6 +850,7 @@ def security_connector_governance_rule(self): from ..v2022_01_01_preview.aio.operations import SecurityConnectorGovernanceRuleOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connector_governance_rule'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -817,6 +864,7 @@ def security_connector_governance_rules(self): from ..v2022_01_01_preview.aio.operations import SecurityConnectorGovernanceRulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connector_governance_rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -830,6 +878,7 @@ def security_connector_governance_rules_execute_status(self): from ..v2022_01_01_preview.aio.operations import SecurityConnectorGovernanceRulesExecuteStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connector_governance_rules_execute_status'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -838,14 +887,18 @@ def security_connectors(self): * 2021-07-01-preview: :class:`SecurityConnectorsOperations` * 2022-05-01-preview: :class:`SecurityConnectorsOperations` + * 2022-08-01-preview: :class:`SecurityConnectorsOperations` """ api_version = self._get_api_version('security_connectors') if api_version == '2021-07-01-preview': from ..v2021_07_01_preview.aio.operations import SecurityConnectorsOperations as OperationClass elif api_version == '2022-05-01-preview': from ..v2022_05_01_preview.aio.operations import SecurityConnectorsOperations as OperationClass + elif api_version == '2022-08-01-preview': + from ..v2022_08_01_preview.aio.operations import SecurityConnectorsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_connectors'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -859,6 +912,7 @@ def security_contacts(self): from ..v2017_08_01_preview.aio.operations import SecurityContactsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_contacts'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -872,6 +926,7 @@ def security_solutions(self): from ..v2020_01_01.aio.operations import SecuritySolutionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_solutions'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -885,6 +940,7 @@ def security_solutions_reference_data(self): from ..v2020_01_01.aio.operations import SecuritySolutionsReferenceDataOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'security_solutions_reference_data'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -898,6 +954,7 @@ def server_vulnerability_assessment(self): from ..v2020_01_01.aio.operations import ServerVulnerabilityAssessmentOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'server_vulnerability_assessment'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -917,6 +974,7 @@ def settings(self): from ..v2022_05_01.aio.operations import SettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -930,6 +988,7 @@ def software_inventories(self): from ..v2021_05_01_preview.aio.operations import SoftwareInventoriesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'software_inventories'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -943,6 +1002,7 @@ def sql_vulnerability_assessment_baseline_rules(self): from ..v2020_07_01_preview.aio.operations import SqlVulnerabilityAssessmentBaselineRulesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_baseline_rules'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -956,6 +1016,7 @@ def sql_vulnerability_assessment_scan_results(self): from ..v2020_07_01_preview.aio.operations import SqlVulnerabilityAssessmentScanResultsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scan_results'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -969,6 +1030,7 @@ def sql_vulnerability_assessment_scans(self): from ..v2020_07_01_preview.aio.operations import SqlVulnerabilityAssessmentScansOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'sql_vulnerability_assessment_scans'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -982,6 +1044,7 @@ def sub_assessments(self): from ..v2019_01_01_preview.aio.operations import SubAssessmentsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'sub_assessments'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -995,6 +1058,7 @@ def subscription_governance_rules_execute_status(self): from ..v2022_01_01_preview.aio.operations import SubscriptionGovernanceRulesExecuteStatusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'subscription_governance_rules_execute_status'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -1008,6 +1072,7 @@ def tasks(self): from ..v2015_06_01_preview.aio.operations import TasksOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'tasks'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -1021,6 +1086,7 @@ def topology(self): from ..v2020_01_01.aio.operations import TopologyOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'topology'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -1034,6 +1100,7 @@ def workspace_settings(self): from ..v2017_08_01_preview.aio.operations import WorkspaceSettingsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'workspace_settings'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) async def close(self): diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_configuration.py index b06d35a46ae4..c5a559682c88 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2015-06-01-preview") # type: str + api_version = kwargs.pop("api_version", "2015-06-01-preview") # type: Literal["2015-06-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_metadata.json index d15b751677b8..251d12e3010f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_metadata.json @@ -101,4 +101,4 @@ "operations": "Operations", "tasks": "TasksOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_configuration.py index 9220452a3fdb..acdf00c88a84 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2015-06-01-preview") # type: str + api_version = kwargs.pop("api_version", "2015-06-01-preview") # type: Literal["2015-06-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_locations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_locations_operations.py index 457c5073a829..8192e2fba9ae 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_locations_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_locations_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._locations_operations import build_get_request, build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -68,7 +73,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AscLocation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AscLocationList] error_map = { @@ -94,10 +101,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -151,7 +165,9 @@ async def get(self, asc_location: str, **kwargs: Any) -> _models.AscLocation: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AscLocation] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_operations.py index 18cde6b25fe1..29ad792ed595 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._operations import build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,7 +70,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationList] error_map = { @@ -90,10 +97,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_tasks_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_tasks_operations.py index 6ff807dd349f..b29058c24837 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_tasks_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/aio/operations/_tasks_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar, Union -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -38,6 +39,10 @@ build_update_subscription_level_task_state_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,7 +81,9 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncIterable["_m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityTaskList] error_map = { @@ -103,10 +110,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -157,7 +171,9 @@ def list_by_home_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityTaskList] error_map = { @@ -185,10 +201,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -246,7 +269,9 @@ async def get_subscription_level_task( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityTask] request = build_get_subscription_level_task_request( @@ -285,7 +310,7 @@ async def update_subscription_level_task_state( # pylint: disable=inconsistent- self, asc_location: str, task_name: str, - task_update_action_type: Union[str, "_models.TaskUpdateActionType"], + task_update_action_type: Union[str, _models.TaskUpdateActionType], **kwargs: Any ) -> None: """Recommended tasks that will help improve the security of the subscription proactively. @@ -315,7 +340,9 @@ async def update_subscription_level_task_state( # pylint: disable=inconsistent- _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_task_state_request( @@ -369,7 +396,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityTaskList] error_map = { @@ -398,10 +427,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -462,7 +498,9 @@ async def get_resource_group_level_task( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityTask] request = build_get_resource_group_level_task_request( @@ -503,7 +541,7 @@ async def update_resource_group_level_task_state( # pylint: disable=inconsisten resource_group_name: str, asc_location: str, task_name: str, - task_update_action_type: Union[str, "_models.TaskUpdateActionType"], + task_update_action_type: Union[str, _models.TaskUpdateActionType], **kwargs: Any ) -> None: """Recommended tasks that will help improve the security of the subscription proactively. @@ -536,7 +574,9 @@ async def update_resource_group_level_task_state( # pylint: disable=inconsisten _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_task_state_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_models_py3.py index 9755b20cb6ff..01d1fdf0e11b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_models_py3.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/models/_models_py3.py @@ -12,13 +12,14 @@ from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_locations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_locations_operations.py index 94a567c26ec3..a6ae0bc51282 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_locations_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_locations_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +73,9 @@ def build_get_request(asc_location: str, subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -125,7 +134,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.AscLocation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AscLocationList] error_map = { @@ -151,10 +162,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -208,7 +226,9 @@ def get(self, asc_location: str, **kwargs: Any) -> _models.AscLocation: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AscLocation] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_operations.py index 0d153f8197b7..49b52920f5cf 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -86,7 +93,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationList] error_map = { @@ -111,10 +120,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_tasks_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_tasks_operations.py index 3626829cc85a..bd53fab9ae24 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_tasks_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2015_06_01_preview/operations/_tasks_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar, Union -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +77,9 @@ def build_list_by_home_region_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -103,7 +112,9 @@ def build_get_subscription_level_task_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -133,14 +144,16 @@ def build_get_subscription_level_task_request( def build_update_subscription_level_task_state_request( asc_location: str, task_name: str, - task_update_action_type: Union[str, "_models.TaskUpdateActionType"], + task_update_action_type: Union[str, _models.TaskUpdateActionType], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -174,7 +187,9 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -211,7 +226,9 @@ def build_get_resource_group_level_task_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -245,14 +262,16 @@ def build_update_resource_group_level_task_state_request( resource_group_name: str, asc_location: str, task_name: str, - task_update_action_type: Union[str, "_models.TaskUpdateActionType"], + task_update_action_type: Union[str, _models.TaskUpdateActionType], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -317,7 +336,9 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityTaskList] error_map = { @@ -344,10 +365,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -398,7 +426,9 @@ def list_by_home_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityTaskList] error_map = { @@ -426,10 +456,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -485,7 +522,9 @@ def get_subscription_level_task(self, asc_location: str, task_name: str, **kwarg _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityTask] request = build_get_subscription_level_task_request( @@ -524,7 +563,7 @@ def update_subscription_level_task_state( # pylint: disable=inconsistent-return self, asc_location: str, task_name: str, - task_update_action_type: Union[str, "_models.TaskUpdateActionType"], + task_update_action_type: Union[str, _models.TaskUpdateActionType], **kwargs: Any ) -> None: """Recommended tasks that will help improve the security of the subscription proactively. @@ -554,7 +593,9 @@ def update_subscription_level_task_state( # pylint: disable=inconsistent-return _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_task_state_request( @@ -608,7 +649,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityTaskList] error_map = { @@ -637,10 +680,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -701,7 +751,9 @@ def get_resource_group_level_task( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityTask] request = build_get_resource_group_level_task_request( @@ -742,7 +794,7 @@ def update_resource_group_level_task_state( # pylint: disable=inconsistent-retu resource_group_name: str, asc_location: str, task_name: str, - task_update_action_type: Union[str, "_models.TaskUpdateActionType"], + task_update_action_type: Union[str, _models.TaskUpdateActionType], **kwargs: Any ) -> None: """Recommended tasks that will help improve the security of the subscription proactively. @@ -775,7 +827,9 @@ def update_resource_group_level_task_state( # pylint: disable=inconsistent-retu _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2015-06-01-preview") + ) # type: Literal["2015-06-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_task_state_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_configuration.py index b2b5163fc823..7c2f0329f3c1 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -34,7 +40,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-08-01") # type: str + api_version = kwargs.pop("api_version", "2017-08-01") # type: Literal["2017-08-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_metadata.json index 809d36282025..a3d9e73ca6f8 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_metadata.json @@ -87,4 +87,4 @@ "operation_groups": { "compliance_results": "ComplianceResultsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_configuration.py index 5a5a74c8da9b..a9eb28389fa5 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -34,7 +40,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-08-01") # type: str + api_version = kwargs.pop("api_version", "2017-08-01") # type: Literal["2017-08-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_compliance_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_compliance_results_operations.py index edaa4ba85c7e..0c69edc315df 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_compliance_results_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/aio/operations/_compliance_results_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._compliance_results_operations import build_get_request, build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +75,7 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.ComplianceRe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: Literal["2017-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ComplianceResultList] error_map = { @@ -96,10 +101,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -154,7 +166,7 @@ async def get(self, resource_id: str, compliance_result_name: str, **kwargs: Any _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: Literal["2017-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ComplianceResult] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_compliance_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_compliance_results_operations.py index 1489239f21b8..b62b7604b5c2 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_compliance_results_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01/operations/_compliance_results_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: Literal["2017-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +69,7 @@ def build_get_request(resource_id: str, compliance_result_name: str, **kwargs: A _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: Literal["2017-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -122,7 +127,7 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.ComplianceResult" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: Literal["2017-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ComplianceResultList] error_map = { @@ -148,10 +153,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -206,7 +218,7 @@ def get(self, resource_id: str, compliance_result_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01")) # type: Literal["2017-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ComplianceResult] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_configuration.py index 46043a171d74..93d7fbe4adcb 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-08-01-preview") # type: str + api_version = kwargs.pop("api_version", "2017-08-01-preview") # type: Literal["2017-08-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_metadata.json index f2bc142b961c..b1b962d4083c 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_metadata.json @@ -103,4 +103,4 @@ "security_contacts": "SecurityContactsOperations", "workspace_settings": "WorkspaceSettingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_configuration.py index a11c9bf2cb31..00d25b5afc26 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2017-08-01-preview") # type: str + api_version = kwargs.pop("api_version", "2017-08-01-preview") # type: Literal["2017-08-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_auto_provisioning_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_auto_provisioning_settings_operations.py index b744df15fb60..3550d9f4a2b4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_auto_provisioning_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_auto_provisioning_settings_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -34,6 +35,10 @@ build_list_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +76,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.AutoProvisioningSetting" _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoProvisioningSettingList] error_map = { @@ -97,10 +104,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -153,7 +167,9 @@ async def get(self, setting_name: str, **kwargs: Any) -> _models.AutoProvisionin _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoProvisioningSetting] request = build_get_request( @@ -258,7 +274,9 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoProvisioningSetting] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_compliances_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_compliances_operations.py index b21cfe52fcb0..461dcaad1f17 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_compliances_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_compliances_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._compliances_operations import build_get_request, build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +75,9 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Compliance"] _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ComplianceList] error_map = { @@ -96,10 +103,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -156,7 +170,9 @@ async def get(self, scope: str, compliance_name: str, **kwargs: Any) -> _models. _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Compliance] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_information_protection_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_information_protection_policies_operations.py index 497223be13a5..089089b739d3 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_information_protection_policies_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_information_protection_policies_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -34,6 +35,10 @@ build_list_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -61,7 +66,7 @@ def __init__(self, *args, **kwargs) -> None: async def get( self, scope: str, - information_protection_policy_name: Union[str, "_models.InformationProtectionPolicyName"], + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], **kwargs: Any ) -> _models.InformationProtectionPolicy: """Details of the information protection policy. @@ -90,7 +95,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.InformationProtectionPolicy] request = build_get_request( @@ -127,7 +134,7 @@ async def get( async def create_or_update( self, scope: str, - information_protection_policy_name: Union[str, "_models.InformationProtectionPolicyName"], + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], information_protection_policy: _models.InformationProtectionPolicy, *, content_type: str = "application/json", @@ -159,7 +166,7 @@ async def create_or_update( async def create_or_update( self, scope: str, - information_protection_policy_name: Union[str, "_models.InformationProtectionPolicyName"], + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], information_protection_policy: IO, *, content_type: str = "application/json", @@ -190,7 +197,7 @@ async def create_or_update( async def create_or_update( self, scope: str, - information_protection_policy_name: Union[str, "_models.InformationProtectionPolicyName"], + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], information_protection_policy: Union[_models.InformationProtectionPolicy, IO], **kwargs: Any ) -> _models.InformationProtectionPolicy: @@ -227,7 +234,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.InformationProtectionPolicy] @@ -294,7 +303,9 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.InformationP _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.InformationProtectionPolicyList] error_map = { @@ -320,10 +331,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_security_contacts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_security_contacts_operations.py index 4ddc3f763ad1..3c4645fac8a9 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_security_contacts_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_security_contacts_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -36,6 +37,10 @@ build_update_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +77,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityContact"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityContactList] error_map = { @@ -98,10 +105,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -154,7 +168,9 @@ async def get(self, security_contact_name: str, **kwargs: Any) -> _models.Securi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityContact] request = build_get_request( @@ -260,7 +276,9 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityContact] @@ -329,7 +347,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -431,7 +451,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityContact] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_workspace_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_workspace_settings_operations.py index 0275f7763a9b..3aadca5bb094 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_workspace_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/aio/operations/_workspace_settings_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -36,6 +37,10 @@ build_update_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +78,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.WorkspaceSetting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceSettingList] error_map = { @@ -99,10 +106,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -156,7 +170,9 @@ async def get(self, workspace_setting_name: str, **kwargs: Any) -> _models.Works _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceSetting] request = build_get_request( @@ -267,7 +283,9 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceSetting] @@ -390,7 +408,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceSetting] @@ -460,7 +480,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_auto_provisioning_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_auto_provisioning_settings_operations.py index 9ef440fda985..c4caaaa8c4ca 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_auto_provisioning_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_auto_provisioning_settings_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +75,9 @@ def build_get_request(setting_name: str, subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +107,9 @@ def build_create_request(setting_name: str, subscription_id: str, **kwargs: Any) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -160,7 +171,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.AutoProvisioningSetting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoProvisioningSettingList] error_map = { @@ -186,10 +199,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -242,7 +262,9 @@ def get(self, setting_name: str, **kwargs: Any) -> _models.AutoProvisioningSetti _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoProvisioningSetting] request = build_get_request( @@ -347,7 +369,9 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutoProvisioningSetting] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_compliances_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_compliances_operations.py index ae622aad907f..d29f85ec3a43 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_compliances_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_compliances_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +71,9 @@ def build_get_request(scope: str, compliance_name: str, **kwargs: Any) -> HttpRe _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -121,7 +130,9 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.Compliance"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ComplianceList] error_map = { @@ -147,10 +158,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -207,7 +225,9 @@ def get(self, scope: str, compliance_name: str, **kwargs: Any) -> _models.Compli _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Compliance] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_information_protection_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_information_protection_policies_operations.py index 8d98f47ae9be..63720c65bf74 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_information_protection_policies_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_information_protection_policies_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -37,12 +42,14 @@ def build_get_request( - scope: str, information_protection_policy_name: Union[str, "_models.InformationProtectionPolicyName"], **kwargs: Any + scope: str, information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,12 +76,14 @@ def build_get_request( def build_create_or_update_request( - scope: str, information_protection_policy_name: Union[str, "_models.InformationProtectionPolicyName"], **kwargs: Any + scope: str, information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -107,7 +116,9 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -150,7 +161,7 @@ def __init__(self, *args, **kwargs): def get( self, scope: str, - information_protection_policy_name: Union[str, "_models.InformationProtectionPolicyName"], + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], **kwargs: Any ) -> _models.InformationProtectionPolicy: """Details of the information protection policy. @@ -179,7 +190,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.InformationProtectionPolicy] request = build_get_request( @@ -216,7 +229,7 @@ def get( def create_or_update( self, scope: str, - information_protection_policy_name: Union[str, "_models.InformationProtectionPolicyName"], + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], information_protection_policy: _models.InformationProtectionPolicy, *, content_type: str = "application/json", @@ -248,7 +261,7 @@ def create_or_update( def create_or_update( self, scope: str, - information_protection_policy_name: Union[str, "_models.InformationProtectionPolicyName"], + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], information_protection_policy: IO, *, content_type: str = "application/json", @@ -279,7 +292,7 @@ def create_or_update( def create_or_update( self, scope: str, - information_protection_policy_name: Union[str, "_models.InformationProtectionPolicyName"], + information_protection_policy_name: Union[str, _models.InformationProtectionPolicyName], information_protection_policy: Union[_models.InformationProtectionPolicy, IO], **kwargs: Any ) -> _models.InformationProtectionPolicy: @@ -316,7 +329,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.InformationProtectionPolicy] @@ -383,7 +398,9 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.InformationProtec _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.InformationProtectionPolicyList] error_map = { @@ -409,10 +426,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_security_contacts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_security_contacts_operations.py index 71c4974a0d0b..26de75d54020 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_security_contacts_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_security_contacts_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +73,9 @@ def build_get_request(security_contact_name: str, subscription_id: str, **kwargs _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +105,9 @@ def build_create_request(security_contact_name: str, subscription_id: str, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -129,7 +140,9 @@ def build_delete_request(security_contact_name: str, subscription_id: str, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -159,7 +172,9 @@ def build_update_request(security_contact_name: str, subscription_id: str, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -220,7 +235,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityContact"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityContactList] error_map = { @@ -246,10 +263,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -302,7 +326,9 @@ def get(self, security_contact_name: str, **kwargs: Any) -> _models.SecurityCont _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityContact] request = build_get_request( @@ -408,7 +434,9 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityContact] @@ -477,7 +505,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -579,7 +609,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityContact] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_workspace_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_workspace_settings_operations.py index dd4635121972..e246cf1e71b5 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_workspace_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2017_08_01_preview/operations/_workspace_settings_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +73,9 @@ def build_get_request(workspace_setting_name: str, subscription_id: str, **kwarg _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +105,9 @@ def build_create_request(workspace_setting_name: str, subscription_id: str, **kw _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -129,7 +140,9 @@ def build_update_request(workspace_setting_name: str, subscription_id: str, **kw _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -162,7 +175,9 @@ def build_delete_request(workspace_setting_name: str, subscription_id: str, **kw _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -221,7 +236,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.WorkspaceSetting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceSettingList] error_map = { @@ -247,10 +264,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -304,7 +328,9 @@ def get(self, workspace_setting_name: str, **kwargs: Any) -> _models.WorkspaceSe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceSetting] request = build_get_request( @@ -415,7 +441,9 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceSetting] @@ -538,7 +566,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.WorkspaceSetting] @@ -608,7 +638,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2017-08-01-preview") + ) # type: Literal["2017-08-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_configuration.py index 0281c36f13a3..1a9383b9ca50 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-06-01") # type: str + api_version = kwargs.pop("api_version", "2018-06-01") # type: Literal["2018-06-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_metadata.json index d7403e5aa6ae..a257924c29e6 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_metadata.json @@ -99,4 +99,4 @@ "operation_groups": { "pricings": "PricingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_configuration.py index 198a0d9cc031..71ecbf233ba3 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2018-06-01") # type: str + api_version = kwargs.pop("api_version", "2018-06-01") # type: Literal["2018-06-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_pricings_operations.py index 120fed75b73c..16cf1bb363a4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_pricings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/aio/operations/_pricings_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._pricings_operations import build_get_request, build_list_request, build_update_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +75,7 @@ async def list(self, **kwargs: Any) -> _models.PricingList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: Literal["2018-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.PricingList] request = build_list_request( @@ -124,7 +129,7 @@ async def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: Literal["2018-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pricing] request = build_get_request( @@ -222,7 +227,7 @@ async def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO], * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: Literal["2018-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pricing] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_pricings_operations.py index be74c863b0b3..f45646b09a91 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_pricings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2018_06_01/operations/_pricings_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,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 = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: Literal["2018-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +69,7 @@ def build_get_request(pricing_name: str, subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: Literal["2018-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +98,7 @@ def build_update_request(pricing_name: str, subscription_id: str, **kwargs: Any) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: Literal["2018-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -160,7 +165,7 @@ def list(self, **kwargs: Any) -> _models.PricingList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: Literal["2018-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.PricingList] request = build_list_request( @@ -214,7 +219,7 @@ def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: Literal["2018-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pricing] request = build_get_request( @@ -312,7 +317,7 @@ def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO], **kwarg _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-06-01")) # type: Literal["2018-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pricing] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_configuration.py index 3ea0c3b424ca..e06429a27991 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -34,7 +40,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-01-01") # type: str + api_version = kwargs.pop("api_version", "2019-01-01") # type: Literal["2019-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_metadata.json index 1354c53972c1..5b738d4c8656 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_metadata.json @@ -87,4 +87,4 @@ "operation_groups": { "advanced_threat_protection": "AdvancedThreatProtectionOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_configuration.py index b5facb33c489..5d8fbb0d22b9 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -34,7 +40,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-01-01") # type: str + api_version = kwargs.pop("api_version", "2019-01-01") # type: Literal["2019-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_advanced_threat_protection_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_advanced_threat_protection_operations.py index 6651995275d1..28684d54f261 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_advanced_threat_protection_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/aio/operations/_advanced_threat_protection_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._advanced_threat_protection_operations import build_create_request, build_get_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -75,8 +80,8 @@ async def get(self, resource_id: str, **kwargs: Any) -> _models.AdvancedThreatPr _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str - setting_name = kwargs.pop("setting_name", "current") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: Literal["2019-01-01"] + setting_name = kwargs.pop("setting_name", "current") # type: Literal["current"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AdvancedThreatProtectionSetting] request = build_get_request( @@ -201,8 +206,8 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str - setting_name = kwargs.pop("setting_name", "current") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: Literal["2019-01-01"] + setting_name = kwargs.pop("setting_name", "current") # type: Literal["current"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AdvancedThreatProtectionSetting] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_advanced_threat_protection_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_advanced_threat_protection_operations.py index b2e858629f03..28b043a74cbb 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_advanced_threat_protection_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01/operations/_advanced_threat_protection_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,8 +43,8 @@ def build_get_request(resource_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str - setting_name = kwargs.pop("setting_name", "current") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: Literal["2019-01-01"] + setting_name = kwargs.pop("setting_name", "current") # type: Literal["current"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,8 +71,8 @@ def build_create_request(resource_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str - setting_name = kwargs.pop("setting_name", "current") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: Literal["2019-01-01"] + setting_name = kwargs.pop("setting_name", "current") # type: Literal["current"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -137,8 +142,8 @@ def get(self, resource_id: str, **kwargs: Any) -> _models.AdvancedThreatProtecti _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str - setting_name = kwargs.pop("setting_name", "current") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: Literal["2019-01-01"] + setting_name = kwargs.pop("setting_name", "current") # type: Literal["current"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AdvancedThreatProtectionSetting] request = build_get_request( @@ -263,8 +268,8 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: str - setting_name = kwargs.pop("setting_name", "current") # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01")) # type: Literal["2019-01-01"] + setting_name = kwargs.pop("setting_name", "current") # type: Literal["current"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AdvancedThreatProtectionSetting] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_configuration.py index e84e5e718ea9..e0525d39cb17 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2019-01-01-preview") # type: Literal["2019-01-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_metadata.json index ff1244d9151c..65712a8b6388 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_metadata.json @@ -104,4 +104,4 @@ "automations": "AutomationsOperations", "alerts_suppression_rules": "AlertsSuppressionRulesOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_configuration.py index f0095709a25b..6cd221fea7b4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2019-01-01-preview") # type: Literal["2019-01-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_alerts_suppression_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_alerts_suppression_rules_operations.py index ca30d57d9e64..eeb3135f3277 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_alerts_suppression_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_alerts_suppression_rules_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -35,6 +36,10 @@ build_update_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +79,9 @@ def list(self, alert_type: Optional[str] = None, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertsSuppressionRulesList] error_map = { @@ -101,10 +108,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -157,7 +171,9 @@ async def get(self, alerts_suppression_rule_name: str, **kwargs: Any) -> _models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertsSuppressionRule] request = build_get_request( @@ -273,7 +289,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertsSuppressionRule] @@ -342,7 +360,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_automations_operations.py index b12943e523ef..6947366b1082 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_automations_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_automations_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_validate_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +79,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Automation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutomationList] error_map = { @@ -100,10 +107,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -151,7 +165,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutomationList] error_map = { @@ -178,10 +194,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -237,7 +260,9 @@ async def get(self, resource_group_name: str, automation_name: str, **kwargs: An _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Automation] request = build_get_request( @@ -363,7 +388,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Automation] @@ -440,7 +467,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -562,7 +591,9 @@ async def validate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutomationValidationStatus] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_assessments_operations.py index d5152401b526..0da66fe3d056 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_assessments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_assessments_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._regulatory_compliance_assessments_operations import build_get_request, build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,7 +86,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceAssessmentList] error_map = { @@ -110,10 +117,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -179,7 +193,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceAssessment] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_controls_operations.py index 9e430e1a06ae..c33dad3da474 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_controls_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_controls_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._regulatory_compliance_controls_operations import build_get_request, build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +79,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceControlList] error_map = { @@ -102,10 +109,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -164,7 +178,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceControl] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_standards_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_standards_operations.py index c47981d793f1..a1a59794d533 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_standards_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_regulatory_compliance_standards_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._regulatory_compliance_standards_operations import build_get_request, build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +76,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceStandardList] error_map = { @@ -98,10 +105,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -157,7 +171,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceStandard] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_sub_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_sub_assessments_operations.py index 87793731b44b..3522593c3c28 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_sub_assessments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/aio/operations/_sub_assessments_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._sub_assessments_operations import build_get_request, build_list_all_request, build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -71,7 +76,9 @@ def list_all(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.Security _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySubAssessmentList] error_map = { @@ -97,10 +104,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -151,7 +165,9 @@ def list(self, scope: str, assessment_name: str, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySubAssessmentList] error_map = { @@ -178,10 +194,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -243,7 +266,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySubAssessment] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_alerts_suppression_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_alerts_suppression_rules_operations.py index 88cc4530e664..276f7999f3a4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_alerts_suppression_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_alerts_suppression_rules_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_request(subscription_id: str, *, alert_type: Optional[str] = None _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +77,9 @@ def build_get_request(alerts_suppression_rule_name: str, subscription_id: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -102,7 +111,9 @@ def build_update_request(alerts_suppression_rule_name: str, subscription_id: str _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -137,7 +148,9 @@ def build_delete_request(alerts_suppression_rule_name: str, subscription_id: str _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -200,7 +213,9 @@ def list(self, alert_type: Optional[str] = None, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertsSuppressionRulesList] error_map = { @@ -227,10 +242,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -283,7 +305,9 @@ def get(self, alerts_suppression_rule_name: str, **kwargs: Any) -> _models.Alert _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertsSuppressionRule] request = build_get_request( @@ -399,7 +423,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertsSuppressionRule] @@ -468,7 +494,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_automations_operations.py index 7120814a31b7..0a0b26b9ab24 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_automations_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_automations_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +73,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -100,7 +109,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,7 +146,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -173,7 +186,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -208,7 +223,9 @@ def build_validate_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -273,7 +290,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.Automation"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutomationList] error_map = { @@ -299,10 +318,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -350,7 +376,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutomationList] error_map = { @@ -377,10 +405,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -436,7 +471,9 @@ def get(self, resource_group_name: str, automation_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Automation] request = build_get_request( @@ -562,7 +599,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Automation] @@ -639,7 +678,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -761,7 +802,9 @@ def validate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AutomationValidationStatus] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_assessments_operations.py index ef0d2b6767a2..60392fa32a0e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_assessments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_assessments_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +52,9 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -90,7 +97,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -171,7 +180,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceAssessmentList] error_map = { @@ -200,10 +211,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -269,7 +287,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceAssessment] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_controls_operations.py index 8313724415c1..ece9fd34ccb4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_controls_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_controls_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,9 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -81,7 +88,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -152,7 +161,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceControlList] error_map = { @@ -180,10 +191,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -242,7 +260,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceControl] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_standards_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_standards_operations.py index eb856292c339..6a5a0161789e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_standards_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_regulatory_compliance_standards_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_request(subscription_id: str, *, filter: Optional[str] = None, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +77,9 @@ def build_get_request(regulatory_compliance_standard_name: str, subscription_id: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -133,7 +142,9 @@ def list(self, filter: Optional[str] = None, **kwargs: Any) -> Iterable["_models _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceStandardList] error_map = { @@ -160,10 +171,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -217,7 +235,9 @@ def get(self, regulatory_compliance_standard_name: str, **kwargs: Any) -> _model _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RegulatoryComplianceStandard] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_sub_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_sub_assessments_operations.py index 94e8b359f07a..a4ddd7978895 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_sub_assessments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_01_01_preview/operations/_sub_assessments_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_all_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +71,9 @@ def build_list_request(scope: str, assessment_name: str, **kwargs: Any) -> HttpR _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,7 +100,9 @@ def build_get_request(scope: str, assessment_name: str, sub_assessment_name: str _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -153,7 +164,9 @@ def list_all(self, scope: str, **kwargs: Any) -> Iterable["_models.SecuritySubAs _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySubAssessmentList] error_map = { @@ -179,10 +192,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -233,7 +253,9 @@ def list(self, scope: str, assessment_name: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySubAssessmentList] error_map = { @@ -260,10 +282,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -325,7 +354,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2019-01-01-preview") + ) # type: Literal["2019-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySubAssessment] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_configuration.py index a4a64b1c590f..0eef7f710a06 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-08-01") # type: str + api_version = kwargs.pop("api_version", "2019-08-01") # type: Literal["2019-08-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_metadata.json index 043490fe1983..fb4dc9f00646 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_metadata.json @@ -103,4 +103,4 @@ "iot_security_solutions_analytics_recommendation": "IotSecuritySolutionsAnalyticsRecommendationOperations", "iot_security_solution": "IotSecuritySolutionOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_configuration.py index 32a72d16e481..ad5b17e974bf 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2019-08-01") # type: str + api_version = kwargs.pop("api_version", "2019-08-01") # type: Literal["2019-08-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_device_security_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_device_security_groups_operations.py index 098b1667b0ff..cbbc47d24a29 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_device_security_groups_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_device_security_groups_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -35,6 +36,10 @@ build_list_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -73,7 +78,7 @@ def list(self, resource_id: str, **kwargs: Any) -> AsyncIterable["_models.Device _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DeviceSecurityGroupList] error_map = { @@ -99,10 +104,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -160,7 +172,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DeviceSecurityGroup] request = build_get_request( @@ -289,7 +301,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DeviceSecurityGroup] @@ -365,7 +377,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_analytics_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_analytics_operations.py index 9712b886479c..d2a8e768d80e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_analytics_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_analytics_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._iot_security_solution_analytics_operations import build_get_request, build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +82,7 @@ async def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionAnalyticsModelList] request = build_list_request( @@ -138,7 +143,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionAnalyticsModel] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_operations.py index 38a56933938b..864360becbec 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solution_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +84,7 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionsList] error_map = { @@ -106,10 +111,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -162,7 +174,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionsList] error_map = { @@ -190,10 +202,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -251,7 +270,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionModel] request = build_get_request( @@ -380,7 +399,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionModel] @@ -528,7 +547,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionModel] @@ -601,7 +620,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py index 72740bf605a4..313373854892 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -34,6 +35,10 @@ build_list_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -80,7 +85,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecurityAggregatedAlertList] error_map = { @@ -109,10 +114,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -173,7 +185,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecurityAggregatedAlert] request = build_get_request( @@ -237,7 +249,7 @@ async def dismiss( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_dismiss_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py index 3a62e51ff336..363466f760d9 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/aio/operations/_iot_security_solutions_analytics_recommendation_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -33,6 +34,10 @@ build_list_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -87,7 +92,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecurityAggregatedRecommendation] request = build_get_request( @@ -146,7 +151,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecurityAggregatedRecommendationList] error_map = { @@ -175,10 +180,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_device_security_groups_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_device_security_groups_operations.py index 31d54fd86369..4d8448b0db33 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_device_security_groups_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_device_security_groups_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request(resource_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +69,7 @@ def build_get_request(resource_id: str, device_security_group_name: str, **kwarg _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,7 +96,7 @@ def build_create_or_update_request(resource_id: str, device_security_group_name: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -121,7 +126,7 @@ def build_delete_request(resource_id: str, device_security_group_name: str, **kw _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +183,7 @@ def list(self, resource_id: str, **kwargs: Any) -> Iterable["_models.DeviceSecur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DeviceSecurityGroupList] error_map = { @@ -204,10 +209,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -263,7 +275,7 @@ def get(self, resource_id: str, device_security_group_name: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DeviceSecurityGroup] request = build_get_request( @@ -392,7 +404,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.DeviceSecurityGroup] @@ -468,7 +480,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_analytics_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_analytics_operations.py index fed0d4ba863a..4388c6b46011 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_analytics_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_analytics_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -73,7 +78,7 @@ def build_get_request(resource_group_name: str, solution_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -148,7 +153,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionAnalyticsModelList] request = build_list_request( @@ -209,7 +214,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionAnalyticsModel] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_operations.py index 6846c4276306..51e5cf8b82f6 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solution_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,7 @@ def build_list_by_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -74,7 +79,7 @@ def build_list_by_resource_group_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -108,7 +113,7 @@ def build_get_request(resource_group_name: str, solution_name: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +148,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -181,7 +186,7 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -219,7 +224,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -286,7 +291,7 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionsList] error_map = { @@ -313,10 +318,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -369,7 +381,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionsList] error_map = { @@ -397,10 +409,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -456,7 +475,7 @@ def get(self, resource_group_name: str, solution_name: str, **kwargs: Any) -> _m _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionModel] request = build_get_request( @@ -585,7 +604,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionModel] @@ -733,7 +752,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecuritySolutionModel] @@ -806,7 +825,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py index e376ddea0699..bee10b9a1908 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_aggregated_alert_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +84,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -115,7 +120,7 @@ def build_dismiss_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -187,7 +192,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecurityAggregatedAlertList] error_map = { @@ -216,10 +221,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -280,7 +292,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecurityAggregatedAlert] request = build_get_request( @@ -344,7 +356,7 @@ def dismiss( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_dismiss_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_recommendation_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_recommendation_operations.py index eb4a40ddd39a..c29f12f7c3b0 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_recommendation_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2019_08_01/operations/_iot_security_solutions_analytics_recommendation_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -46,7 +51,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -84,7 +89,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -165,7 +170,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecurityAggregatedRecommendation] request = build_get_request( @@ -224,7 +229,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-08-01")) # type: Literal["2019-08-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IoTSecurityAggregatedRecommendationList] error_map = { @@ -253,10 +258,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_configuration.py index 8a0246a8f30f..fa080065851b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2020-01-01") # type: str + api_version = kwargs.pop("api_version", "2020-01-01") # type: Literal["2020-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_metadata.json index be1c5d7c93ef..ba0549615a76 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_metadata.json @@ -113,4 +113,4 @@ "secure_score_control_definitions": "SecureScoreControlDefinitionsOperations", "security_solutions": "SecuritySolutionsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_configuration.py index 77c3a1c02686..9847128e0ae1 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2020-01-01") # type: str + api_version = kwargs.pop("api_version", "2020-01-01") # type: Literal["2020-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/__init__.py index 97fd501f9bb3..8f44c7940e4b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/__init__.py @@ -25,22 +25,23 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ServerVulnerabilityAssessmentOperations', - 'AssessmentsMetadataOperations', - 'AssessmentsOperations', - 'AdaptiveApplicationControlsOperations', - 'AdaptiveNetworkHardeningsOperations', - 'AllowedConnectionsOperations', - 'TopologyOperations', - 'JitNetworkAccessPoliciesOperations', - 'DiscoveredSecuritySolutionsOperations', - 'SecuritySolutionsReferenceDataOperations', - 'ExternalSecuritySolutionsOperations', - 'SecureScoresOperations', - 'SecureScoreControlsOperations', - 'SecureScoreControlDefinitionsOperations', - 'SecuritySolutionsOperations', + "ServerVulnerabilityAssessmentOperations", + "AssessmentsMetadataOperations", + "AssessmentsOperations", + "AdaptiveApplicationControlsOperations", + "AdaptiveNetworkHardeningsOperations", + "AllowedConnectionsOperations", + "TopologyOperations", + "JitNetworkAccessPoliciesOperations", + "DiscoveredSecuritySolutionsOperations", + "SecuritySolutionsReferenceDataOperations", + "ExternalSecuritySolutionsOperations", + "SecureScoresOperations", + "SecureScoreControlsOperations", + "SecureScoreControlDefinitionsOperations", + "SecuritySolutionsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_application_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_application_controls_operations.py index fc559163caef..bfd1f3c2973c 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_application_controls_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_application_controls_operations.py @@ -6,9 +6,17 @@ # 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, IO, Optional, TypeVar, Union, overload -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._adaptive_application_controls_operations import build_delete_request, build_get_request, build_list_request, build_put_request -T = TypeVar('T') +from ...operations._adaptive_application_controls_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AdaptiveApplicationControlsOperations: """ .. warning:: @@ -41,13 +60,9 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def list( - self, - include_path_recommendations: Optional[bool] = None, - summary: Optional[bool] = None, - **kwargs: Any + self, include_path_recommendations: Optional[bool] = None, summary: Optional[bool] = None, **kwargs: Any ) -> _models.AdaptiveApplicationControlGroups: """Gets a list of application control machine groups for the subscription. @@ -61,23 +76,25 @@ async def list( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveApplicationControlGroups] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AdaptiveApplicationControlGroups] - request = build_list_request( subscription_id=self._config.subscription_id, include_path_recommendations=include_path_recommendations, summary=summary, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -85,9 +102,7 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -96,23 +111,17 @@ async def list( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AdaptiveApplicationControlGroups', pipeline_response) + deserialized = self._deserialize("AdaptiveApplicationControlGroups", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applicationWhitelistings"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applicationWhitelistings"} # type: ignore @distributed_trace_async - async def get( - self, - asc_location: str, - group_name: str, - **kwargs: Any - ) -> _models.AdaptiveApplicationControlGroup: + async def get(self, asc_location: str, group_name: str, **kwargs: Any) -> _models.AdaptiveApplicationControlGroup: """Gets an application control VM/server group. :param asc_location: The location where ASC stores the data of the subscription. can be @@ -126,23 +135,25 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveApplicationControlGroup] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AdaptiveApplicationControlGroup] - request = build_get_request( asc_location=asc_location, group_name=group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -150,9 +161,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -161,15 +170,14 @@ 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('AdaptiveApplicationControlGroup', pipeline_response) + deserialized = self._deserialize("AdaptiveApplicationControlGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # type: ignore @overload async def put( @@ -201,13 +209,7 @@ async def put( @overload async def put( - self, - asc_location: str, - group_name: str, - body: IO, - *, - content_type: str = "application/json", - **kwargs: Any + self, asc_location: str, group_name: str, body: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.AdaptiveApplicationControlGroup: """Update an application control machine group. @@ -227,7 +229,6 @@ async def put( :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace_async async def put( self, @@ -254,16 +255,19 @@ async def put( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveApplicationControlGroup] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AdaptiveApplicationControlGroup] content_type = content_type or "application/json" _json = None @@ -271,7 +275,7 @@ async def put( if isinstance(body, (IO, bytes)): _content = body else: - _json = self._serialize.body(body, 'AdaptiveApplicationControlGroup') + _json = self._serialize.body(body, "AdaptiveApplicationControlGroup") request = build_put_request( asc_location=asc_location, @@ -281,7 +285,7 @@ async def put( content_type=content_type, json=_json, content=_content, - template_url=self.put.metadata['url'], + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -289,9 +293,7 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -300,22 +302,18 @@ async def put( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('AdaptiveApplicationControlGroup', pipeline_response) + deserialized = self._deserialize("AdaptiveApplicationControlGroup", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - asc_location: str, - group_name: str, - **kwargs: Any + self, asc_location: str, group_name: str, **kwargs: Any ) -> None: """Delete an application control machine group. @@ -330,23 +328,25 @@ async def delete( # pylint: disable=inconsistent-return-statements :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( asc_location=asc_location, group_name=group_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -354,9 +354,7 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -368,5 +366,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/applicationWhitelistings/{groupName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_network_hardenings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_network_hardenings_operations.py index c29732ca7356..42a8ec4659a4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_network_hardenings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_adaptive_network_hardenings_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -23,10 +31,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._adaptive_network_hardenings_operations import build_enforce_request, build_get_request, build_list_by_extended_resource_request -T = TypeVar('T') +from ...operations._adaptive_network_hardenings_operations import ( + build_enforce_request, + build_get_request, + build_list_by_extended_resource_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AdaptiveNetworkHardeningsOperations: """ .. warning:: @@ -46,15 +64,9 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_extended_resource( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.AdaptiveNetworkHardening"]: """Gets a list of Adaptive Network Hardenings resources in scope of an extended resource. @@ -77,16 +89,20 @@ def list_by_extended_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveNetworkHardeningsList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AdaptiveNetworkHardeningsList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_extended_resource_request( resource_group_name=resource_group_name, resource_namespace=resource_namespace, @@ -94,7 +110,7 @@ def prepare_request(next_link=None): resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_extended_resource.metadata['url'], + template_url=self.list_by_extended_resource.metadata["url"], headers=_headers, params=_params, ) @@ -103,10 +119,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -123,9 +146,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -135,11 +156,9 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_extended_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings"} # type: ignore + list_by_extended_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings"} # type: ignore @distributed_trace_async async def get( @@ -171,17 +190,19 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AdaptiveNetworkHardening] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AdaptiveNetworkHardening] - request = build_get_request( resource_group_name=resource_group_name, resource_namespace=resource_namespace, @@ -190,7 +211,7 @@ async def get( adaptive_network_hardening_resource_name=adaptive_network_hardening_resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -198,9 +219,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -209,15 +228,14 @@ 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('AdaptiveNetworkHardening', pipeline_response) + deserialized = self._deserialize("AdaptiveNetworkHardening", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}"} # type: ignore async def _enforce_initial( # pylint: disable=inconsistent-return-statements self, @@ -230,17 +248,22 @@ async def _enforce_initial( # pylint: disable=inconsistent-return-statements **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - adaptive_network_hardening_enforce_action = kwargs.pop('adaptive_network_hardening_enforce_action', "enforce") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + adaptive_network_hardening_enforce_action = kwargs.pop( + "adaptive_network_hardening_enforce_action", "enforce" + ) # type: Literal["enforce"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] content_type = content_type or "application/json" _json = None @@ -248,7 +271,7 @@ async def _enforce_initial( # pylint: disable=inconsistent-return-statements if isinstance(body, (IO, bytes)): _content = body else: - _json = self._serialize.body(body, 'AdaptiveNetworkHardeningEnforceRequest') + _json = self._serialize.body(body, "AdaptiveNetworkHardeningEnforceRequest") request = build_enforce_request( resource_group_name=resource_group_name, @@ -262,7 +285,7 @@ async def _enforce_initial( # pylint: disable=inconsistent-return-statements content_type=content_type, json=_json, content=_content, - template_url=self._enforce_initial.metadata['url'], + template_url=self._enforce_initial.metadata["url"], headers=_headers, params=_params, ) @@ -270,9 +293,7 @@ async def _enforce_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -284,8 +305,7 @@ async def _enforce_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _enforce_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}"} # type: ignore - + _enforce_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}"} # type: ignore @overload async def begin_enforce( @@ -385,7 +405,6 @@ async def begin_enforce( :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace_async async def begin_enforce( self, @@ -436,16 +455,15 @@ async def begin_enforce( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - adaptive_network_hardening_enforce_action = kwargs.pop('adaptive_network_hardening_enforce_action', "enforce") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + adaptive_network_hardening_enforce_action = kwargs.pop( + "adaptive_network_hardening_enforce_action", "enforce" + ) # type: Literal["enforce"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._enforce_initial( # type: ignore resource_group_name=resource_group_name, @@ -457,34 +475,30 @@ async def begin_enforce( adaptive_network_hardening_enforce_action=adaptive_network_hardening_enforce_action, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_enforce.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}"} # type: ignore + begin_enforce.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/adaptiveNetworkHardenings/{adaptiveNetworkHardeningResourceName}/{adaptiveNetworkHardeningEnforceAction}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_allowed_connections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_allowed_connections_operations.py index 1bbcf7642e24..cb341ce95ec9 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_allowed_connections_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_allowed_connections_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar, Union -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._allowed_connections_operations import build_get_request, build_list_by_home_region_request, build_list_request -T = TypeVar('T') +from ...operations._allowed_connections_operations import ( + build_get_request, + build_list_by_home_region_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AllowedConnectionsOperations: """ .. warning:: @@ -44,12 +62,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.AllowedConnectionsResource"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.AllowedConnectionsResource"]: """Gets the list of all possible traffic between resources for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,20 +76,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedConnectionsList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedConnectionsList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,10 +102,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -104,9 +129,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,17 +139,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/allowedConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/allowedConnections"} # type: ignore @distributed_trace def list_by_home_region( - self, - asc_location: str, - **kwargs: Any + self, asc_location: str, **kwargs: Any ) -> AsyncIterable["_models.AllowedConnectionsResource"]: """Gets the list of all possible traffic between resources for the subscription and location. @@ -143,21 +162,25 @@ def list_by_home_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedConnectionsList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedConnectionsList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_home_region_request( asc_location=asc_location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_home_region.metadata['url'], + template_url=self.list_by_home_region.metadata["url"], headers=_headers, params=_params, ) @@ -166,10 +189,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -186,9 +216,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -198,18 +226,16 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections"} # type: ignore + list_by_home_region.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections"} # type: ignore @distributed_trace_async async def get( self, resource_group_name: str, asc_location: str, - connection_type: Union[str, "_models.ConnectionType"], + connection_type: Union[str, _models.ConnectionType], **kwargs: Any ) -> _models.AllowedConnectionsResource: """Gets the list of all possible traffic between resources for the subscription and location, @@ -230,24 +256,26 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.AllowedConnectionsResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedConnectionsResource] - request = build_get_request( resource_group_name=resource_group_name, asc_location=asc_location, connection_type=connection_type, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -255,9 +283,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -266,12 +292,11 @@ 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('AllowedConnectionsResource', pipeline_response) + deserialized = self._deserialize("AllowedConnectionsResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/allowedConnections/{connectionType}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_metadata_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_metadata_operations.py index 3dd61c6048f0..e6ac957eedaa 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_metadata_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_metadata_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,10 +29,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._assessments_metadata_operations import build_create_in_subscription_request, build_delete_in_subscription_request, build_get_in_subscription_request, build_get_request, build_list_by_subscription_request, build_list_request -T = TypeVar('T') +from ...operations._assessments_metadata_operations import ( + build_create_in_subscription_request, + build_delete_in_subscription_request, + build_get_in_subscription_request, + build_get_request, + build_list_by_subscription_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AssessmentsMetadataOperations: """ .. warning:: @@ -44,12 +65,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecurityAssessmentMetadata"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentMetadata"]: """Get metadata information on all assessment types. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,19 +79,23 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -83,10 +104,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -103,9 +131,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,18 +141,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Security/assessmentMetadata"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Security/assessmentMetadata"} # type: ignore @distributed_trace_async - async def get( - self, - assessment_metadata_name: str, - **kwargs: Any - ) -> _models.SecurityAssessmentMetadata: + async def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityAssessmentMetadata: """Get metadata information on an assessment type. :param assessment_metadata_name: The Assessment Key - Unique key for the assessment type. @@ -138,21 +158,23 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadata] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadata] - request = build_get_request( assessment_metadata_name=assessment_metadata_name, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -160,9 +182,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -171,21 +191,17 @@ 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('SecurityAssessmentMetadata', pipeline_response) + deserialized = self._deserialize("SecurityAssessmentMetadata", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # type: ignore - + get.metadata = {"url": "/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecurityAssessmentMetadata"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentMetadata"]: """Get metadata information on all assessment types in a specific subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -198,20 +214,24 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadataList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -220,10 +240,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -240,9 +267,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -252,17 +277,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata"} # type: ignore @distributed_trace_async async def get_in_subscription( - self, - assessment_metadata_name: str, - **kwargs: Any + self, assessment_metadata_name: str, **kwargs: Any ) -> _models.SecurityAssessmentMetadata: """Get metadata information on an assessment type in a specific subscription. @@ -275,22 +296,24 @@ async def get_in_subscription( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadata] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadata] - request = build_get_in_subscription_request( assessment_metadata_name=assessment_metadata_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_in_subscription.metadata['url'], + template_url=self.get_in_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -298,9 +321,7 @@ async def get_in_subscription( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -309,15 +330,14 @@ async def get_in_subscription( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SecurityAssessmentMetadata', pipeline_response) + deserialized = self._deserialize("SecurityAssessmentMetadata", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # type: ignore - + get_in_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # type: ignore @overload async def create_in_subscription( @@ -369,7 +389,6 @@ async def create_in_subscription( :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace_async async def create_in_subscription( self, @@ -395,16 +414,19 @@ async def create_in_subscription( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentMetadata] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadata] content_type = content_type or "application/json" _json = None @@ -412,7 +434,7 @@ async def create_in_subscription( if isinstance(assessment_metadata, (IO, bytes)): _content = assessment_metadata else: - _json = self._serialize.body(assessment_metadata, 'SecurityAssessmentMetadata') + _json = self._serialize.body(assessment_metadata, "SecurityAssessmentMetadata") request = build_create_in_subscription_request( assessment_metadata_name=assessment_metadata_name, @@ -421,7 +443,7 @@ async def create_in_subscription( content_type=content_type, json=_json, content=_content, - template_url=self.create_in_subscription.metadata['url'], + template_url=self.create_in_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -429,9 +451,7 @@ async def create_in_subscription( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -440,21 +460,18 @@ async def create_in_subscription( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SecurityAssessmentMetadata', pipeline_response) + deserialized = self._deserialize("SecurityAssessmentMetadata", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # type: ignore - + create_in_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # type: ignore @distributed_trace_async async def delete_in_subscription( # pylint: disable=inconsistent-return-statements - self, - assessment_metadata_name: str, - **kwargs: Any + self, assessment_metadata_name: str, **kwargs: Any ) -> None: """Delete metadata information on an assessment type in a specific subscription, will cause the deletion of all the assessments of that type in that subscription. @@ -468,22 +485,24 @@ async def delete_in_subscription( # pylint: disable=inconsistent-return-stateme :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_in_subscription_request( assessment_metadata_name=assessment_metadata_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_in_subscription.metadata['url'], + template_url=self.delete_in_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -491,9 +510,7 @@ async def delete_in_subscription( # pylint: disable=inconsistent-return-stateme request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -505,5 +522,4 @@ async def delete_in_subscription( # pylint: disable=inconsistent-return-stateme if cls: return cls(pipeline_response, None, {}) - delete_in_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # type: ignore - + delete_in_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/assessmentMetadata/{assessmentMetadataName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_operations.py index 0de36619a20d..1761db658ea4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_assessments_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._assessments_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._assessments_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class AssessmentsOperations: """ .. warning:: @@ -44,13 +63,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - scope: str, - **kwargs: Any - ) -> AsyncIterable["_models.SecurityAssessment"]: + def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessment"]: """Get security assessments on all your scanned resources inside a scope. :param scope: Scope of the query, can be subscription @@ -66,20 +80,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessmentList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( scope=scope, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,10 +106,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -108,9 +133,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -120,18 +143,16 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/{scope}/providers/Microsoft.Security/assessments"} # type: ignore + list.metadata = {"url": "/{scope}/providers/Microsoft.Security/assessments"} # type: ignore @distributed_trace_async async def get( self, resource_id: str, assessment_name: str, - expand: Optional[Union[str, "_models.ExpandEnum"]] = None, + expand: Optional[Union[str, _models.ExpandEnum]] = None, **kwargs: Any ) -> _models.SecurityAssessment: """Get a security assessment on your scanned resource. @@ -149,23 +170,25 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessment] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessment] - request = build_get_request( resource_id=resource_id, assessment_name=assessment_name, expand=expand, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -173,9 +196,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -184,15 +205,14 @@ 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('SecurityAssessment', pipeline_response) + deserialized = self._deserialize("SecurityAssessment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # type: ignore - + get.metadata = {"url": "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # type: ignore @overload async def create_or_update( @@ -250,14 +270,9 @@ async def create_or_update( :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace_async async def create_or_update( - self, - resource_id: str, - assessment_name: str, - assessment: Union[_models.SecurityAssessment, IO], - **kwargs: Any + self, resource_id: str, assessment_name: str, assessment: Union[_models.SecurityAssessment, IO], **kwargs: Any ) -> _models.SecurityAssessment: """Create a security assessment on your resource. An assessment metadata that describes this assessment must be predefined with the same name before inserting the assessment result. @@ -278,16 +293,19 @@ async def create_or_update( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecurityAssessment] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessment] content_type = content_type or "application/json" _json = None @@ -295,7 +313,7 @@ async def create_or_update( if isinstance(assessment, (IO, bytes)): _content = assessment else: - _json = self._serialize.body(assessment, 'SecurityAssessment') + _json = self._serialize.body(assessment, "SecurityAssessment") request = build_create_or_update_request( resource_id=resource_id, @@ -304,7 +322,7 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -312,9 +330,7 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -324,25 +340,21 @@ async def create_or_update( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('SecurityAssessment', pipeline_response) + deserialized = self._deserialize("SecurityAssessment", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('SecurityAssessment', pipeline_response) + deserialized = self._deserialize("SecurityAssessment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # type: ignore - + create_or_update.metadata = {"url": "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_id: str, - assessment_name: str, - **kwargs: Any + self, resource_id: str, assessment_name: str, **kwargs: Any ) -> None: """Delete a security assessment on your resource. An assessment metadata that describes this assessment must be predefined with the same name before inserting the assessment result. @@ -357,22 +369,24 @@ async def delete( # pylint: disable=inconsistent-return-statements :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_id=resource_id, assessment_name=assessment_name, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -380,9 +394,7 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -394,5 +406,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # type: ignore - + delete.metadata = {"url": "/{resourceId}/providers/Microsoft.Security/assessments/{assessmentName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_discovered_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_discovered_security_solutions_operations.py index 0263981579d4..48d2baa9aead 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_discovered_security_solutions_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_discovered_security_solutions_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._discovered_security_solutions_operations import build_get_request, build_list_by_home_region_request, build_list_request -T = TypeVar('T') +from ...operations._discovered_security_solutions_operations import ( + build_get_request, + build_list_by_home_region_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DiscoveredSecuritySolutionsOperations: """ .. warning:: @@ -44,12 +62,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.DiscoveredSecuritySolution"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.DiscoveredSecuritySolution"]: """Gets a list of discovered Security Solutions for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,20 +76,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiscoveredSecuritySolutionList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiscoveredSecuritySolutionList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,10 +102,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -104,9 +129,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,17 +139,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/discoveredSecuritySolutions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/discoveredSecuritySolutions"} # type: ignore @distributed_trace def list_by_home_region( - self, - asc_location: str, - **kwargs: Any + self, asc_location: str, **kwargs: Any ) -> AsyncIterable["_models.DiscoveredSecuritySolution"]: """Gets a list of discovered Security Solutions for the subscription and location. @@ -143,21 +162,25 @@ def list_by_home_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiscoveredSecuritySolutionList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiscoveredSecuritySolutionList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_home_region_request( asc_location=asc_location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_home_region.metadata['url'], + template_url=self.list_by_home_region.metadata["url"], headers=_headers, params=_params, ) @@ -166,10 +189,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -186,9 +216,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -198,19 +226,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions"} # type: ignore + list_by_home_region.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - asc_location: str, - discovered_security_solution_name: str, - **kwargs: Any + self, resource_group_name: str, asc_location: str, discovered_security_solution_name: str, **kwargs: Any ) -> _models.DiscoveredSecuritySolution: """Gets a specific discovered Security Solution. @@ -228,24 +250,26 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DiscoveredSecuritySolution] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DiscoveredSecuritySolution] - request = build_get_request( resource_group_name=resource_group_name, asc_location=asc_location, discovered_security_solution_name=discovered_security_solution_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -253,9 +277,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -264,12 +286,11 @@ 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('DiscoveredSecuritySolution', pipeline_response) + deserialized = self._deserialize("DiscoveredSecuritySolution", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions/{discoveredSecuritySolutionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/discoveredSecuritySolutions/{discoveredSecuritySolutionName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_external_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_external_security_solutions_operations.py index 6eaf733532d9..180037abff08 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_external_security_solutions_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_external_security_solutions_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._external_security_solutions_operations import build_get_request, build_list_by_home_region_request, build_list_request -T = TypeVar('T') +from ...operations._external_security_solutions_operations import ( + build_get_request, + build_list_by_home_region_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ExternalSecuritySolutionsOperations: """ .. warning:: @@ -44,12 +62,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ExternalSecuritySolution"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ExternalSecuritySolution"]: """Gets a list of external security solutions for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,20 +76,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ExternalSecuritySolutionList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExternalSecuritySolutionList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,10 +102,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -104,9 +129,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,17 +139,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/externalSecuritySolutions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/externalSecuritySolutions"} # type: ignore @distributed_trace def list_by_home_region( - self, - asc_location: str, - **kwargs: Any + self, asc_location: str, **kwargs: Any ) -> AsyncIterable["_models.ExternalSecuritySolution"]: """Gets a list of external Security Solutions for the subscription and location. @@ -143,21 +162,25 @@ def list_by_home_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ExternalSecuritySolutionList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExternalSecuritySolutionList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_home_region_request( asc_location=asc_location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_home_region.metadata['url'], + template_url=self.list_by_home_region.metadata["url"], headers=_headers, params=_params, ) @@ -166,10 +189,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -186,9 +216,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -198,19 +226,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions"} # type: ignore + list_by_home_region.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - asc_location: str, - external_security_solutions_name: str, - **kwargs: Any + self, resource_group_name: str, asc_location: str, external_security_solutions_name: str, **kwargs: Any ) -> _models.ExternalSecuritySolution: """Gets a specific external Security Solution. @@ -228,24 +250,26 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ExternalSecuritySolution] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ExternalSecuritySolution] - request = build_get_request( resource_group_name=resource_group_name, asc_location=asc_location, external_security_solutions_name=external_security_solutions_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -253,9 +277,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -264,12 +286,11 @@ 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('ExternalSecuritySolution', pipeline_response) + deserialized = self._deserialize("ExternalSecuritySolution", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions/{externalSecuritySolutionsName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/ExternalSecuritySolutions/{externalSecuritySolutionsName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_jit_network_access_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_jit_network_access_policies_operations.py index 127b7b4b143c..d5a6f0671157 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_jit_network_access_policies_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_jit_network_access_policies_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,10 +29,25 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._jit_network_access_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_initiate_request, build_list_by_region_request, build_list_by_resource_group_and_region_request, build_list_by_resource_group_request, build_list_request -T = TypeVar('T') +from ...operations._jit_network_access_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_initiate_request, + build_list_by_region_request, + build_list_by_resource_group_and_region_request, + build_list_by_resource_group_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class JitNetworkAccessPoliciesOperations: """ .. warning:: @@ -44,12 +67,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: """Policies for protecting resources using Just-in-Time access control. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,20 +81,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPoliciesList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,10 +107,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -104,9 +134,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,18 +144,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/jitNetworkAccessPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/jitNetworkAccessPolicies"} # type: ignore @distributed_trace - def list_by_region( - self, - asc_location: str, - **kwargs: Any - ) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: + def list_by_region(self, asc_location: str, **kwargs: Any) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: """Policies for protecting resources using Just-in-Time access control for the subscription, location. @@ -144,21 +166,25 @@ def list_by_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPoliciesList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_region_request( asc_location=asc_location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_region.metadata['url'], + template_url=self.list_by_region.metadata["url"], headers=_headers, params=_params, ) @@ -167,10 +193,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -187,9 +220,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -199,17 +230,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies"} # type: ignore + list_by_region.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any + self, resource_group_name: str, **kwargs: Any ) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: """Policies for protecting resources using Just-in-Time access control for the subscription, location. @@ -227,21 +254,25 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPoliciesList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -250,10 +281,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -270,9 +308,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -282,18 +318,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/jitNetworkAccessPolicies"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/jitNetworkAccessPolicies"} # type: ignore @distributed_trace def list_by_resource_group_and_region( - self, - resource_group_name: str, - asc_location: str, - **kwargs: Any + self, resource_group_name: str, asc_location: str, **kwargs: Any ) -> AsyncIterable["_models.JitNetworkAccessPolicy"]: """Policies for protecting resources using Just-in-Time access control for the subscription, location. @@ -314,22 +345,26 @@ def list_by_resource_group_and_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPoliciesList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPoliciesList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_resource_group_and_region_request( resource_group_name=resource_group_name, asc_location=asc_location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_resource_group_and_region.metadata['url'], + template_url=self.list_by_resource_group_and_region.metadata["url"], headers=_headers, params=_params, ) @@ -338,10 +373,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -358,9 +400,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -370,19 +410,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group_and_region.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies"} # type: ignore + list_by_resource_group_and_region.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - **kwargs: Any + self, resource_group_name: str, asc_location: str, jit_network_access_policy_name: str, **kwargs: Any ) -> _models.JitNetworkAccessPolicy: """Policies for protecting resources using Just-in-Time access control for the subscription, location. @@ -402,24 +436,26 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPolicy] - request = build_get_request( resource_group_name=resource_group_name, asc_location=asc_location, jit_network_access_policy_name=jit_network_access_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -427,9 +463,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -438,15 +472,14 @@ 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('JitNetworkAccessPolicy', pipeline_response) + deserialized = self._deserialize("JitNetworkAccessPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # type: ignore @overload async def create_or_update( @@ -514,7 +547,6 @@ async def create_or_update( :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace_async async def create_or_update( self, @@ -546,16 +578,19 @@ async def create_or_update( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPolicy] content_type = content_type or "application/json" _json = None @@ -563,7 +598,7 @@ async def create_or_update( if isinstance(body, (IO, bytes)): _content = body else: - _json = self._serialize.body(body, 'JitNetworkAccessPolicy') + _json = self._serialize.body(body, "JitNetworkAccessPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, @@ -574,7 +609,7 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -582,9 +617,7 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -593,23 +626,18 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('JitNetworkAccessPolicy', pipeline_response) + deserialized = self._deserialize("JitNetworkAccessPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - asc_location: str, - jit_network_access_policy_name: str, - **kwargs: Any + self, resource_group_name: str, asc_location: str, jit_network_access_policy_name: str, **kwargs: Any ) -> None: """Delete a Just-in-Time access control policy. @@ -628,24 +656,26 @@ async def delete( # pylint: disable=inconsistent-return-statements :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, asc_location=asc_location, jit_network_access_policy_name=jit_network_access_policy_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -653,9 +683,7 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -667,8 +695,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}"} # type: ignore @overload async def initiate( @@ -744,7 +771,6 @@ async def initiate( :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace_async async def initiate( self, @@ -780,17 +806,22 @@ async def initiate( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - jit_network_access_policy_initiate_type = kwargs.pop('jit_network_access_policy_initiate_type', "initiate") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.JitNetworkAccessRequest] + jit_network_access_policy_initiate_type = kwargs.pop( + "jit_network_access_policy_initiate_type", "initiate" + ) # type: Literal["initiate"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessRequest] content_type = content_type or "application/json" _json = None @@ -798,7 +829,7 @@ async def initiate( if isinstance(body, (IO, bytes)): _content = body else: - _json = self._serialize.body(body, 'JitNetworkAccessPolicyInitiateRequest') + _json = self._serialize.body(body, "JitNetworkAccessPolicyInitiateRequest") request = build_initiate_request( resource_group_name=resource_group_name, @@ -810,7 +841,7 @@ async def initiate( content_type=content_type, json=_json, content=_content, - template_url=self.initiate.metadata['url'], + template_url=self.initiate.metadata["url"], headers=_headers, params=_params, ) @@ -818,9 +849,7 @@ async def initiate( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -829,12 +858,11 @@ async def initiate( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('JitNetworkAccessRequest', pipeline_response) + deserialized = self._deserialize("JitNetworkAccessRequest", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - initiate.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}/{jitNetworkAccessPolicyInitiateType}"} # type: ignore - + initiate.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/jitNetworkAccessPolicies/{jitNetworkAccessPolicyName}/{jitNetworkAccessPolicyInitiateType}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_patch.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_control_definitions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_control_definitions_operations.py index 09e4ee7643bc..1666c3f2a99e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_control_definitions_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_control_definitions_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +28,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._secure_score_control_definitions_operations import build_list_by_subscription_request, build_list_request -T = TypeVar('T') +from ...operations._secure_score_control_definitions_operations import ( + build_list_by_subscription_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SecureScoreControlDefinitionsOperations: """ .. warning:: @@ -43,12 +60,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecureScoreControlDefinitionItem"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SecureScoreControlDefinitionItem"]: """List the available security controls, their assessments, and the max score. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,19 +74,23 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlDefinitionList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoreControlDefinitionList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -82,10 +99,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -102,9 +126,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,17 +136,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Security/secureScoreControlDefinitions"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Security/secureScoreControlDefinitions"} # type: ignore @distributed_trace - def list_by_subscription( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecureScoreControlDefinitionItem"]: + def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.SecureScoreControlDefinitionItem"]: """For a specified subscription, list the available security controls, their assessments, and the max score. @@ -138,20 +155,24 @@ def list_by_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlDefinitionList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoreControlDefinitionList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_subscription_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_subscription.metadata['url'], + template_url=self.list_by_subscription.metadata["url"], headers=_headers, params=_params, ) @@ -160,10 +181,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -180,9 +208,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -192,8 +218,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_subscription.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControlDefinitions"} # type: ignore + list_by_subscription.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControlDefinitions"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_controls_operations.py index 11b70f0f3e80..d935cbe380ac 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_controls_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_score_controls_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar, Union -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._secure_score_controls_operations import build_list_by_secure_score_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SecureScoreControlsOperations: """ .. warning:: @@ -43,13 +57,9 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_secure_score( - self, - secure_score_name: str, - expand: Optional[Union[str, "_models.ExpandControlsEnum"]] = None, - **kwargs: Any + self, secure_score_name: str, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any ) -> AsyncIterable["_models.SecureScoreControlDetails"]: """Get all security controls for a specific initiative within a scope. @@ -68,22 +78,26 @@ def list_by_secure_score( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoreControlList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_secure_score_request( secure_score_name=secure_score_name, subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list_by_secure_score.metadata['url'], + template_url=self.list_by_secure_score.metadata["url"], headers=_headers, params=_params, ) @@ -92,10 +106,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -112,9 +133,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -124,17 +143,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_secure_score.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}/secureScoreControls"} # type: ignore + list_by_secure_score.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}/secureScoreControls"} # type: ignore @distributed_trace def list( - self, - expand: Optional[Union[str, "_models.ExpandControlsEnum"]] = None, - **kwargs: Any + self, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any ) -> AsyncIterable["_models.SecureScoreControlDetails"]: """Get all security controls within a scope. @@ -150,21 +165,25 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreControlList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoreControlList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, expand=expand, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -173,10 +192,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -193,9 +219,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -205,8 +229,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControls"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScoreControls"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_scores_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_scores_operations.py index ff02b070d169..c4821406dd76 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_scores_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_secure_scores_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -22,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._secure_scores_operations import build_get_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SecureScoresOperations: """ .. warning:: @@ -44,12 +58,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecureScoreItem"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SecureScoreItem"]: """List secure scores for all your Microsoft Defender for Cloud initiatives within your current scope. @@ -62,20 +72,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoresList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoresList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,10 +98,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -104,9 +125,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,18 +135,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores"} # type: ignore @distributed_trace_async - async def get( - self, - secure_score_name: str, - **kwargs: Any - ) -> _models.SecureScoreItem: + async def get(self, secure_score_name: str, **kwargs: Any) -> _models.SecureScoreItem: """Get secure score for a specific Microsoft Defender for Cloud initiative within your current scope. For the ASC Default initiative, use 'ascScore'. @@ -140,22 +153,24 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecureScoreItem] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoreItem] - request = build_get_request( secure_score_name=secure_score_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -163,9 +178,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -174,12 +187,11 @@ 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('SecureScoreItem', pipeline_response) + deserialized = self._deserialize("SecureScoreItem", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/secureScores/{secureScoreName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_operations.py index e41e91e22dc0..dd8c2bd37cad 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -22,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._security_solutions_operations import build_get_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SecuritySolutionsOperations: """ .. warning:: @@ -44,12 +58,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.SecuritySolution"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SecuritySolution"]: """Gets a list of Security Solutions for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,20 +71,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolutionList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySolutionList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -83,10 +97,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -103,9 +124,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,19 +134,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutions"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutions"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - asc_location: str, - security_solution_name: str, - **kwargs: Any + self, resource_group_name: str, asc_location: str, security_solution_name: str, **kwargs: Any ) -> _models.SecuritySolution: """Gets a specific Security Solution. @@ -145,24 +158,26 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolution] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySolution] - request = build_get_request( resource_group_name=resource_group_name, asc_location=asc_location, security_solution_name=security_solution_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -170,9 +185,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -181,12 +194,11 @@ 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('SecuritySolution', pipeline_response) + deserialized = self._deserialize("SecuritySolution", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutions/{securitySolutionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutions/{securitySolutionName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_reference_data_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_reference_data_operations.py index 2f61757b1815..5e79c73762c7 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_reference_data_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_security_solutions_reference_data_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._security_solutions_reference_data_operations import build_list_by_home_region_request, build_list_request -T = TypeVar('T') +from ...operations._security_solutions_reference_data_operations import ( + build_list_by_home_region_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SecuritySolutionsReferenceDataOperations: """ .. warning:: @@ -41,12 +58,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - **kwargs: Any - ) -> _models.SecuritySolutionsReferenceDataList: + async def list(self, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: """Gets a list of all supported Security Solutions for the subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -55,21 +68,23 @@ async def list( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolutionsReferenceDataList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySolutionsReferenceDataList] - request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -77,9 +92,7 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -88,22 +101,17 @@ async def list( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SecuritySolutionsReferenceDataList', pipeline_response) + deserialized = self._deserialize("SecuritySolutionsReferenceDataList", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutionsReferenceData"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securitySolutionsReferenceData"} # type: ignore @distributed_trace_async - async def list_by_home_region( - self, - asc_location: str, - **kwargs: Any - ) -> _models.SecuritySolutionsReferenceDataList: + async def list_by_home_region(self, asc_location: str, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: """Gets list of all supported Security Solutions for subscription and location. :param asc_location: The location where ASC stores the data of the subscription. can be @@ -115,22 +123,24 @@ async def list_by_home_region( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SecuritySolutionsReferenceDataList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySolutionsReferenceDataList] - request = build_list_by_home_region_request( asc_location=asc_location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_home_region.metadata['url'], + template_url=self.list_by_home_region.metadata["url"], headers=_headers, params=_params, ) @@ -138,9 +148,7 @@ async def list_by_home_region( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,12 +157,11 @@ async def list_by_home_region( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('SecuritySolutionsReferenceDataList', pipeline_response) + deserialized = self._deserialize("SecuritySolutionsReferenceDataList", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutionsReferenceData"} # type: ignore - + list_by_home_region.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/securitySolutionsReferenceData"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_server_vulnerability_assessment_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_server_vulnerability_assessment_operations.py index 6a978f394a08..3b7016783df2 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_server_vulnerability_assessment_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_server_vulnerability_assessment_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union, cast -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -20,10 +28,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._server_vulnerability_assessment_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_by_extended_resource_request -T = TypeVar('T') +from ...operations._server_vulnerability_assessment_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_extended_resource_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ServerVulnerabilityAssessmentOperations: """ .. warning:: @@ -43,15 +62,9 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def list_by_extended_resource( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any ) -> _models.ServerVulnerabilityAssessmentsList: """Gets a list of server vulnerability assessment onboarding statuses on a given resource. @@ -70,17 +83,19 @@ async def list_by_extended_resource( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServerVulnerabilityAssessmentsList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessmentsList] - request = build_list_by_extended_resource_request( resource_group_name=resource_group_name, resource_namespace=resource_namespace, @@ -88,7 +103,7 @@ async def list_by_extended_resource( resource_name=resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_extended_resource.metadata['url'], + template_url=self.list_by_extended_resource.metadata["url"], headers=_headers, params=_params, ) @@ -96,9 +111,7 @@ async def list_by_extended_resource( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -107,24 +120,18 @@ async def list_by_extended_resource( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServerVulnerabilityAssessmentsList', pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessmentsList", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_extended_resource.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments"} # type: ignore - + list_by_extended_resource.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any ) -> _models.ServerVulnerabilityAssessment: """Gets a server vulnerability assessment onboarding statuses on a given resource. @@ -147,18 +154,22 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - server_vulnerability_assessment = kwargs.pop('server_vulnerability_assessment', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServerVulnerabilityAssessment] + server_vulnerability_assessment = kwargs.pop( + "server_vulnerability_assessment", "default" + ) # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessment] - request = build_get_request( resource_group_name=resource_group_name, resource_namespace=resource_namespace, @@ -167,7 +178,7 @@ async def get( subscription_id=self._config.subscription_id, server_vulnerability_assessment=server_vulnerability_assessment, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -175,9 +186,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -186,24 +195,18 @@ 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('ServerVulnerabilityAssessment', pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # type: ignore @distributed_trace_async async def create_or_update( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any ) -> _models.ServerVulnerabilityAssessment: """Creating a server vulnerability assessment on a resource, which will onboard a resource for having a vulnerability assessment on it. @@ -227,18 +230,22 @@ async def create_or_update( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - server_vulnerability_assessment = kwargs.pop('server_vulnerability_assessment', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ServerVulnerabilityAssessment] + server_vulnerability_assessment = kwargs.pop( + "server_vulnerability_assessment", "default" + ) # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessment] - request = build_create_or_update_request( resource_group_name=resource_group_name, resource_namespace=resource_namespace, @@ -247,7 +254,7 @@ async def create_or_update( subscription_id=self._config.subscription_id, server_vulnerability_assessment=server_vulnerability_assessment, api_version=api_version, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -255,9 +262,7 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -266,37 +271,35 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ServerVulnerabilityAssessment', pipeline_response) + deserialized = self._deserialize("ServerVulnerabilityAssessment", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # type: ignore async def _delete_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - server_vulnerability_assessment = kwargs.pop('server_vulnerability_assessment', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + server_vulnerability_assessment = kwargs.pop( + "server_vulnerability_assessment", "default" + ) # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, resource_namespace=resource_namespace, @@ -305,7 +308,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements subscription_id=self._config.subscription_id, server_vulnerability_assessment=server_vulnerability_assessment, api_version=api_version, - template_url=self._delete_initial.metadata['url'], + template_url=self._delete_initial.metadata["url"], headers=_headers, params=_params, ) @@ -313,9 +316,7 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -327,17 +328,11 @@ async def _delete_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _delete_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # type: ignore - + _delete_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # type: ignore @distributed_trace_async async def begin_delete( - self, - resource_group_name: str, - resource_namespace: str, - resource_type: str, - resource_name: str, - **kwargs: Any + self, resource_group_name: str, resource_namespace: str, resource_type: str, resource_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Removing server vulnerability assessment from a resource. @@ -369,15 +364,14 @@ async def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - server_vulnerability_assessment = kwargs.pop('server_vulnerability_assessment', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + server_vulnerability_assessment = kwargs.pop( + "server_vulnerability_assessment", "default" + ) # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._delete_initial( # type: ignore resource_group_name=resource_group_name, @@ -386,34 +380,32 @@ async def begin_delete( resource_name=resource_name, server_vulnerability_assessment=server_vulnerability_assessment, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # type: ignore + begin_delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceNamespace}/{resourceType}/{resourceName}/providers/Microsoft.Security/serverVulnerabilityAssessments/{serverVulnerabilityAssessment}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_topology_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_topology_operations.py index 7996a058582c..8568c81fb33c 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_topology_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/aio/operations/_topology_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -22,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._topology_operations import build_get_request, build_list_by_home_region_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TopologyOperations: """ .. warning:: @@ -44,12 +58,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.TopologyResource"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.TopologyResource"]: """Gets a list that allows to build a topology view of a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,20 +71,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopologyList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopologyList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -83,10 +97,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -103,9 +124,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,18 +134,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/topologies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/topologies"} # type: ignore @distributed_trace - def list_by_home_region( - self, - asc_location: str, - **kwargs: Any - ) -> AsyncIterable["_models.TopologyResource"]: + def list_by_home_region(self, asc_location: str, **kwargs: Any) -> AsyncIterable["_models.TopologyResource"]: """Gets a list that allows to build a topology view of a subscription and location. :param asc_location: The location where ASC stores the data of the subscription. can be @@ -141,21 +154,25 @@ def list_by_home_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopologyList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopologyList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_home_region_request( asc_location=asc_location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_home_region.metadata['url'], + template_url=self.list_by_home_region.metadata["url"], headers=_headers, params=_params, ) @@ -164,10 +181,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -184,9 +208,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -196,19 +218,13 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_home_region.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/topologies"} # type: ignore + list_by_home_region.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/locations/{ascLocation}/topologies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - asc_location: str, - topology_resource_name: str, - **kwargs: Any + self, resource_group_name: str, asc_location: str, topology_resource_name: str, **kwargs: Any ) -> _models.TopologyResource: """Gets a specific topology component. @@ -226,24 +242,26 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TopologyResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TopologyResource] - request = build_get_request( resource_group_name=resource_group_name, asc_location=asc_location, topology_resource_name=topology_resource_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -251,9 +269,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -262,12 +278,11 @@ 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('TopologyResource', pipeline_response) + deserialized = self._deserialize("TopologyResource", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/topologies/{topologyResourceName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/locations/{ascLocation}/topologies/{topologyResourceName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/__init__.py index 04e9256c865f..22cb443808b0 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/__init__.py @@ -120,117 +120,118 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AadConnectivityState', - 'AadExternalSecuritySolution', - 'AadSolutionProperties', - 'AdaptiveApplicationControlGroup', - 'AdaptiveApplicationControlGroups', - 'AdaptiveApplicationControlIssueSummary', - 'AdaptiveNetworkHardening', - 'AdaptiveNetworkHardeningEnforceRequest', - 'AdaptiveNetworkHardeningsList', - 'AllowedConnectionsList', - 'AllowedConnectionsResource', - 'AssessmentLinks', - 'AssessmentStatus', - 'AtaExternalSecuritySolution', - 'AtaSolutionProperties', - 'AzureResourceDetails', - 'AzureResourceLink', - 'CefExternalSecuritySolution', - 'CefSolutionProperties', - 'CloudErrorBody', - 'ConnectableResource', - 'ConnectedResource', - 'ConnectedWorkspace', - 'DiscoveredSecuritySolution', - 'DiscoveredSecuritySolutionList', - 'EffectiveNetworkSecurityGroups', - 'ErrorAdditionalInfo', - 'ExternalSecuritySolution', - 'ExternalSecuritySolutionKind', - 'ExternalSecuritySolutionList', - 'ExternalSecuritySolutionProperties', - 'JitNetworkAccessPoliciesList', - 'JitNetworkAccessPolicy', - 'JitNetworkAccessPolicyInitiatePort', - 'JitNetworkAccessPolicyInitiateRequest', - 'JitNetworkAccessPolicyInitiateVirtualMachine', - 'JitNetworkAccessPolicyVirtualMachine', - 'JitNetworkAccessPortRule', - 'JitNetworkAccessRequest', - 'JitNetworkAccessRequestPort', - 'JitNetworkAccessRequestVirtualMachine', - 'Kind', - 'Location', - 'OnPremiseResourceDetails', - 'OnPremiseSqlResourceDetails', - 'PathRecommendation', - 'ProtectionMode', - 'PublisherInfo', - 'Resource', - 'ResourceDetails', - 'Rule', - 'SecureScoreControlDefinitionItem', - 'SecureScoreControlDefinitionList', - 'SecureScoreControlDefinitionSource', - 'SecureScoreControlDetails', - 'SecureScoreControlList', - 'SecureScoreControlScore', - 'SecureScoreItem', - 'SecureScoresList', - 'SecurityAssessment', - 'SecurityAssessmentList', - 'SecurityAssessmentMetadata', - 'SecurityAssessmentMetadataList', - 'SecurityAssessmentMetadataPartnerData', - 'SecurityAssessmentMetadataProperties', - 'SecurityAssessmentPartnerData', - 'SecuritySolution', - 'SecuritySolutionList', - 'SecuritySolutionsReferenceData', - 'SecuritySolutionsReferenceDataList', - 'ServerVulnerabilityAssessment', - 'ServerVulnerabilityAssessmentsList', - 'TopologyList', - 'TopologyResource', - 'TopologySingleResource', - 'TopologySingleResourceChild', - 'TopologySingleResourceParent', - 'UserRecommendation', - 'VmRecommendation', - 'AadConnectivityStateEnum', - 'AdaptiveApplicationControlIssue', - 'AssessmentStatusCode', - 'AssessmentType', - 'Categories', - 'ConfigurationStatus', - 'ConnectionType', - 'ControlType', - 'Direction', - 'EnforcementMode', - 'EnforcementSupport', - 'ExpandControlsEnum', - 'ExpandEnum', - 'ExternalSecuritySolutionKindEnum', - 'FileType', - 'ImplementationEffort', - 'ProtocolEnum', - 'ProvisioningState', - 'RecommendationAction', - 'RecommendationStatus', - 'RecommendationType', - 'SecurityFamily', - 'ServerVulnerabilityAssessmentPropertiesProvisioningState', - 'Severity', - 'Source', - 'SourceSystem', - 'Status', - 'StatusReason', - 'Threats', - 'TransportProtocol', - 'UserImpact', + "AadConnectivityState", + "AadExternalSecuritySolution", + "AadSolutionProperties", + "AdaptiveApplicationControlGroup", + "AdaptiveApplicationControlGroups", + "AdaptiveApplicationControlIssueSummary", + "AdaptiveNetworkHardening", + "AdaptiveNetworkHardeningEnforceRequest", + "AdaptiveNetworkHardeningsList", + "AllowedConnectionsList", + "AllowedConnectionsResource", + "AssessmentLinks", + "AssessmentStatus", + "AtaExternalSecuritySolution", + "AtaSolutionProperties", + "AzureResourceDetails", + "AzureResourceLink", + "CefExternalSecuritySolution", + "CefSolutionProperties", + "CloudErrorBody", + "ConnectableResource", + "ConnectedResource", + "ConnectedWorkspace", + "DiscoveredSecuritySolution", + "DiscoveredSecuritySolutionList", + "EffectiveNetworkSecurityGroups", + "ErrorAdditionalInfo", + "ExternalSecuritySolution", + "ExternalSecuritySolutionKind", + "ExternalSecuritySolutionList", + "ExternalSecuritySolutionProperties", + "JitNetworkAccessPoliciesList", + "JitNetworkAccessPolicy", + "JitNetworkAccessPolicyInitiatePort", + "JitNetworkAccessPolicyInitiateRequest", + "JitNetworkAccessPolicyInitiateVirtualMachine", + "JitNetworkAccessPolicyVirtualMachine", + "JitNetworkAccessPortRule", + "JitNetworkAccessRequest", + "JitNetworkAccessRequestPort", + "JitNetworkAccessRequestVirtualMachine", + "Kind", + "Location", + "OnPremiseResourceDetails", + "OnPremiseSqlResourceDetails", + "PathRecommendation", + "ProtectionMode", + "PublisherInfo", + "Resource", + "ResourceDetails", + "Rule", + "SecureScoreControlDefinitionItem", + "SecureScoreControlDefinitionList", + "SecureScoreControlDefinitionSource", + "SecureScoreControlDetails", + "SecureScoreControlList", + "SecureScoreControlScore", + "SecureScoreItem", + "SecureScoresList", + "SecurityAssessment", + "SecurityAssessmentList", + "SecurityAssessmentMetadata", + "SecurityAssessmentMetadataList", + "SecurityAssessmentMetadataPartnerData", + "SecurityAssessmentMetadataProperties", + "SecurityAssessmentPartnerData", + "SecuritySolution", + "SecuritySolutionList", + "SecuritySolutionsReferenceData", + "SecuritySolutionsReferenceDataList", + "ServerVulnerabilityAssessment", + "ServerVulnerabilityAssessmentsList", + "TopologyList", + "TopologyResource", + "TopologySingleResource", + "TopologySingleResourceChild", + "TopologySingleResourceParent", + "UserRecommendation", + "VmRecommendation", + "AadConnectivityStateEnum", + "AdaptiveApplicationControlIssue", + "AssessmentStatusCode", + "AssessmentType", + "Categories", + "ConfigurationStatus", + "ConnectionType", + "ControlType", + "Direction", + "EnforcementMode", + "EnforcementSupport", + "ExpandControlsEnum", + "ExpandEnum", + "ExternalSecuritySolutionKindEnum", + "FileType", + "ImplementationEffort", + "ProtocolEnum", + "ProvisioningState", + "RecommendationAction", + "RecommendationStatus", + "RecommendationType", + "SecurityFamily", + "ServerVulnerabilityAssessmentPropertiesProvisioningState", + "Severity", + "Source", + "SourceSystem", + "Status", + "StatusReason", + "Threats", + "TransportProtocol", + "UserImpact", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_models_py3.py index 358bbf9b07db..f912e7b9bdda 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_models_py3.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_models_py3.py @@ -31,10 +31,7 @@ class AadConnectivityState(_serialization.Model): } def __init__( - self, - *, - connectivity_state: Optional[Union[str, "_models.AadConnectivityStateEnum"]] = None, - **kwargs + self, *, connectivity_state: Optional[Union[str, "_models.AadConnectivityStateEnum"]] = None, **kwargs ): """ :keyword connectivity_state: The connectivity state of the external AAD solution. Known values @@ -56,19 +53,15 @@ class Location(_serialization.Model): """ _validation = { - 'location': {'readonly': True}, + "location": {"readonly": True}, } _attribute_map = { "location": {"key": "location", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.location = None @@ -84,12 +77,7 @@ class ExternalSecuritySolutionKind(_serialization.Model): "kind": {"key": "kind", "type": "str"}, } - def __init__( - self, - *, - kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, - **kwargs - ): + def __init__(self, *, kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, **kwargs): """ :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". :paramtype kind: str or @@ -113,9 +101,9 @@ class Resource(_serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { @@ -124,12 +112,8 @@ class Resource(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.id = None self.name = None @@ -154,10 +138,10 @@ class ExternalSecuritySolution(Resource, ExternalSecuritySolutionKind, Location) """ _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { @@ -168,12 +152,7 @@ class ExternalSecuritySolution(Resource, ExternalSecuritySolutionKind, Location) "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, - **kwargs - ): + def __init__(self, *, kind: Optional[Union[str, "_models.ExternalSecuritySolutionKindEnum"]] = None, **kwargs): """ :keyword kind: The kind of the external solution. Known values are: "CEF", "ATA", and "AAD". :paramtype kind: str or @@ -207,10 +186,10 @@ class AadExternalSecuritySolution(ExternalSecuritySolution): """ _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { @@ -339,7 +318,14 @@ def __init__( :keyword workspace: Represents an OMS workspace to which the solution is connected. :paramtype workspace: ~azure.mgmt.security.v2020_01_01.models.ConnectedWorkspace """ - super().__init__(additional_properties=additional_properties, device_vendor=device_vendor, device_type=device_type, workspace=workspace, connectivity_state=connectivity_state, **kwargs) + super().__init__( + additional_properties=additional_properties, + device_vendor=device_vendor, + device_type=device_type, + workspace=workspace, + connectivity_state=connectivity_state, + **kwargs + ) self.connectivity_state = connectivity_state self.additional_properties = additional_properties self.device_vendor = device_vendor @@ -387,14 +373,14 @@ class AdaptiveApplicationControlGroup(Resource, Location): # pylint: disable=to """ _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'configuration_status': {'readonly': True}, - 'recommendation_status': {'readonly': True}, - 'issues': {'readonly': True}, - 'source_system': {'readonly': True}, + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "configuration_status": {"readonly": True}, + "recommendation_status": {"readonly": True}, + "issues": {"readonly": True}, + "source_system": {"readonly": True}, } _attribute_map = { @@ -460,12 +446,7 @@ class AdaptiveApplicationControlGroups(_serialization.Model): "value": {"key": "value", "type": "[AdaptiveApplicationControlGroup]"}, } - def __init__( - self, - *, - value: Optional[List["_models.AdaptiveApplicationControlGroup"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.AdaptiveApplicationControlGroup"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.AdaptiveApplicationControlGroup] @@ -533,9 +514,9 @@ class AdaptiveNetworkHardening(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { @@ -544,7 +525,10 @@ class AdaptiveNetworkHardening(Resource): "type": {"key": "type", "type": "str"}, "rules": {"key": "properties.rules", "type": "[Rule]"}, "rules_calculation_time": {"key": "properties.rulesCalculationTime", "type": "iso-8601"}, - "effective_network_security_groups": {"key": "properties.effectiveNetworkSecurityGroups", "type": "[EffectiveNetworkSecurityGroups]"}, + "effective_network_security_groups": { + "key": "properties.effectiveNetworkSecurityGroups", + "type": "[EffectiveNetworkSecurityGroups]", + }, } def __init__( @@ -585,8 +569,8 @@ class AdaptiveNetworkHardeningEnforceRequest(_serialization.Model): """ _validation = { - 'rules': {'required': True}, - 'network_security_groups': {'required': True}, + "rules": {"required": True}, + "network_security_groups": {"required": True}, } _attribute_map = { @@ -594,13 +578,7 @@ class AdaptiveNetworkHardeningEnforceRequest(_serialization.Model): "network_security_groups": {"key": "networkSecurityGroups", "type": "[str]"}, } - def __init__( - self, - *, - rules: List["_models.Rule"], - network_security_groups: List[str], - **kwargs - ): + def __init__(self, *, rules: List["_models.Rule"], network_security_groups: List[str], **kwargs): """ :keyword rules: The rules to enforce. Required. :paramtype rules: list[~azure.mgmt.security.v2020_01_01.models.Rule] @@ -658,8 +636,8 @@ class AllowedConnectionsList(_serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -667,12 +645,8 @@ class AllowedConnectionsList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.value = None self.next_link = None @@ -700,12 +674,12 @@ class AllowedConnectionsResource(Resource, Location): """ _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'calculated_date_time': {'readonly': True}, - 'connectable_resources': {'readonly': True}, + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "calculated_date_time": {"readonly": True}, + "connectable_resources": {"readonly": True}, } _attribute_map = { @@ -717,12 +691,8 @@ class AllowedConnectionsResource(Resource, Location): "connectable_resources": {"key": "properties.connectableResources", "type": "[ConnectableResource]"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.location = None self.calculated_date_time = None @@ -742,19 +712,15 @@ class AssessmentLinks(_serialization.Model): """ _validation = { - 'azure_portal_uri': {'readonly': True}, + "azure_portal_uri": {"readonly": True}, } _attribute_map = { "azure_portal_uri": {"key": "azurePortalUri", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.azure_portal_uri = None @@ -774,7 +740,7 @@ class AssessmentStatus(_serialization.Model): """ _validation = { - 'code': {'required': True}, + "code": {"required": True}, } _attribute_map = { @@ -826,10 +792,10 @@ class AtaExternalSecuritySolution(ExternalSecuritySolution): """ _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { @@ -906,7 +872,13 @@ def __init__( :keyword last_event_received: :paramtype last_event_received: str """ - super().__init__(additional_properties=additional_properties, device_vendor=device_vendor, device_type=device_type, workspace=workspace, **kwargs) + super().__init__( + additional_properties=additional_properties, + device_vendor=device_vendor, + device_type=device_type, + workspace=workspace, + **kwargs + ) self.last_event_received = last_event_received @@ -924,23 +896,17 @@ class ResourceDetails(_serialization.Model): """ _validation = { - 'source': {'required': True}, + "source": {"required": True}, } _attribute_map = { "source": {"key": "source", "type": "str"}, } - _subtype_map = { - 'source': {'Azure': 'AzureResourceDetails', 'OnPremise': 'OnPremiseResourceDetails'} - } + _subtype_map = {"source": {"Azure": "AzureResourceDetails", "OnPremise": "OnPremiseResourceDetails"}} - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.source = None # type: Optional[str] @@ -960,8 +926,8 @@ class AzureResourceDetails(ResourceDetails): """ _validation = { - 'source': {'required': True}, - 'id': {'readonly': True}, + "source": {"required": True}, + "id": {"readonly": True}, } _attribute_map = { @@ -969,14 +935,10 @@ class AzureResourceDetails(ResourceDetails): "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) - self.source = 'Azure' # type: str + self.source = "Azure" # type: str self.id = None @@ -990,19 +952,15 @@ class AzureResourceLink(_serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.id = None @@ -1027,10 +985,10 @@ class CefExternalSecuritySolution(ExternalSecuritySolution): """ _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { @@ -1119,7 +1077,13 @@ def __init__( :keyword last_event_received: :paramtype last_event_received: str """ - super().__init__(additional_properties=additional_properties, device_vendor=device_vendor, device_type=device_type, workspace=workspace, **kwargs) + super().__init__( + additional_properties=additional_properties, + device_vendor=device_vendor, + device_type=device_type, + workspace=workspace, + **kwargs + ) self.hostname = hostname self.agent = agent self.last_event_received = last_event_received @@ -1143,11 +1107,11 @@ class CloudErrorBody(_serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { @@ -1158,12 +1122,8 @@ class CloudErrorBody(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.code = None self.message = None @@ -1190,9 +1150,9 @@ class ConnectableResource(_serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'inbound_connected_resources': {'readonly': True}, - 'outbound_connected_resources': {'readonly': True}, + "id": {"readonly": True}, + "inbound_connected_resources": {"readonly": True}, + "outbound_connected_resources": {"readonly": True}, } _attribute_map = { @@ -1201,12 +1161,8 @@ class ConnectableResource(_serialization.Model): "outbound_connected_resources": {"key": "outboundConnectedResources", "type": "[ConnectedResource]"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.id = None self.inbound_connected_resources = None @@ -1227,9 +1183,9 @@ class ConnectedResource(_serialization.Model): """ _validation = { - 'connected_resource_id': {'readonly': True}, - 'tcp_ports': {'readonly': True}, - 'udp_ports': {'readonly': True}, + "connected_resource_id": {"readonly": True}, + "tcp_ports": {"readonly": True}, + "udp_ports": {"readonly": True}, } _attribute_map = { @@ -1238,12 +1194,8 @@ class ConnectedResource(_serialization.Model): "udp_ports": {"key": "udpPorts", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.connected_resource_id = None self.tcp_ports = None @@ -1261,12 +1213,7 @@ class ConnectedWorkspace(_serialization.Model): "id": {"key": "id", "type": "str"}, } - def __init__( - self, - *, - id: Optional[str] = None, # pylint: disable=redefined-builtin - **kwargs - ): + def __init__(self, *, id: Optional[str] = None, **kwargs): # pylint: disable=redefined-builtin """ :keyword id: Azure resource ID of the connected OMS workspace. :paramtype id: str @@ -1302,14 +1249,14 @@ class DiscoveredSecuritySolution(Resource, Location): """ _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'security_family': {'required': True}, - 'offer': {'required': True}, - 'publisher': {'required': True}, - 'sku': {'required': True}, + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "security_family": {"required": True}, + "offer": {"required": True}, + "publisher": {"required": True}, + "sku": {"required": True}, } _attribute_map = { @@ -1324,13 +1271,7 @@ class DiscoveredSecuritySolution(Resource, Location): } def __init__( - self, - *, - security_family: Union[str, "_models.SecurityFamily"], - offer: str, - publisher: str, - sku: str, - **kwargs + self, *, security_family: Union[str, "_models.SecurityFamily"], offer: str, publisher: str, sku: str, **kwargs ): """ :keyword security_family: The security family of the discovered solution. Required. Known @@ -1366,7 +1307,7 @@ class DiscoveredSecuritySolutionList(_serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -1374,12 +1315,7 @@ class DiscoveredSecuritySolutionList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.DiscoveredSecuritySolution"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.DiscoveredSecuritySolution"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.DiscoveredSecuritySolution] @@ -1404,11 +1340,7 @@ class EffectiveNetworkSecurityGroups(_serialization.Model): } def __init__( - self, - *, - network_interface: Optional[str] = None, - network_security_groups: Optional[List[str]] = None, - **kwargs + self, *, network_interface: Optional[str] = None, network_security_groups: Optional[List[str]] = None, **kwargs ): """ :keyword network_interface: The Azure resource ID of the network interface. @@ -1434,8 +1366,8 @@ class ErrorAdditionalInfo(_serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { @@ -1443,12 +1375,8 @@ class ErrorAdditionalInfo(_serialization.Model): "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.type = None self.info = None @@ -1466,7 +1394,7 @@ class ExternalSecuritySolutionList(_serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -1474,12 +1402,7 @@ class ExternalSecuritySolutionList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ExternalSecuritySolution"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ExternalSecuritySolution"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.ExternalSecuritySolution] @@ -1501,7 +1424,7 @@ class JitNetworkAccessPoliciesList(_serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -1509,12 +1432,7 @@ class JitNetworkAccessPoliciesList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.JitNetworkAccessPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.JitNetworkAccessPolicy"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.JitNetworkAccessPolicy] @@ -1535,12 +1453,7 @@ class Kind(_serialization.Model): "kind": {"key": "kind", "type": "str"}, } - def __init__( - self, - *, - kind: Optional[str] = None, - **kwargs - ): + def __init__(self, *, kind: Optional[str] = None, **kwargs): """ :keyword kind: Kind of the resource. :paramtype kind: str @@ -1577,12 +1490,12 @@ class JitNetworkAccessPolicy(Resource, Kind, Location): """ _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'virtual_machines': {'required': True}, - 'provisioning_state': {'readonly': True}, + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "virtual_machines": {"required": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -1640,8 +1553,8 @@ class JitNetworkAccessPolicyInitiatePort(_serialization.Model): """ _validation = { - 'number': {'required': True, 'maximum': 65535, 'minimum': 0}, - 'end_time_utc': {'required': True}, + "number": {"required": True, "maximum": 65535, "minimum": 0}, + "end_time_utc": {"required": True}, } _attribute_map = { @@ -1686,7 +1599,7 @@ class JitNetworkAccessPolicyInitiateRequest(_serialization.Model): """ _validation = { - 'virtual_machines': {'required': True}, + "virtual_machines": {"required": True}, } _attribute_map = { @@ -1726,8 +1639,8 @@ class JitNetworkAccessPolicyInitiateVirtualMachine(_serialization.Model): """ _validation = { - 'id': {'required': True}, - 'ports': {'required': True}, + "id": {"required": True}, + "ports": {"required": True}, } _attribute_map = { @@ -1769,8 +1682,8 @@ class JitNetworkAccessPolicyVirtualMachine(_serialization.Model): """ _validation = { - 'id': {'required': True}, - 'ports': {'required': True}, + "id": {"required": True}, + "ports": {"required": True}, } _attribute_map = { @@ -1823,9 +1736,9 @@ class JitNetworkAccessPortRule(_serialization.Model): """ _validation = { - 'number': {'required': True, 'maximum': 65535, 'minimum': 0}, - 'protocol': {'required': True}, - 'max_request_access_duration': {'required': True}, + "number": {"required": True, "maximum": 65535, "minimum": 0}, + "protocol": {"required": True}, + "max_request_access_duration": {"required": True}, } _attribute_map = { @@ -1887,9 +1800,9 @@ class JitNetworkAccessRequest(_serialization.Model): """ _validation = { - 'virtual_machines': {'required': True}, - 'start_time_utc': {'required': True}, - 'requestor': {'required': True}, + "virtual_machines": {"required": True}, + "start_time_utc": {"required": True}, + "requestor": {"required": True}, } _attribute_map = { @@ -1952,10 +1865,10 @@ class JitNetworkAccessRequestPort(_serialization.Model): """ _validation = { - 'number': {'required': True, 'maximum': 65535, 'minimum': 0}, - 'end_time_utc': {'required': True}, - 'status': {'required': True}, - 'status_reason': {'required': True}, + "number": {"required": True, "maximum": 65535, "minimum": 0}, + "end_time_utc": {"required": True}, + "status": {"required": True}, + "status_reason": {"required": True}, } _attribute_map = { @@ -2023,8 +1936,8 @@ class JitNetworkAccessRequestVirtualMachine(_serialization.Model): """ _validation = { - 'id': {'required': True}, - 'ports': {'required': True}, + "id": {"required": True}, + "ports": {"required": True}, } _attribute_map = { @@ -2072,11 +1985,11 @@ class OnPremiseResourceDetails(ResourceDetails): """ _validation = { - 'source': {'required': True}, - 'workspace_id': {'required': True}, - 'vmuuid': {'required': True}, - 'source_computer_id': {'required': True}, - 'machine_name': {'required': True}, + "source": {"required": True}, + "workspace_id": {"required": True}, + "vmuuid": {"required": True}, + "source_computer_id": {"required": True}, + "machine_name": {"required": True}, } _attribute_map = { @@ -2087,19 +2000,9 @@ class OnPremiseResourceDetails(ResourceDetails): "machine_name": {"key": "machineName", "type": "str"}, } - _subtype_map = { - 'source': {'OnPremiseSql': 'OnPremiseSqlResourceDetails'} - } + _subtype_map = {"source": {"OnPremiseSql": "OnPremiseSqlResourceDetails"}} - def __init__( - self, - *, - workspace_id: str, - vmuuid: str, - source_computer_id: str, - machine_name: str, - **kwargs - ): + def __init__(self, *, workspace_id: str, vmuuid: str, source_computer_id: str, machine_name: str, **kwargs): """ :keyword workspace_id: Azure resource Id of the workspace the machine is attached to. Required. :paramtype workspace_id: str @@ -2111,7 +2014,7 @@ def __init__( :paramtype machine_name: str """ super().__init__(**kwargs) - self.source = 'OnPremise' # type: str + self.source = "OnPremise" # type: str self.workspace_id = workspace_id self.vmuuid = vmuuid self.source_computer_id = source_computer_id @@ -2141,13 +2044,13 @@ class OnPremiseSqlResourceDetails(OnPremiseResourceDetails): """ _validation = { - 'source': {'required': True}, - 'workspace_id': {'required': True}, - 'vmuuid': {'required': True}, - 'source_computer_id': {'required': True}, - 'machine_name': {'required': True}, - 'server_name': {'required': True}, - 'database_name': {'required': True}, + "source": {"required": True}, + "workspace_id": {"required": True}, + "vmuuid": {"required": True}, + "source_computer_id": {"required": True}, + "machine_name": {"required": True}, + "server_name": {"required": True}, + "database_name": {"required": True}, } _attribute_map = { @@ -2185,8 +2088,14 @@ def __init__( :keyword database_name: The Sql database name installed on the machine. Required. :paramtype database_name: str """ - super().__init__(workspace_id=workspace_id, vmuuid=vmuuid, source_computer_id=source_computer_id, machine_name=machine_name, **kwargs) - self.source = 'OnPremiseSql' # type: str + super().__init__( + workspace_id=workspace_id, + vmuuid=vmuuid, + source_computer_id=source_computer_id, + machine_name=machine_name, + **kwargs + ) + self.source = "OnPremiseSql" # type: str self.server_name = server_name self.database_name = database_name @@ -2402,7 +2311,7 @@ class Rule(_serialization.Model): """ _validation = { - 'destination_port': {'maximum': 65535, 'minimum': 0}, + "destination_port": {"maximum": 65535, "minimum": 0}, } _attribute_map = { @@ -2470,14 +2379,14 @@ class SecureScoreControlDefinitionItem(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'description': {'readonly': True, 'max_length': 256}, - 'max_score': {'readonly': True, 'maximum': 10, 'minimum': 0}, - 'source': {'readonly': True}, - 'assessment_definitions': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "description": {"readonly": True, "max_length": 256}, + "max_score": {"readonly": True, "maximum": 10, "minimum": 0}, + "source": {"readonly": True}, + "assessment_definitions": {"readonly": True}, } _attribute_map = { @@ -2491,12 +2400,8 @@ class SecureScoreControlDefinitionItem(Resource): "assessment_definitions": {"key": "properties.assessmentDefinitions", "type": "[AzureResourceLink]"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.display_name = None self.description = None @@ -2517,8 +2422,8 @@ class SecureScoreControlDefinitionList(_serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -2526,12 +2431,8 @@ class SecureScoreControlDefinitionList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.value = None self.next_link = None @@ -2549,12 +2450,7 @@ class SecureScoreControlDefinitionSource(_serialization.Model): "source_type": {"key": "sourceType", "type": "str"}, } - def __init__( - self, - *, - source_type: Optional[Union[str, "_models.ControlType"]] = None, - **kwargs - ): + def __init__(self, *, source_type: Optional[Union[str, "_models.ControlType"]] = None, **kwargs): """ :keyword source_type: The type of security control (for example, BuiltIn). Known values are: "BuiltIn" and "Custom". @@ -2598,17 +2494,17 @@ class SecureScoreControlDetails(Resource): # pylint: disable=too-many-instance- """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'healthy_resource_count': {'readonly': True}, - 'unhealthy_resource_count': {'readonly': True}, - 'not_applicable_resource_count': {'readonly': True}, - 'weight': {'readonly': True, 'minimum': 0}, - 'max': {'readonly': True, 'minimum': 0}, - 'current': {'readonly': True, 'minimum': 0}, - 'percentage': {'readonly': True, 'maximum': 1, 'minimum': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "healthy_resource_count": {"readonly": True}, + "unhealthy_resource_count": {"readonly": True}, + "not_applicable_resource_count": {"readonly": True}, + "weight": {"readonly": True, "minimum": 0}, + "max": {"readonly": True, "minimum": 0}, + "current": {"readonly": True, "minimum": 0}, + "percentage": {"readonly": True, "maximum": 1, "minimum": 0}, } _attribute_map = { @@ -2626,12 +2522,7 @@ class SecureScoreControlDetails(Resource): # pylint: disable=too-many-instance- "percentage": {"key": "properties.score.percentage", "type": "float"}, } - def __init__( - self, - *, - definition: Optional["_models.SecureScoreControlDefinitionItem"] = None, - **kwargs - ): + def __init__(self, *, definition: Optional["_models.SecureScoreControlDefinitionItem"] = None, **kwargs): """ :keyword definition: Information about the security control. :paramtype definition: ~azure.mgmt.security.v2020_01_01.models.SecureScoreControlDefinitionItem @@ -2660,8 +2551,8 @@ class SecureScoreControlList(_serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -2669,12 +2560,8 @@ class SecureScoreControlList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.value = None self.next_link = None @@ -2696,9 +2583,9 @@ class SecureScoreControlScore(_serialization.Model): """ _validation = { - 'max': {'readonly': True, 'maximum': 10, 'minimum': 0}, - 'current': {'readonly': True, 'maximum': 10, 'minimum': 0}, - 'percentage': {'readonly': True, 'maximum': 1, 'minimum': 0}, + "max": {"readonly": True, "maximum": 10, "minimum": 0}, + "current": {"readonly": True, "maximum": 10, "minimum": 0}, + "percentage": {"readonly": True, "maximum": 1, "minimum": 0}, } _attribute_map = { @@ -2707,12 +2594,8 @@ class SecureScoreControlScore(_serialization.Model): "percentage": {"key": "percentage", "type": "float"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.max = None self.current = None @@ -2745,14 +2628,14 @@ class SecureScoreItem(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'weight': {'readonly': True, 'minimum': 0}, - 'max': {'readonly': True, 'minimum': 0}, - 'current': {'readonly': True, 'minimum': 0}, - 'percentage': {'readonly': True, 'maximum': 1, 'minimum': 0}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "weight": {"readonly": True, "minimum": 0}, + "max": {"readonly": True, "minimum": 0}, + "current": {"readonly": True, "minimum": 0}, + "percentage": {"readonly": True, "maximum": 1, "minimum": 0}, } _attribute_map = { @@ -2766,12 +2649,8 @@ class SecureScoreItem(Resource): "percentage": {"key": "properties.score.percentage", "type": "float"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.display_name = None self.weight = None @@ -2792,8 +2671,8 @@ class SecureScoresList(_serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -2801,12 +2680,8 @@ class SecureScoresList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.value = None self.next_link = None @@ -2840,11 +2715,11 @@ class SecurityAssessment(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'display_name': {'readonly': True}, - 'links': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "display_name": {"readonly": True}, + "links": {"readonly": True}, } _attribute_map = { @@ -2905,8 +2780,8 @@ class SecurityAssessmentList(_serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -2914,12 +2789,8 @@ class SecurityAssessmentList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.value = None self.next_link = None @@ -2972,10 +2843,10 @@ class SecurityAssessmentMetadata(Resource): # pylint: disable=too-many-instance """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_definition_id': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_definition_id": {"readonly": True}, } _attribute_map = { @@ -3071,8 +2942,8 @@ class SecurityAssessmentMetadataList(_serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -3080,12 +2951,8 @@ class SecurityAssessmentMetadataList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.value = None self.next_link = None @@ -3106,8 +2973,8 @@ class SecurityAssessmentMetadataPartnerData(_serialization.Model): """ _validation = { - 'partner_name': {'required': True}, - 'secret': {'required': True}, + "partner_name": {"required": True}, + "secret": {"required": True}, } _attribute_map = { @@ -3116,14 +2983,7 @@ class SecurityAssessmentMetadataPartnerData(_serialization.Model): "secret": {"key": "secret", "type": "str"}, } - def __init__( - self, - *, - partner_name: str, - secret: str, - product_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, partner_name: str, secret: str, product_name: Optional[str] = None, **kwargs): """ :keyword partner_name: Name of the company of the partner. Required. :paramtype partner_name: str @@ -3182,10 +3042,10 @@ class SecurityAssessmentMetadataProperties(_serialization.Model): # pylint: dis """ _validation = { - 'display_name': {'required': True}, - 'policy_definition_id': {'readonly': True}, - 'severity': {'required': True}, - 'assessment_type': {'required': True}, + "display_name": {"required": True}, + "policy_definition_id": {"readonly": True}, + "severity": {"required": True}, + "assessment_type": {"required": True}, } _attribute_map = { @@ -3278,8 +3138,8 @@ class SecurityAssessmentPartnerData(_serialization.Model): """ _validation = { - 'partner_name': {'required': True}, - 'secret': {'required': True}, + "partner_name": {"required": True}, + "secret": {"required": True}, } _attribute_map = { @@ -3287,13 +3147,7 @@ class SecurityAssessmentPartnerData(_serialization.Model): "secret": {"key": "secret", "type": "str"}, } - def __init__( - self, - *, - partner_name: str, - secret: str, - **kwargs - ): + def __init__(self, *, partner_name: str, secret: str, **kwargs): """ :keyword partner_name: Name of the company of the partner. Required. :paramtype partner_name: str @@ -3331,10 +3185,10 @@ class SecuritySolution(Resource, Location): """ _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { @@ -3392,7 +3246,7 @@ class SecuritySolutionList(_serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -3400,12 +3254,7 @@ class SecuritySolutionList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.SecuritySolution"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SecuritySolution"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.SecuritySolution] @@ -3448,17 +3297,17 @@ class SecuritySolutionsReferenceData(Resource, Location): # pylint: disable=too """ _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'security_family': {'required': True}, - 'alert_vendor_name': {'required': True}, - 'package_info_url': {'required': True}, - 'product_name': {'required': True}, - 'publisher': {'required': True}, - 'publisher_display_name': {'required': True}, - 'template': {'required': True}, + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "security_family": {"required": True}, + "alert_vendor_name": {"required": True}, + "package_info_url": {"required": True}, + "product_name": {"required": True}, + "publisher": {"required": True}, + "publisher_display_name": {"required": True}, + "template": {"required": True}, } _attribute_map = { @@ -3529,12 +3378,7 @@ class SecuritySolutionsReferenceDataList(_serialization.Model): "value": {"key": "value", "type": "[SecuritySolutionsReferenceData]"}, } - def __init__( - self, - *, - value: Optional[List["_models.SecuritySolutionsReferenceData"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.SecuritySolutionsReferenceData"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.SecuritySolutionsReferenceData] @@ -3562,10 +3406,10 @@ class ServerVulnerabilityAssessment(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { @@ -3575,12 +3419,8 @@ class ServerVulnerabilityAssessment(Resource): "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.provisioning_state = None @@ -3596,12 +3436,7 @@ class ServerVulnerabilityAssessmentsList(_serialization.Model): "value": {"key": "value", "type": "[ServerVulnerabilityAssessment]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ServerVulnerabilityAssessment"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ServerVulnerabilityAssessment"]] = None, **kwargs): """ :keyword value: :paramtype value: list[~azure.mgmt.security.v2020_01_01.models.ServerVulnerabilityAssessment] @@ -3622,8 +3457,8 @@ class TopologyList(_serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -3631,12 +3466,8 @@ class TopologyList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.value = None self.next_link = None @@ -3663,12 +3494,12 @@ class TopologyResource(Resource, Location): """ _validation = { - 'location': {'readonly': True}, - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'calculated_date_time': {'readonly': True}, - 'topology_resources': {'readonly': True}, + "location": {"readonly": True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "calculated_date_time": {"readonly": True}, + "topology_resources": {"readonly": True}, } _attribute_map = { @@ -3680,12 +3511,8 @@ class TopologyResource(Resource, Location): "topology_resources": {"key": "properties.topologyResources", "type": "[TopologySingleResource]"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.location = None self.calculated_date_time = None @@ -3722,14 +3549,14 @@ class TopologySingleResource(_serialization.Model): """ _validation = { - 'resource_id': {'readonly': True}, - 'severity': {'readonly': True}, - 'recommendations_exist': {'readonly': True}, - 'network_zones': {'readonly': True}, - 'topology_score': {'readonly': True}, - 'location': {'readonly': True}, - 'parents': {'readonly': True}, - 'children': {'readonly': True}, + "resource_id": {"readonly": True}, + "severity": {"readonly": True}, + "recommendations_exist": {"readonly": True}, + "network_zones": {"readonly": True}, + "topology_score": {"readonly": True}, + "location": {"readonly": True}, + "parents": {"readonly": True}, + "children": {"readonly": True}, } _attribute_map = { @@ -3743,12 +3570,8 @@ class TopologySingleResource(_serialization.Model): "children": {"key": "children", "type": "[TopologySingleResourceChild]"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.resource_id = None self.severity = None @@ -3770,19 +3593,15 @@ class TopologySingleResourceChild(_serialization.Model): """ _validation = { - 'resource_id': {'readonly': True}, + "resource_id": {"readonly": True}, } _attribute_map = { "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.resource_id = None @@ -3797,19 +3616,15 @@ class TopologySingleResourceParent(_serialization.Model): """ _validation = { - 'resource_id': {'readonly': True}, + "resource_id": {"readonly": True}, } _attribute_map = { "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.resource_id = None diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_security_center_enums.py index c66b5e0d8b5e..3521c0d26140 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_security_center_enums.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/models/_security_center_enums.py @@ -11,16 +11,15 @@ class AadConnectivityStateEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The connectivity state of the external AAD solution. - """ + """The connectivity state of the external AAD solution.""" DISCOVERED = "Discovered" NOT_LICENSED = "NotLicensed" CONNECTED = "Connected" + class AdaptiveApplicationControlIssue(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """An alert that machines within a group can have. - """ + """An alert that machines within a group can have.""" VIOLATIONS_AUDITED = "ViolationsAudited" VIOLATIONS_BLOCKED = "ViolationsBlocked" @@ -29,9 +28,9 @@ class AdaptiveApplicationControlIssue(str, Enum, metaclass=CaseInsensitiveEnumMe EXECUTABLE_VIOLATIONS_AUDITED = "ExecutableViolationsAudited" RULES_VIOLATED_MANUALLY = "RulesViolatedManually" + class AssessmentStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Programmatic code for the status of the assessment. - """ + """Programmatic code for the status of the assessment.""" #: The resource is healthy HEALTHY = "Healthy" @@ -40,6 +39,7 @@ class AssessmentStatusCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: Assessment for this resource did not happen NOT_APPLICABLE = "NotApplicable" + class AssessmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """BuiltIn if the assessment based on built-in Azure Policy definition, Custom if the assessment based on custom Azure Policy definition. @@ -56,9 +56,9 @@ class AssessmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: An assessment that was created by a verified 3rd party if the user connected it to ASC VERIFIED_PARTNER = "VerifiedPartner" + class Categories(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The categories of resource that is at risk when the assessment is unhealthy. - """ + """The categories of resource that is at risk when the assessment is unhealthy.""" COMPUTE = "Compute" NETWORKING = "Networking" @@ -66,9 +66,9 @@ class Categories(str, Enum, metaclass=CaseInsensitiveEnumMeta): IDENTITY_AND_ACCESS = "IdentityAndAccess" IO_T = "IoT" + class ConfigurationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The configuration status of the machines group or machine or rule. - """ + """The configuration status of the machines group or machine or rule.""" CONFIGURED = "Configured" NOT_CONFIGURED = "NotConfigured" @@ -76,72 +76,72 @@ class ConfigurationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "Failed" NO_STATUS = "NoStatus" + class ConnectionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ConnectionType. - """ + """ConnectionType.""" INTERNAL = "Internal" EXTERNAL = "External" + class ControlType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of security control (for example, BuiltIn). - """ + """The type of security control (for example, BuiltIn).""" #: Microsoft Defender for Cloud managed assessments BUILT_IN = "BuiltIn" #: Non Microsoft Defender for Cloud managed assessments CUSTOM = "Custom" + class Direction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The rule's direction. - """ + """The rule's direction.""" INBOUND = "Inbound" OUTBOUND = "Outbound" + class EnforcementMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The application control policy enforcement/protection mode of the machine group. - """ + """The application control policy enforcement/protection mode of the machine group.""" AUDIT = "Audit" ENFORCE = "Enforce" NONE = "None" + class EnforcementSupport(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The machine supportability of Enforce feature. - """ + """The machine supportability of Enforce feature.""" SUPPORTED = "Supported" NOT_SUPPORTED = "NotSupported" UNKNOWN = "Unknown" + class ExpandControlsEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ExpandControlsEnum. - """ + """ExpandControlsEnum.""" #: Add definition object for each control DEFINITION = "definition" + class ExpandEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ExpandEnum. - """ + """ExpandEnum.""" #: All links associated with an assessment LINKS = "links" #: Assessment metadata METADATA = "metadata" + class ExternalSecuritySolutionKindEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The kind of the external solution. - """ + """The kind of the external solution.""" CEF = "CEF" ATA = "ATA" AAD = "AAD" + class FileType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the file (for Linux files - Executable is used). - """ + """The type of the file (for Linux files - Executable is used).""" EXE = "Exe" DLL = "Dll" @@ -150,50 +150,50 @@ class FileType(str, Enum, metaclass=CaseInsensitiveEnumMeta): EXECUTABLE = "Executable" UNKNOWN = "Unknown" + class ImplementationEffort(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The implementation effort required to remediate this assessment. - """ + """The implementation effort required to remediate this assessment.""" LOW = "Low" MODERATE = "Moderate" HIGH = "High" + class ProtocolEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """ProtocolEnum. - """ + """ProtocolEnum.""" TCP = "TCP" UDP = "UDP" ALL = "*" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The security family provisioning State. - """ + """The security family provisioning State.""" SUCCEEDED = "Succeeded" FAILED = "Failed" UPDATING = "Updating" + class RecommendationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The recommendation action of the machine or rule. - """ + """The recommendation action of the machine or rule.""" RECOMMENDED = "Recommended" ADD = "Add" REMOVE = "Remove" + class RecommendationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The initial recommendation status of the machine group or machine. - """ + """The initial recommendation status of the machine group or machine.""" RECOMMENDED = "Recommended" NOT_RECOMMENDED = "NotRecommended" NOT_AVAILABLE = "NotAvailable" NO_STATUS = "NoStatus" + class RecommendationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of the rule to be allowed. - """ + """The type of the rule to be allowed.""" FILE = "File" FILE_HASH = "FileHash" @@ -202,18 +202,18 @@ class RecommendationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): BINARY_SIGNATURE = "BinarySignature" VERSION_AND_ABOVE_SIGNATURE = "VersionAndAboveSignature" + class SecurityFamily(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The security family of the discovered solution. - """ + """The security family of the discovered solution.""" WAF = "Waf" NGFW = "Ngfw" SAAS_WAF = "SaasWaf" VA = "Va" + class ServerVulnerabilityAssessmentPropertiesProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The provisioningState of the vulnerability assessment capability on the VM. - """ + """The provisioningState of the vulnerability assessment capability on the VM.""" SUCCEEDED = "Succeeded" FAILED = "Failed" @@ -221,17 +221,17 @@ class ServerVulnerabilityAssessmentPropertiesProvisioningState(str, Enum, metacl PROVISIONING = "Provisioning" DEPROVISIONING = "Deprovisioning" + class Severity(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The severity level of the assessment. - """ + """The severity level of the assessment.""" LOW = "Low" MEDIUM = "Medium" HIGH = "High" + class Source(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The platform where the assessed resource resides. - """ + """The platform where the assessed resource resides.""" #: Resource is in Azure AZURE = "Azure" @@ -240,9 +240,9 @@ class Source(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: SQL Resource in an on premise machine connected to Azure cloud ON_PREMISE_SQL = "OnPremiseSql" + class SourceSystem(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The source type of the machine group. - """ + """The source type of the machine group.""" AZURE_APP_LOCKER = "Azure_AppLocker" AZURE_AUDIT_D = "Azure_AuditD" @@ -250,24 +250,24 @@ class SourceSystem(str, Enum, metaclass=CaseInsensitiveEnumMeta): NON_AZURE_AUDIT_D = "NonAzure_AuditD" NONE = "None" + class Status(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the port. - """ + """The status of the port.""" REVOKED = "Revoked" INITIATED = "Initiated" + class StatusReason(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """A description of why the ``status`` has its value. - """ + """A description of why the ``status`` has its value.""" EXPIRED = "Expired" USER_REQUESTED = "UserRequested" NEWER_REQUEST_INITIATED = "NewerRequestInitiated" + class Threats(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Threats impact of the assessment. - """ + """Threats impact of the assessment.""" ACCOUNT_BREACH = "accountBreach" DATA_EXFILTRATION = "dataExfiltration" @@ -278,16 +278,16 @@ class Threats(str, Enum, metaclass=CaseInsensitiveEnumMeta): MISSING_COVERAGE = "missingCoverage" DENIAL_OF_SERVICE = "denialOfService" + class TransportProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """TransportProtocol. - """ + """TransportProtocol.""" TCP = "TCP" UDP = "UDP" + class UserImpact(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The user impact of the assessment. - """ + """The user impact of the assessment.""" LOW = "Low" MODERATE = "Moderate" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_application_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_application_controls_operations.py index 576ef208ecc5..fff0749da585 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_application_controls_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_application_controls_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -44,7 +49,7 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -78,7 +83,7 @@ def build_get_request(asc_location: str, group_name: str, subscription_id: str, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -109,7 +114,7 @@ def build_put_request(asc_location: str, group_name: str, subscription_id: str, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -143,7 +148,7 @@ def build_delete_request(asc_location: str, group_name: str, subscription_id: st _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -215,7 +220,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AdaptiveApplicationControlGroups] request = build_list_request( @@ -274,7 +279,7 @@ def get(self, asc_location: str, group_name: str, **kwargs: Any) -> _models.Adap _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AdaptiveApplicationControlGroup] request = build_get_request( @@ -394,7 +399,7 @@ def put( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.AdaptiveApplicationControlGroup] @@ -467,7 +472,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_network_hardenings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_network_hardenings_operations.py index 8865ab45899f..306da09fb4c1 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_network_hardenings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_adaptive_network_hardenings_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -49,7 +54,7 @@ def build_list_by_extended_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -92,7 +97,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -140,8 +145,8 @@ def build_enforce_request( adaptive_network_hardening_enforce_action = kwargs.pop( "adaptive_network_hardening_enforce_action", "enforce" - ) # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + ) # type: Literal["enforce"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -225,7 +230,7 @@ def list_by_extended_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AdaptiveNetworkHardeningsList] error_map = { @@ -255,10 +260,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -329,7 +341,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AdaptiveNetworkHardening] request = build_get_request( @@ -389,8 +401,8 @@ def _enforce_initial( # pylint: disable=inconsistent-return-statements adaptive_network_hardening_enforce_action = kwargs.pop( "adaptive_network_hardening_enforce_action", "enforce" - ) # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + ) # type: Literal["enforce"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] @@ -586,8 +598,8 @@ def begin_enforce( adaptive_network_hardening_enforce_action = kwargs.pop( "adaptive_network_hardening_enforce_action", "enforce" - ) # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + ) # type: Literal["enforce"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_allowed_connections_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_allowed_connections_operations.py index 5f4d6def55bf..6929ecb0f58a 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_allowed_connections_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_allowed_connections_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar, Union -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +71,7 @@ def build_list_by_home_region_request(asc_location: str, subscription_id: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -95,14 +100,14 @@ def build_list_by_home_region_request(asc_location: str, subscription_id: str, * def build_get_request( resource_group_name: str, asc_location: str, - connection_type: Union[str, "_models.ConnectionType"], + connection_type: Union[str, _models.ConnectionType], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -165,7 +170,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.AllowedConnectionsResource"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedConnectionsList] error_map = { @@ -191,10 +196,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -242,7 +254,7 @@ def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedConnectionsList] error_map = { @@ -269,10 +281,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -308,7 +327,7 @@ def get( self, resource_group_name: str, asc_location: str, - connection_type: Union[str, "_models.ConnectionType"], + connection_type: Union[str, _models.ConnectionType], **kwargs: Any ) -> _models.AllowedConnectionsResource: """Gets the list of all possible traffic between resources for the subscription and location, @@ -339,7 +358,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AllowedConnectionsResource] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_metadata_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_metadata_operations.py index 82b2105674c2..437167903c12 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_metadata_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_metadata_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_get_request(assessment_metadata_name: str, **kwargs: Any) -> HttpReque _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +88,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -111,7 +116,7 @@ def build_get_in_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +148,7 @@ def build_create_in_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -178,7 +183,7 @@ def build_delete_in_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -237,7 +242,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityAssessmentMetadata"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataList] error_map = { @@ -262,10 +267,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -319,7 +331,7 @@ def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityA _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadata] request = build_get_request( @@ -365,7 +377,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SecurityAsses _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataList] error_map = { @@ -391,10 +403,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -448,7 +467,7 @@ def get_in_subscription(self, assessment_metadata_name: str, **kwargs: Any) -> _ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadata] request = build_get_in_subscription_request( @@ -566,7 +585,7 @@ def create_in_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadata] @@ -637,7 +656,7 @@ def delete_in_subscription( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_in_subscription_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_operations.py index 23da392cf2b1..6ed562817062 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_assessments_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,12 +66,12 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: def build_get_request( - resource_id: str, assessment_name: str, *, expand: Optional[Union[str, "_models.ExpandEnum"]] = None, **kwargs: Any + resource_id: str, assessment_name: str, *, expand: Optional[Union[str, _models.ExpandEnum]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +98,7 @@ def build_create_or_update_request(resource_id: str, assessment_name: str, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -121,7 +126,7 @@ def build_delete_request(resource_id: str, assessment_name: str, **kwargs: Any) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -178,7 +183,7 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.SecurityAssessmen _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentList] error_map = { @@ -204,10 +209,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -243,7 +255,7 @@ def get( self, resource_id: str, assessment_name: str, - expand: Optional[Union[str, "_models.ExpandEnum"]] = None, + expand: Optional[Union[str, _models.ExpandEnum]] = None, **kwargs: Any ) -> _models.SecurityAssessment: """Get a security assessment on your scanned resource. @@ -271,7 +283,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessment] request = build_get_request( @@ -394,7 +406,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessment] @@ -470,7 +482,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_discovered_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_discovered_security_solutions_operations.py index d223fdf7340c..e5fc10eda33b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_discovered_security_solutions_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_discovered_security_solutions_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +73,7 @@ def build_list_by_home_region_request(asc_location: str, subscription_id: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -104,7 +109,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -169,7 +174,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.DiscoveredSecuritySolution"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DiscoveredSecuritySolutionList] error_map = { @@ -195,10 +200,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -246,7 +258,7 @@ def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DiscoveredSecuritySolutionList] error_map = { @@ -273,10 +285,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -337,7 +356,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.DiscoveredSecuritySolution] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_external_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_external_security_solutions_operations.py index af77fba3ea31..00a0e84c865b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_external_security_solutions_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_external_security_solutions_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +73,7 @@ def build_list_by_home_region_request(asc_location: str, subscription_id: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -104,7 +109,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -169,7 +174,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.ExternalSecuritySolution"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ExternalSecuritySolutionList] error_map = { @@ -195,10 +200,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -246,7 +258,7 @@ def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ExternalSecuritySolutionList] error_map = { @@ -273,10 +285,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -337,7 +356,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ExternalSecuritySolution] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_jit_network_access_policies_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_jit_network_access_policies_operations.py index 766cfc7c97be..6f6bd6431853 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_jit_network_access_policies_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_jit_network_access_policies_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +73,7 @@ def build_list_by_region_request(asc_location: str, subscription_id: str, **kwar _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +103,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 = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -132,7 +137,7 @@ def build_list_by_resource_group_and_region_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -171,7 +176,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -213,7 +218,7 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -258,7 +263,7 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -302,8 +307,8 @@ def build_initiate_request( jit_network_access_policy_initiate_type = kwargs.pop( "jit_network_access_policy_initiate_type", "initiate" - ) # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + ) # type: Literal["initiate"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -374,7 +379,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.JitNetworkAccessPolicy"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPoliciesList] error_map = { @@ -400,10 +405,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -452,7 +464,7 @@ def list_by_region(self, asc_location: str, **kwargs: Any) -> Iterable["_models. _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPoliciesList] error_map = { @@ -479,10 +491,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -533,7 +552,7 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPoliciesList] error_map = { @@ -560,10 +579,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -617,7 +643,7 @@ def list_by_resource_group_and_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPoliciesList] error_map = { @@ -645,10 +671,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -711,7 +744,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPolicy] request = build_get_request( @@ -853,7 +886,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessPolicy] @@ -931,7 +964,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -1083,8 +1116,8 @@ def initiate( jit_network_access_policy_initiate_type = kwargs.pop( "jit_network_access_policy_initiate_type", "initiate" - ) # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + ) # type: Literal["initiate"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.JitNetworkAccessRequest] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_control_definitions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_control_definitions_operations.py index e2aeb24faf82..3bb1cbd8d86d 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_control_definitions_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_control_definitions_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -116,7 +121,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecureScoreControlDefinitionI _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoreControlDefinitionList] error_map = { @@ -141,10 +146,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -190,7 +202,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SecureScoreCo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoreControlDefinitionList] error_map = { @@ -216,10 +228,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_controls_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_controls_operations.py index bb5e8a114e42..e5720ed24935 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_controls_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_score_controls_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar, Union -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,13 +45,13 @@ def build_list_by_secure_score_request( secure_score_name: str, subscription_id: str, *, - expand: Optional[Union[str, "_models.ExpandControlsEnum"]] = None, + expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -75,12 +80,12 @@ def build_list_by_secure_score_request( def build_list_request( - subscription_id: str, *, expand: Optional[Union[str, "_models.ExpandControlsEnum"]] = None, **kwargs: Any + subscription_id: str, *, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +132,7 @@ def __init__(self, *args, **kwargs): @distributed_trace def list_by_secure_score( - self, secure_score_name: str, expand: Optional[Union[str, "_models.ExpandControlsEnum"]] = None, **kwargs: Any + self, secure_score_name: str, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any ) -> Iterable["_models.SecureScoreControlDetails"]: """Get all security controls for a specific initiative within a scope. @@ -146,7 +151,7 @@ def list_by_secure_score( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoreControlList] error_map = { @@ -174,10 +179,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -210,7 +222,7 @@ def get_next(next_link=None): @distributed_trace def list( - self, expand: Optional[Union[str, "_models.ExpandControlsEnum"]] = None, **kwargs: Any + self, expand: Optional[Union[str, _models.ExpandControlsEnum]] = None, **kwargs: Any ) -> Iterable["_models.SecureScoreControlDetails"]: """Get all security controls within a scope. @@ -226,7 +238,7 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoreControlList] error_map = { @@ -253,10 +265,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_scores_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_scores_operations.py index 7afefc7523a3..42a221dadd27 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_scores_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_secure_scores_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +71,7 @@ def build_get_request(secure_score_name: str, subscription_id: str, **kwargs: An _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -123,7 +128,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecureScoreItem"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoresList] error_map = { @@ -149,10 +154,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -207,7 +219,7 @@ def get(self, secure_score_name: str, **kwargs: Any) -> _models.SecureScoreItem: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecureScoreItem] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_operations.py index fbf12bc96fa9..d32ce7c086dd 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +73,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -129,7 +134,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecuritySolution"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySolutionList] error_map = { @@ -155,10 +160,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -219,7 +231,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySolution] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_reference_data_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_reference_data_operations.py index 753e4b7ea0ea..44d4baec6c5a 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_reference_data_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_security_solutions_reference_data_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,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 = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +71,7 @@ def build_list_by_home_region_request(asc_location: str, subscription_id: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -131,7 +136,7 @@ def list(self, **kwargs: Any) -> _models.SecuritySolutionsReferenceDataList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySolutionsReferenceDataList] request = build_list_request( @@ -186,7 +191,7 @@ def list_by_home_region(self, asc_location: str, **kwargs: Any) -> _models.Secur _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecuritySolutionsReferenceDataList] request = build_list_by_home_region_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_server_vulnerability_assessment_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_server_vulnerability_assessment_operations.py index a9f17636c842..f49d3fd4d88f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_server_vulnerability_assessment_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_server_vulnerability_assessment_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar, Union, cast from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +52,7 @@ def build_list_by_extended_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -89,8 +94,10 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - server_vulnerability_assessment = kwargs.pop("server_vulnerability_assessment", "default") # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + server_vulnerability_assessment = kwargs.pop( + "server_vulnerability_assessment", "default" + ) # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,8 +142,10 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - server_vulnerability_assessment = kwargs.pop("server_vulnerability_assessment", "default") # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + server_vulnerability_assessment = kwargs.pop( + "server_vulnerability_assessment", "default" + ) # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -181,8 +190,10 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - server_vulnerability_assessment = kwargs.pop("server_vulnerability_assessment", "default") # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + server_vulnerability_assessment = kwargs.pop( + "server_vulnerability_assessment", "default" + ) # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -266,7 +277,7 @@ def list_by_extended_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessmentsList] request = build_list_by_extended_resource_request( @@ -337,8 +348,10 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - server_vulnerability_assessment = kwargs.pop("server_vulnerability_assessment", "default") # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + server_vulnerability_assessment = kwargs.pop( + "server_vulnerability_assessment", "default" + ) # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessment] request = build_get_request( @@ -411,8 +424,10 @@ def create_or_update( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - server_vulnerability_assessment = kwargs.pop("server_vulnerability_assessment", "default") # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + server_vulnerability_assessment = kwargs.pop( + "server_vulnerability_assessment", "default" + ) # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerVulnerabilityAssessment] request = build_create_or_update_request( @@ -463,8 +478,10 @@ def _delete_initial( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - server_vulnerability_assessment = kwargs.pop("server_vulnerability_assessment", "default") # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + server_vulnerability_assessment = kwargs.pop( + "server_vulnerability_assessment", "default" + ) # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -531,8 +548,10 @@ def begin_delete( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - server_vulnerability_assessment = kwargs.pop("server_vulnerability_assessment", "default") # type: str - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + server_vulnerability_assessment = kwargs.pop( + "server_vulnerability_assessment", "default" + ) # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_topology_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_topology_operations.py index 1cca6ef8ceba..c0e23166eb5f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_topology_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01/operations/_topology_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +71,7 @@ def build_list_by_home_region_request(asc_location: str, subscription_id: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +103,7 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -159,7 +164,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.TopologyResource"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.TopologyList] error_map = { @@ -185,10 +190,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -234,7 +246,7 @@ def list_by_home_region(self, asc_location: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.TopologyList] error_map = { @@ -261,10 +273,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -325,7 +344,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-01-01")) # type: Literal["2020-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.TopologyResource] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_configuration.py index ae35f0fad6a3..16b000307558 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2020-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-01-01-preview") # type: Literal["2020-01-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_metadata.json index 047d717b391b..3e2097810054 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_metadata.json @@ -99,4 +99,4 @@ "operation_groups": { "connectors": "ConnectorsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/__init__.py index 23906b4c7b04..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['SecurityCenter'] + +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_configuration.py index 954856784769..4c63533d8d8d 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -34,14 +40,9 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-01-01-preview") # type: Literal["2020-01-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-security/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_security_center.py index fa0a5e2b3f88..2c1984123c43 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/_security_center.py @@ -21,6 +21,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential + class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword """API spec for Microsoft.Security (Azure Security Center) resource provider. @@ -52,16 +53,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.connectors = ConnectorsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.connectors = ConnectorsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/__init__.py index 1d6239b35b09..36717e9887ca 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectorsOperations', + "ConnectorsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_connectors_operations.py index faeb687dcc68..e71f9e9c6b8e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_connectors_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._connectors_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._connectors_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ConnectorsOperations: """ .. warning:: @@ -44,12 +63,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.ConnectorSetting"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.ConnectorSetting"]: """Cloud accounts connectors of a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,20 +76,26 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSettingList] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectorSettingList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -83,10 +104,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -103,9 +131,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,18 +141,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors"} # type: ignore @distributed_trace_async - async def get( - self, - connector_name: str, - **kwargs: Any - ) -> _models.ConnectorSetting: + async def get(self, connector_name: str, **kwargs: Any) -> _models.ConnectorSetting: """Details of a specific cloud account connector. :param connector_name: Name of the cloud account connector. Required. @@ -137,22 +157,26 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSetting] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectorSetting] - request = build_get_request( connector_name=connector_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -160,9 +184,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -171,15 +193,14 @@ 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('ConnectorSetting', pipeline_response) + deserialized = self._deserialize("ConnectorSetting", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore @overload async def create_or_update( @@ -209,12 +230,7 @@ async def create_or_update( @overload async def create_or_update( - self, - connector_name: str, - connector_setting: IO, - *, - content_type: str = "application/json", - **kwargs: Any + self, connector_name: str, connector_setting: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ConnectorSetting: """Create a cloud account connector or update an existing one. Connect to your cloud account. For AWS, use either account credentials or role-based authentication. For GCP, use account @@ -233,13 +249,9 @@ async def create_or_update( :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace_async async def create_or_update( - self, - connector_name: str, - connector_setting: Union[_models.ConnectorSetting, IO], - **kwargs: Any + self, connector_name: str, connector_setting: Union[_models.ConnectorSetting, IO], **kwargs: Any ) -> _models.ConnectorSetting: """Create a cloud account connector or update an existing one. Connect to your cloud account. For AWS, use either account credentials or role-based authentication. For GCP, use account @@ -259,16 +271,21 @@ async def create_or_update( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSetting] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectorSetting] content_type = content_type or "application/json" _json = None @@ -276,7 +293,7 @@ async def create_or_update( if isinstance(connector_setting, (IO, bytes)): _content = connector_setting else: - _json = self._serialize.body(connector_setting, 'ConnectorSetting') + _json = self._serialize.body(connector_setting, "ConnectorSetting") request = build_create_or_update_request( connector_name=connector_name, @@ -285,7 +302,7 @@ async def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -293,9 +310,7 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -304,21 +319,18 @@ async def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectorSetting', pipeline_response) + deserialized = self._deserialize("ConnectorSetting", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - connector_name: str, - **kwargs: Any + self, connector_name: str, **kwargs: Any ) -> None: """Delete a cloud account connector from a subscription. @@ -330,22 +342,26 @@ async def delete( # pylint: disable=inconsistent-return-statements :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( connector_name=connector_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -353,9 +369,7 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -367,5 +381,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_patch.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/__init__.py index 0fb2cfc7e30d..4d965dbf3b31 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/__init__.py @@ -27,24 +27,25 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AuthenticationDetailsProperties', - 'AwAssumeRoleAuthenticationDetailsProperties', - 'AwsCredsAuthenticationDetailsProperties', - 'CloudErrorBody', - 'ConnectorSetting', - 'ConnectorSettingList', - 'ErrorAdditionalInfo', - 'GcpCredentialsDetailsProperties', - 'HybridComputeSettingsProperties', - 'ProxyServerProperties', - 'Resource', - 'ServicePrincipalProperties', - 'AuthenticationProvisioningState', - 'AuthenticationType', - 'AutoProvision', - 'HybridComputeProvisioningState', - 'PermissionProperty', + "AuthenticationDetailsProperties", + "AwAssumeRoleAuthenticationDetailsProperties", + "AwsCredsAuthenticationDetailsProperties", + "CloudErrorBody", + "ConnectorSetting", + "ConnectorSettingList", + "ErrorAdditionalInfo", + "GcpCredentialsDetailsProperties", + "HybridComputeSettingsProperties", + "ProxyServerProperties", + "Resource", + "ServicePrincipalProperties", + "AuthenticationProvisioningState", + "AuthenticationType", + "AutoProvision", + "HybridComputeProvisioningState", + "PermissionProperty", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_models_py3.py index f9aa761a4a4c..7b508a23d1f2 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_models_py3.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_models_py3.py @@ -42,9 +42,9 @@ class AuthenticationDetailsProperties(_serialization.Model): """ _validation = { - 'authentication_provisioning_state': {'readonly': True}, - 'granted_permissions': {'readonly': True}, - 'authentication_type': {'required': True}, + "authentication_provisioning_state": {"readonly": True}, + "granted_permissions": {"readonly": True}, + "authentication_type": {"required": True}, } _attribute_map = { @@ -54,15 +54,15 @@ class AuthenticationDetailsProperties(_serialization.Model): } _subtype_map = { - 'authentication_type': {'awsAssumeRole': 'AwAssumeRoleAuthenticationDetailsProperties', 'awsCreds': 'AwsCredsAuthenticationDetailsProperties', 'gcpCredentials': 'GcpCredentialsDetailsProperties'} + "authentication_type": { + "awsAssumeRole": "AwAssumeRoleAuthenticationDetailsProperties", + "awsCreds": "AwsCredsAuthenticationDetailsProperties", + "gcpCredentials": "GcpCredentialsDetailsProperties", + } } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.authentication_provisioning_state = None self.granted_permissions = None @@ -99,12 +99,12 @@ class AwAssumeRoleAuthenticationDetailsProperties(AuthenticationDetailsPropertie """ _validation = { - 'authentication_provisioning_state': {'readonly': True}, - 'granted_permissions': {'readonly': True}, - 'authentication_type': {'required': True}, - 'account_id': {'readonly': True}, - 'aws_assume_role_arn': {'required': True}, - 'aws_external_id': {'required': True}, + "authentication_provisioning_state": {"readonly": True}, + "granted_permissions": {"readonly": True}, + "authentication_type": {"required": True}, + "account_id": {"readonly": True}, + "aws_assume_role_arn": {"required": True}, + "aws_external_id": {"required": True}, } _attribute_map = { @@ -116,13 +116,7 @@ class AwAssumeRoleAuthenticationDetailsProperties(AuthenticationDetailsPropertie "aws_external_id": {"key": "awsExternalId", "type": "str"}, } - def __init__( - self, - *, - aws_assume_role_arn: str, - aws_external_id: str, - **kwargs - ): + def __init__(self, *, aws_assume_role_arn: str, aws_external_id: str, **kwargs): """ :keyword aws_assume_role_arn: Assumed role ID is an identifier that you can use to create temporary security credentials. Required. @@ -132,7 +126,7 @@ def __init__( :paramtype aws_external_id: str """ super().__init__(**kwargs) - self.authentication_type = 'awsAssumeRole' # type: str + self.authentication_type = "awsAssumeRole" # type: str self.account_id = None self.aws_assume_role_arn = aws_assume_role_arn self.aws_external_id = aws_external_id @@ -168,12 +162,12 @@ class AwsCredsAuthenticationDetailsProperties(AuthenticationDetailsProperties): """ _validation = { - 'authentication_provisioning_state': {'readonly': True}, - 'granted_permissions': {'readonly': True}, - 'authentication_type': {'required': True}, - 'account_id': {'readonly': True}, - 'aws_access_key_id': {'required': True}, - 'aws_secret_access_key': {'required': True}, + "authentication_provisioning_state": {"readonly": True}, + "granted_permissions": {"readonly": True}, + "authentication_type": {"required": True}, + "account_id": {"readonly": True}, + "aws_access_key_id": {"required": True}, + "aws_secret_access_key": {"required": True}, } _attribute_map = { @@ -185,13 +179,7 @@ class AwsCredsAuthenticationDetailsProperties(AuthenticationDetailsProperties): "aws_secret_access_key": {"key": "awsSecretAccessKey", "type": "str"}, } - def __init__( - self, - *, - aws_access_key_id: str, - aws_secret_access_key: str, - **kwargs - ): + def __init__(self, *, aws_access_key_id: str, aws_secret_access_key: str, **kwargs): """ :keyword aws_access_key_id: Public key element of the AWS credential object (write only). Required. @@ -201,7 +189,7 @@ def __init__( :paramtype aws_secret_access_key: str """ super().__init__(**kwargs) - self.authentication_type = 'awsCreds' # type: str + self.authentication_type = "awsCreds" # type: str self.account_id = None self.aws_access_key_id = aws_access_key_id self.aws_secret_access_key = aws_secret_access_key @@ -226,11 +214,11 @@ class CloudErrorBody(_serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { @@ -241,12 +229,8 @@ class CloudErrorBody(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.code = None self.message = None @@ -269,9 +253,9 @@ class Resource(_serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { @@ -280,12 +264,8 @@ class Resource(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.id = None self.name = None @@ -314,17 +294,23 @@ class ConnectorSetting(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { "id": {"key": "id", "type": "str"}, "name": {"key": "name", "type": "str"}, "type": {"key": "type", "type": "str"}, - "hybrid_compute_settings": {"key": "properties.hybridComputeSettings", "type": "HybridComputeSettingsProperties"}, - "authentication_details": {"key": "properties.authenticationDetails", "type": "AuthenticationDetailsProperties"}, + "hybrid_compute_settings": { + "key": "properties.hybridComputeSettings", + "type": "HybridComputeSettingsProperties", + }, + "authentication_details": { + "key": "properties.authenticationDetails", + "type": "AuthenticationDetailsProperties", + }, } def __init__( @@ -361,7 +347,7 @@ class ConnectorSettingList(_serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -369,12 +355,7 @@ class ConnectorSettingList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.ConnectorSetting"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ConnectorSetting"]] = None, **kwargs): """ :keyword value: List of all the cloud account connector settings. :paramtype value: list[~azure.mgmt.security.v2020_01_01_preview.models.ConnectorSetting] @@ -396,8 +377,8 @@ class ErrorAdditionalInfo(_serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { @@ -405,12 +386,8 @@ class ErrorAdditionalInfo(_serialization.Model): "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.type = None self.info = None @@ -462,20 +439,20 @@ class GcpCredentialsDetailsProperties(AuthenticationDetailsProperties): # pylin """ _validation = { - 'authentication_provisioning_state': {'readonly': True}, - 'granted_permissions': {'readonly': True}, - 'authentication_type': {'required': True}, - 'organization_id': {'required': True}, - 'type': {'required': True}, - 'project_id': {'required': True}, - 'private_key_id': {'required': True}, - 'private_key': {'required': True}, - 'client_email': {'required': True}, - 'client_id': {'required': True}, - 'auth_uri': {'required': True}, - 'token_uri': {'required': True}, - 'auth_provider_x509_cert_url': {'required': True}, - 'client_x509_cert_url': {'required': True}, + "authentication_provisioning_state": {"readonly": True}, + "granted_permissions": {"readonly": True}, + "authentication_type": {"required": True}, + "organization_id": {"required": True}, + "type": {"required": True}, + "project_id": {"required": True}, + "private_key_id": {"required": True}, + "private_key": {"required": True}, + "client_email": {"required": True}, + "client_id": {"required": True}, + "auth_uri": {"required": True}, + "token_uri": {"required": True}, + "auth_provider_x509_cert_url": {"required": True}, + "client_x509_cert_url": {"required": True}, } _attribute_map = { @@ -538,7 +515,7 @@ def __init__( :paramtype client_x509_cert_url: str """ super().__init__(**kwargs) - self.authentication_type = 'gcpCredentials' # type: str + self.authentication_type = "gcpCredentials" # type: str self.organization_id = organization_id self.type = type self.project_id = project_id @@ -580,8 +557,8 @@ class HybridComputeSettingsProperties(_serialization.Model): """ _validation = { - 'hybrid_compute_provisioning_state': {'readonly': True}, - 'auto_provision': {'required': True}, + "hybrid_compute_provisioning_state": {"readonly": True}, + "auto_provision": {"required": True}, } _attribute_map = { @@ -643,13 +620,7 @@ class ProxyServerProperties(_serialization.Model): "port": {"key": "port", "type": "str"}, } - def __init__( - self, - *, - ip: Optional[str] = None, - port: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip: Optional[str] = None, port: Optional[str] = None, **kwargs): """ :keyword ip: Proxy server IP. :paramtype ip: str @@ -676,13 +647,7 @@ class ServicePrincipalProperties(_serialization.Model): "secret": {"key": "secret", "type": "str"}, } - def __init__( - self, - *, - application_id: Optional[str] = None, - secret: Optional[str] = None, - **kwargs - ): + def __init__(self, *, application_id: Optional[str] = None, secret: Optional[str] = None, **kwargs): """ :keyword application_id: Application ID of service principal. :paramtype application_id: str diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_security_center_enums.py index ae512c2bd2e8..9c10c4fb9804 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_security_center_enums.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/models/_security_center_enums.py @@ -11,8 +11,7 @@ class AuthenticationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """State of the multi-cloud connector. - """ + """State of the multi-cloud connector.""" #: Valid connector VALID = "Valid" @@ -23,6 +22,7 @@ class AuthenticationProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMe #: Incorrect policy of the connector INCORRECT_POLICY = "IncorrectPolicy" + class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Connect to your cloud account, for AWS use either account credentials or role-based authentication. For GCP use account organization credentials. @@ -35,18 +35,18 @@ class AuthenticationType(str, Enum, metaclass=CaseInsensitiveEnumMeta): #: GCP account connector service to service authentication GCP_CREDENTIALS = "gcpCredentials" + class AutoProvision(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Whether or not to automatically install Azure Arc (hybrid compute) agents on machines. - """ + """Whether or not to automatically install Azure Arc (hybrid compute) agents on machines.""" #: Install missing Azure Arc agents on machines automatically ON = "On" #: Do not install Azure Arc agent on the machines automatically OFF = "Off" + class HybridComputeProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """State of the service principal and its secret. - """ + """State of the service principal and its secret.""" #: Valid service principal details. VALID = "Valid" @@ -55,9 +55,9 @@ class HybridComputeProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMet #: the service principal details are expired EXPIRED = "Expired" + class PermissionProperty(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """A permission detected in the cloud account. - """ + """A permission detected in the cloud account.""" #: This permission provides read only access to AWS Security Hub resources. AWS_AWS_SECURITY_HUB_READ_ONLY_ACCESS = "AWS::AWSSecurityHubReadOnlyAccess" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/__init__.py index 1d6239b35b09..36717e9887ca 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'ConnectorsOperations', + "ConnectorsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_connectors_operations.py index 4f61e8839d8f..f23c32136df7 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_01_01_preview/operations/_connectors_operations.py @@ -6,10 +6,18 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -21,152 +29,141 @@ from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_get_request( - connector_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(connector_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - "connectorName": _SERIALIZER.url("connector_name", connector_name, 'str'), + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "connectorName": _SERIALIZER.url("connector_name", connector_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_create_or_update_request( - connector_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_request(connector_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - "connectorName": _SERIALIZER.url("connector_name", connector_name, 'str'), + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "connectorName": _SERIALIZER.url("connector_name", connector_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_delete_request( - connector_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request(connector_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - "connectorName": _SERIALIZER.url("connector_name", connector_name, 'str'), + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "connectorName": _SERIALIZER.url("connector_name", connector_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ConnectorsOperations: """ @@ -187,12 +184,8 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.ConnectorSetting"]: + def list(self, **kwargs: Any) -> Iterable["_models.ConnectorSetting"]: """Cloud accounts connectors of a subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -204,20 +197,26 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSettingList] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectorSettingList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -226,10 +225,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -246,9 +252,7 @@ def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -258,18 +262,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors"} # type: ignore @distributed_trace - def get( - self, - connector_name: str, - **kwargs: Any - ) -> _models.ConnectorSetting: + def get(self, connector_name: str, **kwargs: Any) -> _models.ConnectorSetting: """Details of a specific cloud account connector. :param connector_name: Name of the cloud account connector. Required. @@ -280,22 +278,26 @@ def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSetting] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectorSetting] - request = build_get_request( connector_name=connector_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -303,9 +305,7 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -314,15 +314,14 @@ 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('ConnectorSetting', pipeline_response) + deserialized = self._deserialize("ConnectorSetting", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore @overload def create_or_update( @@ -352,12 +351,7 @@ def create_or_update( @overload def create_or_update( - self, - connector_name: str, - connector_setting: IO, - *, - content_type: str = "application/json", - **kwargs: Any + self, connector_name: str, connector_setting: IO, *, content_type: str = "application/json", **kwargs: Any ) -> _models.ConnectorSetting: """Create a cloud account connector or update an existing one. Connect to your cloud account. For AWS, use either account credentials or role-based authentication. For GCP, use account @@ -376,13 +370,9 @@ def create_or_update( :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace def create_or_update( - self, - connector_name: str, - connector_setting: Union[_models.ConnectorSetting, IO], - **kwargs: Any + self, connector_name: str, connector_setting: Union[_models.ConnectorSetting, IO], **kwargs: Any ) -> _models.ConnectorSetting: """Create a cloud account connector or update an existing one. Connect to your cloud account. For AWS, use either account credentials or role-based authentication. For GCP, use account @@ -402,16 +392,21 @@ def create_or_update( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ConnectorSetting] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectorSetting] content_type = content_type or "application/json" _json = None @@ -419,7 +414,7 @@ def create_or_update( if isinstance(connector_setting, (IO, bytes)): _content = connector_setting else: - _json = self._serialize.body(connector_setting, 'ConnectorSetting') + _json = self._serialize.body(connector_setting, "ConnectorSetting") request = build_create_or_update_request( connector_name=connector_name, @@ -428,7 +423,7 @@ def create_or_update( content_type=content_type, json=_json, content=_content, - template_url=self.create_or_update.metadata['url'], + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -436,9 +431,7 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -447,22 +440,17 @@ def create_or_update( map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ConnectorSetting', pipeline_response) + deserialized = self._deserialize("ConnectorSetting", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore @distributed_trace - def delete( # pylint: disable=inconsistent-return-statements - self, - connector_name: str, - **kwargs: Any - ) -> None: + def delete(self, connector_name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements """Delete a cloud account connector from a subscription. :param connector_name: Name of the cloud account connector. Required. @@ -473,22 +461,26 @@ def delete( # pylint: disable=inconsistent-return-statements :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-01-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-01-01-preview") + ) # type: Literal["2020-01-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( connector_name=connector_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -496,9 +488,7 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -510,5 +500,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/connectors/{connectorName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_configuration.py index baa6932f44d6..e26ff92bc8dd 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -34,7 +40,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2020-07-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-07-01-preview") # type: Literal["2020-07-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_metadata.json index c06f42250e5b..097b59763bc9 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_metadata.json @@ -89,4 +89,4 @@ "sql_vulnerability_assessment_scan_results": "SqlVulnerabilityAssessmentScanResultsOperations", "sql_vulnerability_assessment_baseline_rules": "SqlVulnerabilityAssessmentBaselineRulesOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_configuration.py index 0f0dead106be..b5b327f05486 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -34,7 +40,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2020-07-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-07-01-preview") # type: Literal["2020-07-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py index 72e690c60f8c..3c06e26616f4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_baseline_rules_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -33,6 +34,10 @@ build_list_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -161,7 +166,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.RuleResults] @@ -238,7 +245,9 @@ async def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RuleResults] request = build_get_request( @@ -302,7 +311,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -358,7 +369,9 @@ async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RulesResults] request = build_list_request( @@ -486,7 +499,9 @@ async def add( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.RulesResults] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py index dfcecd3efa5d..f8a77971452d 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scan_results_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._sql_vulnerability_assessment_scan_results_operations import build_get_request, build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,7 +88,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ScanResult] request = build_get_request( @@ -147,7 +154,9 @@ async def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ScanResults] request = build_list_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py index 0fe78658a321..dd43e5060c63 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/aio/operations/_sql_vulnerability_assessment_scans_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._sql_vulnerability_assessment_scans_operations import build_get_request, build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -79,7 +84,9 @@ async def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Scan] request = build_get_request( @@ -139,7 +146,9 @@ async def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _mod _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Scans] request = build_list_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py index 905599255ed4..cfa641f0db7a 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_baseline_rules_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,9 @@ def build_create_or_update_request(rule_id: str, resource_id: str, *, workspace_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -70,7 +77,9 @@ def build_get_request(rule_id: str, resource_id: str, *, workspace_id: str, **kw _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -99,7 +108,9 @@ def build_delete_request(rule_id: str, resource_id: str, *, workspace_id: str, * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -128,7 +139,9 @@ def build_list_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -155,7 +168,9 @@ def build_add_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -305,7 +320,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.RuleResults] @@ -382,7 +399,9 @@ def get(self, rule_id: str, workspace_id: str, resource_id: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RuleResults] request = build_get_request( @@ -446,7 +465,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -502,7 +523,9 @@ def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Ru _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.RulesResults] request = build_list_request( @@ -630,7 +653,9 @@ def add( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.RulesResults] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py index d51b7d0b2030..7b5825a52b1e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scan_results_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -70,7 +77,9 @@ def build_list_request(scan_id: str, resource_id: str, *, workspace_id: str, **k _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -147,7 +156,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ScanResult] request = build_get_request( @@ -211,7 +222,9 @@ def list(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ScanResults] request = build_list_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py index 258d66847943..67b1fb530b27 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2020_07_01_preview/operations/_sql_vulnerability_assessment_scans_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,9 @@ def build_get_request(scan_id: str, resource_id: str, *, workspace_id: str, **kw _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +73,9 @@ def build_list_request(resource_id: str, *, workspace_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -137,7 +146,9 @@ def get(self, scan_id: str, workspace_id: str, resource_id: str, **kwargs: Any) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Scan] request = build_get_request( @@ -197,7 +208,9 @@ def list(self, workspace_id: str, resource_id: str, **kwargs: Any) -> _models.Sc _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2020-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-07-01-preview") + ) # type: Literal["2020-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Scans] request = build_list_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_configuration.py index dd390ea69d5f..dc619b6e3a5e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-01-01") # type: str + api_version = kwargs.pop("api_version", "2021-01-01") # type: Literal["2021-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_metadata.json index 70bd35c11acc..174825493d37 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_metadata.json @@ -99,4 +99,4 @@ "operation_groups": { "alerts": "AlertsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_configuration.py index 8d83abfa62a4..e6a65f1057b1 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-01-01") # type: str + api_version = kwargs.pop("api_version", "2021-01-01") # type: Literal["2021-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_alerts_operations.py index 62f6c9cf5808..0d4651467be4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_alerts_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/aio/operations/_alerts_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -46,6 +47,10 @@ build_update_subscription_level_state_to_resolve_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,7 +86,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Alert"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -107,10 +112,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -156,7 +168,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -183,10 +195,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -233,7 +252,7 @@ def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -260,10 +279,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -315,7 +341,7 @@ def list_resource_group_level_by_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -343,10 +369,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -402,7 +435,7 @@ async def get_subscription_level(self, asc_location: str, alert_name: str, **kwa _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Alert] request = build_get_subscription_level_request( @@ -466,7 +499,7 @@ async def get_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Alert] request = build_get_resource_group_level_request( @@ -528,7 +561,7 @@ async def update_subscription_level_state_to_dismiss( # pylint: disable=inconsi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_dismiss_request( @@ -585,7 +618,7 @@ async def update_subscription_level_state_to_resolve( # pylint: disable=inconsi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_resolve_request( @@ -642,7 +675,7 @@ async def update_subscription_level_state_to_activate( # pylint: disable=incons _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_activate_request( @@ -702,7 +735,7 @@ async def update_resource_group_level_state_to_resolve( # pylint: disable=incon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_resolve_request( @@ -763,7 +796,7 @@ async def update_resource_group_level_state_to_dismiss( # pylint: disable=incon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_dismiss_request( @@ -824,7 +857,7 @@ async def update_resource_group_level_state_to_activate( # pylint: disable=inco _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_activate_request( @@ -872,7 +905,7 @@ async def _simulate_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] @@ -1012,7 +1045,7 @@ async def begin_simulate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_models_py3.py index 3198d11fc790..2518d4a817ac 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_models_py3.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/models/_models_py3.py @@ -12,13 +12,14 @@ from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_alerts_operations.py index 11c127f92fd6..b96170f2f9d9 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_alerts_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_01/operations/_alerts_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,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 = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +73,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 = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -102,7 +107,7 @@ def build_list_subscription_level_by_region_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -133,7 +138,7 @@ def build_list_resource_group_level_by_region_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +173,7 @@ def build_get_subscription_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -201,7 +206,7 @@ def build_get_resource_group_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -237,7 +242,7 @@ def build_update_subscription_level_state_to_dismiss_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -270,7 +275,7 @@ def build_update_subscription_level_state_to_resolve_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -303,7 +308,7 @@ def build_update_subscription_level_state_to_activate_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -336,7 +341,7 @@ def build_update_resource_group_level_state_to_resolve_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -372,7 +377,7 @@ def build_update_resource_group_level_state_to_dismiss_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -408,7 +413,7 @@ def build_update_resource_group_level_state_to_activate_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -442,7 +447,7 @@ def build_simulate_request(asc_location: str, subscription_id: str, **kwargs: An _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -502,7 +507,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Alert"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -528,10 +533,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -577,7 +589,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -604,10 +616,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -654,7 +673,7 @@ def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -681,10 +700,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -736,7 +762,7 @@ def list_resource_group_level_by_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -764,10 +790,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -823,7 +856,7 @@ def get_subscription_level(self, asc_location: str, alert_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Alert] request = build_get_subscription_level_request( @@ -887,7 +920,7 @@ def get_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Alert] request = build_get_resource_group_level_request( @@ -949,7 +982,7 @@ def update_subscription_level_state_to_dismiss( # pylint: disable=inconsistent- _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_dismiss_request( @@ -1006,7 +1039,7 @@ def update_subscription_level_state_to_resolve( # pylint: disable=inconsistent- _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_resolve_request( @@ -1063,7 +1096,7 @@ def update_subscription_level_state_to_activate( # pylint: disable=inconsistent _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_activate_request( @@ -1123,7 +1156,7 @@ def update_resource_group_level_state_to_resolve( # pylint: disable=inconsisten _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_resolve_request( @@ -1184,7 +1217,7 @@ def update_resource_group_level_state_to_dismiss( # pylint: disable=inconsisten _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_dismiss_request( @@ -1245,7 +1278,7 @@ def update_resource_group_level_state_to_activate( # pylint: disable=inconsiste _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_activate_request( @@ -1293,7 +1326,7 @@ def _simulate_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] @@ -1433,7 +1466,7 @@ def begin_simulate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_configuration.py index ce9e3f3e8007..29eb554b4669 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-01-15-preview") # type: str + api_version = kwargs.pop("api_version", "2021-01-15-preview") # type: Literal["2021-01-15-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_metadata.json index bd9228fe81da..44fe3aad2097 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_metadata.json @@ -99,4 +99,4 @@ "operation_groups": { "ingestion_settings": "IngestionSettingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/_configuration.py index d6e7427866f1..ed15395c07e2 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-01-15-preview") # type: str + api_version = kwargs.pop("api_version", "2021-01-15-preview") # type: Literal["2021-01-15-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/_ingestion_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/_ingestion_settings_operations.py index 9f31f72e23f6..783c50fa9756 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/_ingestion_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/aio/operations/_ingestion_settings_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_list_tokens_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +79,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.IngestionSetting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IngestionSettingList] error_map = { @@ -100,10 +107,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -157,7 +171,9 @@ async def get(self, ingestion_setting_name: str, **kwargs: Any) -> _models.Inges _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IngestionSetting] request = build_get_request( @@ -271,7 +287,9 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.IngestionSetting] @@ -340,7 +358,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -392,7 +412,9 @@ async def list_tokens(self, ingestion_setting_name: str, **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IngestionSettingToken] request = build_list_tokens_request( @@ -447,7 +469,9 @@ async def list_connection_strings(self, ingestion_setting_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectionStrings] request = build_list_connection_strings_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/_ingestion_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/_ingestion_settings_operations.py index 9d03ba76fb4d..b59efd30e6fd 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/_ingestion_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_01_15_preview/operations/_ingestion_settings_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +73,9 @@ def build_get_request(ingestion_setting_name: str, subscription_id: str, **kwarg _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +105,9 @@ def build_create_request(ingestion_setting_name: str, subscription_id: str, **kw _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -129,7 +140,9 @@ def build_delete_request(ingestion_setting_name: str, subscription_id: str, **kw _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -159,7 +172,9 @@ def build_list_tokens_request(ingestion_setting_name: str, subscription_id: str, _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -191,7 +206,9 @@ def build_list_connection_strings_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -250,7 +267,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.IngestionSetting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IngestionSettingList] error_map = { @@ -276,10 +295,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -333,7 +359,9 @@ def get(self, ingestion_setting_name: str, **kwargs: Any) -> _models.IngestionSe _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IngestionSetting] request = build_get_request( @@ -447,7 +475,9 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.IngestionSetting] @@ -516,7 +546,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -568,7 +600,9 @@ def list_tokens(self, ingestion_setting_name: str, **kwargs: Any) -> _models.Ing _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.IngestionSettingToken] request = build_list_tokens_request( @@ -623,7 +657,9 @@ def list_connection_strings(self, ingestion_setting_name: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-15-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-01-15-preview") + ) # type: Literal["2021-01-15-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ConnectionStrings] request = build_list_connection_strings_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_configuration.py index 2edeed7e1a4a..3614699fc08f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-05-01-preview") # type: Literal["2021-05-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_metadata.json index fc7aa567b217..51725a878d15 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_metadata.json @@ -99,4 +99,4 @@ "operation_groups": { "software_inventories": "SoftwareInventoriesOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_configuration.py index 76ea2b1461ed..938dfefc1977 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-05-01-preview") # type: Literal["2021-05-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_software_inventories_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_software_inventories_operations.py index fbbd49ce806a..efd086d3f9d3 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_software_inventories_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/aio/operations/_software_inventories_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -34,6 +35,10 @@ build_list_by_subscription_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,7 +86,9 @@ def list_by_extended_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) # type: Literal["2021-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SoftwaresList] error_map = { @@ -111,10 +118,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -158,7 +172,9 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Software _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) # type: Literal["2021-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SoftwaresList] error_map = { @@ -184,10 +200,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -257,7 +280,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) # type: Literal["2021-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Software] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_software_inventories_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_software_inventories_operations.py index 0294edbdf2a0..1cb5f3c1fad4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_software_inventories_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_05_01_preview/operations/_software_inventories_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +52,9 @@ def build_list_by_extended_resource_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) # type: Literal["2021-05-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -82,7 +89,9 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) # type: Literal["2021-05-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -118,7 +127,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) # type: Literal["2021-05-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -192,7 +203,9 @@ def list_by_extended_resource( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) # type: Literal["2021-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SoftwaresList] error_map = { @@ -222,10 +235,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -268,7 +288,9 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.Software"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) # type: Literal["2021-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SoftwaresList] error_map = { @@ -294,10 +316,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -367,7 +396,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-05-01-preview") + ) # type: Literal["2021-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Software] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_configuration.py index 2c64b122657d..a751a5a17000 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-06-01") # type: str + api_version = kwargs.pop("api_version", "2021-06-01") # type: Literal["2021-06-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_metadata.json index 81f23729b9f8..79bc9c66c629 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_metadata.json @@ -101,4 +101,4 @@ "assessments_metadata": "AssessmentsMetadataOperations", "assessments": "AssessmentsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_configuration.py index ee2313700217..dd03c6205884 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-06-01") # type: str + api_version = kwargs.pop("api_version", "2021-06-01") # type: Literal["2021-06-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_metadata_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_metadata_operations.py index ff042194632d..dcb5a52502f5 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_metadata_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_metadata_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_list_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +79,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityAssessmentMetada _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataResponseList] error_map = { @@ -99,10 +104,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -156,7 +168,7 @@ async def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.Sec _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] request = build_get_request( @@ -202,7 +214,7 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.Security _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataResponseList] error_map = { @@ -228,10 +240,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -287,7 +306,7 @@ async def get_in_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] request = build_get_in_subscription_request( @@ -406,7 +425,7 @@ async def create_in_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] @@ -477,7 +496,7 @@ async def delete_in_subscription( # pylint: disable=inconsistent-return-stateme _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_in_subscription_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_operations.py index 5a0c45d7392c..c212a1adcd27 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_assessments_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -35,6 +36,10 @@ build_list_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -76,7 +81,7 @@ def list(self, scope: str, **kwargs: Any) -> AsyncIterable["_models.SecurityAsse _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentList] error_map = { @@ -102,10 +107,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -141,7 +153,7 @@ async def get( self, resource_id: str, assessment_name: str, - expand: Optional[Union[str, "_models.ExpandEnum"]] = None, + expand: Optional[Union[str, _models.ExpandEnum]] = None, **kwargs: Any ) -> _models.SecurityAssessmentResponse: """Get a security assessment on your scanned resource. @@ -169,7 +181,7 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentResponse] request = build_get_request( @@ -292,7 +304,7 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentResponse] @@ -368,7 +380,7 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_settings_operations.py index 1d64162e8cd8..a26ac7f2970e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/aio/operations/_settings_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._settings_operations import build_get_request, build_list_request, build_update_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +71,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SettingsList] error_map = { @@ -92,10 +97,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -127,7 +139,7 @@ async def get_next(next_link=None): list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore @distributed_trace_async - async def get(self, setting_name: Union[str, "_models.Enum1"], **kwargs: Any) -> _models.Setting: + async def get(self, setting_name: Union[str, _models.Enum1], **kwargs: Any) -> _models.Setting: """Settings of different configurations in Microsoft Defender for Cloud. :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", and @@ -149,7 +161,7 @@ async def get(self, setting_name: Union[str, "_models.Enum1"], **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] request = build_get_request( @@ -185,7 +197,7 @@ async def get(self, setting_name: Union[str, "_models.Enum1"], **kwargs: Any) -> @overload async def update( self, - setting_name: Union[str, "_models.Enum1"], + setting_name: Union[str, _models.Enum1], setting: _models.Setting, *, content_type: str = "application/json", @@ -210,7 +222,7 @@ async def update( @overload async def update( self, - setting_name: Union[str, "_models.Enum1"], + setting_name: Union[str, _models.Enum1], setting: IO, *, content_type: str = "application/json", @@ -234,7 +246,7 @@ async def update( @distributed_trace_async async def update( - self, setting_name: Union[str, "_models.Enum1"], setting: Union[_models.Setting, IO], **kwargs: Any + self, setting_name: Union[str, _models.Enum1], setting: Union[_models.Setting, IO], **kwargs: Any ) -> _models.Setting: """updating settings about different configurations in Microsoft Defender for Cloud. @@ -262,7 +274,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_metadata_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_metadata_operations.py index f9a775ac640c..adb88f6af608 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_metadata_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_metadata_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -59,7 +64,7 @@ def build_get_request(assessment_metadata_name: str, **kwargs: Any) -> HttpReque _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -83,7 +88,7 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -111,7 +116,7 @@ def build_get_in_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -143,7 +148,7 @@ def build_create_in_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -178,7 +183,7 @@ def build_delete_in_subscription_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -237,7 +242,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityAssessmentMetadataRes _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataResponseList] error_map = { @@ -262,10 +267,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -319,7 +331,7 @@ def get(self, assessment_metadata_name: str, **kwargs: Any) -> _models.SecurityA _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] request = build_get_request( @@ -365,7 +377,7 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.SecurityAsses _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataResponseList] error_map = { @@ -391,10 +403,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -450,7 +469,7 @@ def get_in_subscription( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] request = build_get_in_subscription_request( @@ -569,7 +588,7 @@ def create_in_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentMetadataResponse] @@ -640,7 +659,7 @@ def delete_in_subscription( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_in_subscription_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_operations.py index 9d5d560597f4..1c27f11a49ec 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_assessments_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,7 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -61,12 +66,12 @@ def build_list_request(scope: str, **kwargs: Any) -> HttpRequest: def build_get_request( - resource_id: str, assessment_name: str, *, expand: Optional[Union[str, "_models.ExpandEnum"]] = None, **kwargs: Any + resource_id: str, assessment_name: str, *, expand: Optional[Union[str, _models.ExpandEnum]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +98,7 @@ def build_create_or_update_request(resource_id: str, assessment_name: str, **kwa _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -121,7 +126,7 @@ def build_delete_request(resource_id: str, assessment_name: str, **kwargs: Any) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -179,7 +184,7 @@ def list(self, scope: str, **kwargs: Any) -> Iterable["_models.SecurityAssessmen _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentList] error_map = { @@ -205,10 +210,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -244,7 +256,7 @@ def get( self, resource_id: str, assessment_name: str, - expand: Optional[Union[str, "_models.ExpandEnum"]] = None, + expand: Optional[Union[str, _models.ExpandEnum]] = None, **kwargs: Any ) -> _models.SecurityAssessmentResponse: """Get a security assessment on your scanned resource. @@ -272,7 +284,7 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentResponse] request = build_get_request( @@ -395,7 +407,7 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityAssessmentResponse] @@ -471,7 +483,7 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_settings_operations.py index 05e09fb0d79b..bb9185702e90 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_06_01/operations/_settings_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -62,11 +67,11 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_get_request(setting_name: Union[str, "_models.Enum1"], subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_get_request(setting_name: Union[str, _models.Enum1], subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -91,11 +96,11 @@ def build_get_request(setting_name: Union[str, "_models.Enum1"], subscription_id return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_update_request(setting_name: Union[str, "_models.Enum1"], subscription_id: str, **kwargs: Any) -> HttpRequest: +def build_update_request(setting_name: Union[str, _models.Enum1], subscription_id: str, **kwargs: Any) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -154,7 +159,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SettingsList] error_map = { @@ -180,10 +185,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -215,7 +227,7 @@ def get_next(next_link=None): list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore @distributed_trace - def get(self, setting_name: Union[str, "_models.Enum1"], **kwargs: Any) -> _models.Setting: + def get(self, setting_name: Union[str, _models.Enum1], **kwargs: Any) -> _models.Setting: """Settings of different configurations in Microsoft Defender for Cloud. :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", and @@ -237,7 +249,7 @@ def get(self, setting_name: Union[str, "_models.Enum1"], **kwargs: Any) -> _mode _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] request = build_get_request( @@ -273,7 +285,7 @@ def get(self, setting_name: Union[str, "_models.Enum1"], **kwargs: Any) -> _mode @overload def update( self, - setting_name: Union[str, "_models.Enum1"], + setting_name: Union[str, _models.Enum1], setting: _models.Setting, *, content_type: str = "application/json", @@ -298,7 +310,7 @@ def update( @overload def update( self, - setting_name: Union[str, "_models.Enum1"], + setting_name: Union[str, _models.Enum1], setting: IO, *, content_type: str = "application/json", @@ -322,7 +334,7 @@ def update( @distributed_trace def update( - self, setting_name: Union[str, "_models.Enum1"], setting: Union[_models.Setting, IO], **kwargs: Any + self, setting_name: Union[str, _models.Enum1], setting: Union[_models.Setting, IO], **kwargs: Any ) -> _models.Setting: """updating settings about different configurations in Microsoft Defender for Cloud. @@ -350,7 +362,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_configuration.py index 155cb1fc508d..9194a3328c1b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-07-01") # type: str + api_version = kwargs.pop("api_version", "2021-07-01") # type: Literal["2021-07-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_metadata.json index 7af577e25640..efc901abd95d 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_metadata.json @@ -99,4 +99,4 @@ "operation_groups": { "settings": "SettingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/__init__.py index 23906b4c7b04..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['SecurityCenter'] + +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_configuration.py index 47769728fec2..f3efe1774dd1 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -34,14 +40,9 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in :paramtype api_version: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-07-01") # type: str + api_version = kwargs.pop("api_version", "2021-07-01") # type: Literal["2021-07-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-security/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_patch.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_security_center.py index 52e32fbdc75d..de5852103e68 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_security_center.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/_security_center.py @@ -21,6 +21,7 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential + class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword """API spec for Microsoft.Security (Azure Security Center) resource provider. @@ -51,16 +52,9 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.settings = SettingsOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.settings = SettingsOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/__init__.py index 01945c743c92..0b0925b026d7 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'SettingsOperations', + "SettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_patch.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_settings_operations.py index 889a00b26719..fa070305ec9f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/aio/operations/_settings_operations.py @@ -6,11 +6,19 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -22,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._settings_operations import build_get_request, build_list_request, build_update_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SettingsOperations: """ .. warning:: @@ -44,12 +58,8 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable["_models.Setting"]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: """Settings about different configurations in Microsoft Defender for Cloud. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,20 +71,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SettingsList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SettingsList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -83,10 +97,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -103,9 +124,7 @@ async def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -115,18 +134,12 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore @distributed_trace_async - async def get( - self, - setting_name: Union[str, "_models.SettingName"], - **kwargs: Any - ) -> _models.Setting: + async def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> _models.Setting: """Settings of different configurations in Microsoft Defender for Cloud. :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", @@ -138,22 +151,24 @@ async def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Setting] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] - request = build_get_request( setting_name=setting_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -161,9 +176,7 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -172,20 +185,19 @@ 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('Setting', pipeline_response) + deserialized = self._deserialize("Setting", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # type: ignore @overload async def update( self, - setting_name: Union[str, "_models.SettingName"], + setting_name: Union[str, _models.SettingName], setting: _models.Setting, *, content_type: str = "application/json", @@ -210,7 +222,7 @@ async def update( @overload async def update( self, - setting_name: Union[str, "_models.SettingName"], + setting_name: Union[str, _models.SettingName], setting: IO, *, content_type: str = "application/json", @@ -232,13 +244,9 @@ async def update( :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace_async async def update( - self, - setting_name: Union[str, "_models.SettingName"], - setting: Union[_models.Setting, IO], - **kwargs: Any + self, setting_name: Union[str, _models.SettingName], setting: Union[_models.Setting, IO], **kwargs: Any ) -> _models.Setting: """updating settings about different configurations in Microsoft Defender for Cloud. @@ -256,16 +264,19 @@ async def update( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Setting] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] content_type = content_type or "application/json" _json = None @@ -273,7 +284,7 @@ async def update( if isinstance(setting, (IO, bytes)): _content = setting else: - _json = self._serialize.body(setting, 'Setting') + _json = self._serialize.body(setting, "Setting") request = build_update_request( setting_name=setting_name, @@ -282,7 +293,7 @@ async def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -290,9 +301,7 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -301,12 +310,11 @@ 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('Setting', pipeline_response) + deserialized = self._deserialize("Setting", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/__init__.py index 8d9111d57a50..63e5f8c91733 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/__init__.py @@ -19,16 +19,17 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AlertSyncSettings', - 'CloudErrorBody', - 'DataExportSettings', - 'ErrorAdditionalInfo', - 'Resource', - 'Setting', - 'SettingsList', - 'SettingKind', - 'SettingName', + "AlertSyncSettings", + "CloudErrorBody", + "DataExportSettings", + "ErrorAdditionalInfo", + "Resource", + "Setting", + "SettingsList", + "SettingKind", + "SettingName", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_models_py3.py index 84c7b1d9b217..614e2db39baa 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_models_py3.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_models_py3.py @@ -26,9 +26,9 @@ class Resource(_serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { @@ -37,12 +37,8 @@ class Resource(_serialization.Model): "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.id = None self.name = None @@ -71,10 +67,10 @@ class Setting(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { @@ -84,16 +80,10 @@ class Setting(Resource): "kind": {"key": "kind", "type": "str"}, } - _subtype_map = { - 'kind': {'AlertSyncSettings': 'AlertSyncSettings', 'DataExportSettings': 'DataExportSettings'} - } + _subtype_map = {"kind": {"AlertSyncSettings": "AlertSyncSettings", "DataExportSettings": "DataExportSettings"}} - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.kind = None # type: Optional[str] @@ -119,10 +109,10 @@ class AlertSyncSettings(Setting): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { @@ -133,18 +123,13 @@ class AlertSyncSettings(Setting): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Is the alert sync setting enabled. :paramtype enabled: bool """ super().__init__(**kwargs) - self.kind = 'AlertSyncSettings' # type: str + self.kind = "AlertSyncSettings" # type: str self.enabled = enabled @@ -166,11 +151,11 @@ class CloudErrorBody(_serialization.Model): """ _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, + "code": {"readonly": True}, + "message": {"readonly": True}, + "target": {"readonly": True}, + "details": {"readonly": True}, + "additional_info": {"readonly": True}, } _attribute_map = { @@ -181,12 +166,8 @@ class CloudErrorBody(_serialization.Model): "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.code = None self.message = None @@ -216,10 +197,10 @@ class DataExportSettings(Setting): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'kind': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "kind": {"required": True}, } _attribute_map = { @@ -230,18 +211,13 @@ class DataExportSettings(Setting): "enabled": {"key": "properties.enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Is the data export setting enabled. :paramtype enabled: bool """ super().__init__(**kwargs) - self.kind = 'DataExportSettings' # type: str + self.kind = "DataExportSettings" # type: str self.enabled = enabled @@ -257,8 +233,8 @@ class ErrorAdditionalInfo(_serialization.Model): """ _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, + "type": {"readonly": True}, + "info": {"readonly": True}, } _attribute_map = { @@ -266,12 +242,8 @@ class ErrorAdditionalInfo(_serialization.Model): "info": {"key": "info", "type": "object"}, } - def __init__( - self, - **kwargs - ): - """ - """ + def __init__(self, **kwargs): + """ """ super().__init__(**kwargs) self.type = None self.info = None @@ -289,7 +261,7 @@ class SettingsList(_serialization.Model): """ _validation = { - 'next_link': {'readonly': True}, + "next_link": {"readonly": True}, } _attribute_map = { @@ -297,12 +269,7 @@ class SettingsList(_serialization.Model): "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - *, - value: Optional[List["_models.Setting"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Setting"]] = None, **kwargs): """ :keyword value: The settings list. :paramtype value: list[~azure.mgmt.security.v2021_07_01.models.Setting] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_patch.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_security_center_enums.py index 72f139849430..a8c079d4a92a 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_security_center_enums.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/models/_security_center_enums.py @@ -11,16 +11,15 @@ class SettingKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """the kind of the settings string. - """ + """the kind of the settings string.""" DATA_EXPORT_SETTINGS = "DataExportSettings" ALERT_SUPPRESSION_SETTING = "AlertSuppressionSetting" ALERT_SYNC_SETTINGS = "AlertSyncSettings" + class SettingName(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """SettingName. - """ + """SettingName.""" MCAS = "MCAS" WDATP = "WDATP" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/__init__.py index 01945c743c92..0b0925b026d7 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/__init__.py @@ -11,8 +11,9 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'SettingsOperations', + "SettingsOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_patch.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_settings_operations.py index e01603d019b7..e5e076466b76 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01/operations/_settings_operations.py @@ -6,10 +6,18 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, ResourceNotModifiedError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -21,117 +29,108 @@ from .. import models as _models from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - setting_name: Union[str, "_models.SettingName"], - subscription_id: str, - **kwargs: Any + setting_name: Union[str, _models.SettingName], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - "settingName": _SERIALIZER.url("setting_name", setting_name, 'str'), + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - setting_name: Union[str, "_models.SettingName"], - subscription_id: str, - **kwargs: Any + setting_name: Union[str, _models.SettingName], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', pattern=r'^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$'), - "settingName": _SERIALIZER.url("setting_name", setting_name, 'str'), + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "settingName": _SERIALIZER.url("setting_name", setting_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + class SettingsOperations: """ @@ -152,12 +151,8 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable["_models.Setting"]: + def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: """Settings about different configurations in Microsoft Defender for Cloud. :keyword callable cls: A custom type or function that will be passed the direct response @@ -168,20 +163,24 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.SettingsList] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SettingsList] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -190,10 +189,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -210,9 +216,7 @@ def get_next(next_link=None): request = prepare_request(next_link) pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -222,18 +226,12 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore @distributed_trace - def get( - self, - setting_name: Union[str, "_models.SettingName"], - **kwargs: Any - ) -> _models.Setting: + def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> _models.Setting: """Settings of different configurations in Microsoft Defender for Cloud. :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", @@ -245,22 +243,24 @@ def get( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Setting] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] - request = build_get_request( setting_name=setting_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -268,9 +268,7 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -279,20 +277,19 @@ 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('Setting', pipeline_response) + deserialized = self._deserialize("Setting", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # type: ignore @overload def update( self, - setting_name: Union[str, "_models.SettingName"], + setting_name: Union[str, _models.SettingName], setting: _models.Setting, *, content_type: str = "application/json", @@ -317,7 +314,7 @@ def update( @overload def update( self, - setting_name: Union[str, "_models.SettingName"], + setting_name: Union[str, _models.SettingName], setting: IO, *, content_type: str = "application/json", @@ -339,13 +336,9 @@ def update( :raises ~azure.core.exceptions.HttpResponseError: """ - @distributed_trace def update( - self, - setting_name: Union[str, "_models.SettingName"], - setting: Union[_models.Setting, IO], - **kwargs: Any + self, setting_name: Union[str, _models.SettingName], setting: Union[_models.Setting, IO], **kwargs: Any ) -> _models.Setting: """updating settings about different configurations in Microsoft Defender for Cloud. @@ -363,16 +356,19 @@ def update( :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Setting] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01")) # type: Literal["2021-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] content_type = content_type or "application/json" _json = None @@ -380,7 +376,7 @@ def update( if isinstance(setting, (IO, bytes)): _content = setting else: - _json = self._serialize.body(setting, 'Setting') + _json = self._serialize.body(setting, "Setting") request = build_update_request( setting_name=setting_name, @@ -389,7 +385,7 @@ def update( content_type=content_type, json=_json, content=_content, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -397,9 +393,7 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -408,12 +402,11 @@ 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('Setting', pipeline_response) + deserialized = self._deserialize("Setting", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings/{settingName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_configuration.py index 714068a4b542..ff11a8f61b7d 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-07-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-07-01-preview") # type: Literal["2021-07-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_metadata.json index 2015959c3b7d..374729f3205b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_metadata.json @@ -101,4 +101,4 @@ "custom_entity_store_assignments": "CustomEntityStoreAssignmentsOperations", "security_connectors": "SecurityConnectorsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_configuration.py index b0462e45160b..5e96849ba4bc 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-07-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-07-01-preview") # type: Literal["2021-07-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_assessment_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_assessment_automations_operations.py index 585dfcbc859d..1a0c4fffaf31 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_assessment_automations_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_assessment_automations_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -36,6 +37,10 @@ build_list_by_subscription_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -89,7 +94,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomAssessmentAutomation] request = build_get_request( @@ -227,7 +234,9 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomAssessmentAutomation] @@ -306,7 +315,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -357,7 +368,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomAssessmentAutomationsListResult] error_map = { @@ -384,10 +397,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -434,7 +454,9 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CustomAs _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomAssessmentAutomationsListResult] error_map = { @@ -460,10 +482,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_entity_store_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_entity_store_assignments_operations.py index a9fe177172c9..389ec974975e 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_entity_store_assignments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_custom_entity_store_assignments_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -36,6 +37,10 @@ build_list_by_subscription_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -90,7 +95,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomEntityStoreAssignment] request = build_get_request( @@ -230,7 +237,9 @@ async def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomEntityStoreAssignment] @@ -312,7 +321,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -363,7 +374,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomEntityStoreAssignmentsListResult] error_map = { @@ -390,10 +403,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -440,7 +460,9 @@ def list_by_subscription(self, **kwargs: Any) -> AsyncIterable["_models.CustomEn _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomEntityStoreAssignmentsListResult] error_map = { @@ -466,10 +488,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_security_connectors_operations.py index c0d9bfb3065a..cbdaa5a77d2b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/aio/operations/_security_connectors_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +79,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] error_map = { @@ -100,10 +107,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -153,7 +167,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] error_map = { @@ -180,10 +196,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -241,7 +264,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] request = build_get_request( @@ -372,7 +397,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] @@ -516,7 +543,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] @@ -589,7 +618,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_assessment_automations_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_assessment_automations_operations.py index 254265a277db..69b42c942dcd 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_assessment_automations_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_assessment_automations_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +86,9 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -119,7 +128,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,7 +165,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +199,9 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -259,7 +274,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomAssessmentAutomation] request = build_get_request( @@ -397,7 +414,9 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomAssessmentAutomation] @@ -476,7 +495,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -527,7 +548,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomAssessmentAutomationsListResult] error_map = { @@ -554,10 +577,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -604,7 +634,9 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.CustomAssessm _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomAssessmentAutomationsListResult] error_map = { @@ -630,10 +662,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_entity_store_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_entity_store_assignments_operations.py index 0e9d94806012..e1ec5f2bdfaf 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_entity_store_assignments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_custom_entity_store_assignments_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -79,7 +86,9 @@ def build_create_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -119,7 +128,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -154,7 +165,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -186,7 +199,9 @@ def build_list_by_subscription_request(subscription_id: str, **kwargs: Any) -> H _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -260,7 +275,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomEntityStoreAssignment] request = build_get_request( @@ -400,7 +417,9 @@ def create( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomEntityStoreAssignment] @@ -482,7 +501,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -533,7 +554,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomEntityStoreAssignmentsListResult] error_map = { @@ -560,10 +583,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -610,7 +640,9 @@ def list_by_subscription(self, **kwargs: Any) -> Iterable["_models.CustomEntityS _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.CustomEntityStoreAssignmentsListResult] error_map = { @@ -636,10 +668,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_security_connectors_operations.py index adf7ec313285..ad867e4287d4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_07_01_preview/operations/_security_connectors_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +73,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -100,7 +109,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,7 +146,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -173,7 +186,9 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -211,7 +226,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -273,7 +290,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] error_map = { @@ -299,10 +318,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -350,7 +376,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] error_map = { @@ -377,10 +405,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -436,7 +471,9 @@ def get(self, resource_group_name: str, security_connector_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] request = build_get_request( @@ -567,7 +604,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] @@ -711,7 +750,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] @@ -784,7 +825,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-07-01-preview") + ) # type: Literal["2021-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_configuration.py index 9ba3aef7e095..9c10b6b87859 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-10-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-10-01-preview") # type: Literal["2021-10-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_metadata.json index bc03b8f1af89..99191c265762 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_metadata.json @@ -99,4 +99,4 @@ "operation_groups": { "mde_onboardings": "MdeOnboardingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_configuration.py index a43daaba3c26..bf874fb09566 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2021-10-01-preview") # type: str + api_version = kwargs.pop("api_version", "2021-10-01-preview") # type: Literal["2021-10-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_mde_onboardings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_mde_onboardings_operations.py index 383ddcf63230..5ade8af29984 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_mde_onboardings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/aio/operations/_mde_onboardings_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._mde_onboardings_operations import build_get_request, build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +75,9 @@ async def list(self, **kwargs: Any) -> _models.MdeOnboardingDataList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-10-01-preview") + ) # type: Literal["2021-10-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.MdeOnboardingDataList] request = build_list_request( @@ -122,7 +129,9 @@ async def get(self, **kwargs: Any) -> _models.MdeOnboardingData: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-10-01-preview") + ) # type: Literal["2021-10-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.MdeOnboardingData] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_mde_onboardings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_mde_onboardings_operations.py index 4ffb49310b2a..537642b6028f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_mde_onboardings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2021_10_01_preview/operations/_mde_onboardings_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-10-01-preview") + ) # type: Literal["2021-10-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +71,9 @@ def build_get_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 = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-10-01-preview") + ) # type: Literal["2021-10-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -127,7 +136,9 @@ def list(self, **kwargs: Any) -> _models.MdeOnboardingDataList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-10-01-preview") + ) # type: Literal["2021-10-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.MdeOnboardingDataList] request = build_list_request( @@ -179,7 +190,9 @@ def get(self, **kwargs: Any) -> _models.MdeOnboardingData: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-10-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2021-10-01-preview") + ) # type: Literal["2021-10-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.MdeOnboardingData] request = build_get_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_configuration.py index 7c99034369bd..f82e49827e0f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-01-01") # type: str + api_version = kwargs.pop("api_version", "2022-01-01") # type: Literal["2022-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_metadata.json index a08d93e4fed4..d019af3e33e5 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_metadata.json @@ -99,4 +99,4 @@ "operation_groups": { "alerts": "AlertsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_configuration.py index 48c513514766..2959d8611ba3 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-01-01") # type: str + api_version = kwargs.pop("api_version", "2022-01-01") # type: Literal["2022-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_alerts_operations.py index c991510c66b6..5322d47bdfc7 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_alerts_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/aio/operations/_alerts_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -48,6 +49,10 @@ build_update_subscription_level_state_to_resolve_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -83,7 +88,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Alert"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -109,10 +114,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -158,7 +170,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Asy _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -185,10 +197,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -235,7 +254,7 @@ def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -262,10 +281,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -317,7 +343,7 @@ def list_resource_group_level_by_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -345,10 +371,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -404,7 +437,7 @@ async def get_subscription_level(self, asc_location: str, alert_name: str, **kwa _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Alert] request = build_get_subscription_level_request( @@ -468,7 +501,7 @@ async def get_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Alert] request = build_get_resource_group_level_request( @@ -530,7 +563,7 @@ async def update_subscription_level_state_to_dismiss( # pylint: disable=inconsi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_dismiss_request( @@ -587,7 +620,7 @@ async def update_subscription_level_state_to_resolve( # pylint: disable=inconsi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_resolve_request( @@ -644,7 +677,7 @@ async def update_subscription_level_state_to_activate( # pylint: disable=incons _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_activate_request( @@ -701,7 +734,7 @@ async def update_subscription_level_state_to_in_progress( # pylint: disable=inc _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_in_progress_request( @@ -761,7 +794,7 @@ async def update_resource_group_level_state_to_resolve( # pylint: disable=incon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_resolve_request( @@ -822,7 +855,7 @@ async def update_resource_group_level_state_to_dismiss( # pylint: disable=incon _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_dismiss_request( @@ -883,7 +916,7 @@ async def update_resource_group_level_state_to_activate( # pylint: disable=inco _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_activate_request( @@ -944,7 +977,7 @@ async def update_resource_group_level_state_to_in_progress( # pylint: disable=i _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_in_progress_request( @@ -992,7 +1025,7 @@ async def _simulate_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] @@ -1132,7 +1165,7 @@ async def begin_simulate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_models_py3.py index c5c96fecb209..d06450ef6ea1 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_models_py3.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/models/_models_py3.py @@ -12,13 +12,14 @@ from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_alerts_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_alerts_operations.py index 31f080e24b54..8b4e64307f33 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_alerts_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01/operations/_alerts_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, cast, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -31,6 +32,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,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 = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -68,7 +73,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 = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -102,7 +107,7 @@ def build_list_subscription_level_by_region_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -133,7 +138,7 @@ def build_list_resource_group_level_by_region_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -168,7 +173,7 @@ def build_get_subscription_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -201,7 +206,7 @@ def build_get_resource_group_level_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -237,7 +242,7 @@ def build_update_subscription_level_state_to_dismiss_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -270,7 +275,7 @@ def build_update_subscription_level_state_to_resolve_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -303,7 +308,7 @@ def build_update_subscription_level_state_to_activate_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -336,7 +341,7 @@ def build_update_subscription_level_state_to_in_progress_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -369,7 +374,7 @@ def build_update_resource_group_level_state_to_resolve_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -405,7 +410,7 @@ def build_update_resource_group_level_state_to_dismiss_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -441,7 +446,7 @@ def build_update_resource_group_level_state_to_activate_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -477,7 +482,7 @@ def build_update_resource_group_level_state_to_in_progress_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -511,7 +516,7 @@ def build_simulate_request(asc_location: str, subscription_id: str, **kwargs: An _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -571,7 +576,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Alert"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -597,10 +602,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -646,7 +658,7 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -673,10 +685,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -723,7 +742,7 @@ def list_subscription_level_by_region(self, asc_location: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -750,10 +769,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -805,7 +831,7 @@ def list_resource_group_level_by_region( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.AlertList] error_map = { @@ -833,10 +859,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -892,7 +925,7 @@ def get_subscription_level(self, asc_location: str, alert_name: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Alert] request = build_get_subscription_level_request( @@ -956,7 +989,7 @@ def get_resource_group_level( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Alert] request = build_get_resource_group_level_request( @@ -1018,7 +1051,7 @@ def update_subscription_level_state_to_dismiss( # pylint: disable=inconsistent- _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_dismiss_request( @@ -1075,7 +1108,7 @@ def update_subscription_level_state_to_resolve( # pylint: disable=inconsistent- _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_resolve_request( @@ -1132,7 +1165,7 @@ def update_subscription_level_state_to_activate( # pylint: disable=inconsistent _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_activate_request( @@ -1189,7 +1222,7 @@ def update_subscription_level_state_to_in_progress( # pylint: disable=inconsist _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_subscription_level_state_to_in_progress_request( @@ -1249,7 +1282,7 @@ def update_resource_group_level_state_to_resolve( # pylint: disable=inconsisten _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_resolve_request( @@ -1310,7 +1343,7 @@ def update_resource_group_level_state_to_dismiss( # pylint: disable=inconsisten _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_dismiss_request( @@ -1371,7 +1404,7 @@ def update_resource_group_level_state_to_activate( # pylint: disable=inconsiste _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_activate_request( @@ -1432,7 +1465,7 @@ def update_resource_group_level_state_to_in_progress( # pylint: disable=inconsi _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_update_resource_group_level_state_to_in_progress_request( @@ -1480,7 +1513,7 @@ def _simulate_initial( # pylint: disable=inconsistent-return-statements _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] @@ -1620,7 +1653,7 @@ def begin_simulate( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01")) # type: Literal["2022-01-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_configuration.py index d935bb0a9c2c..d57df2945327 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-01-01-preview") # type: Literal["2022-01-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_metadata.json index 0131c6bfb537..557420da04a7 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_metadata.json @@ -105,4 +105,4 @@ "security_connector_governance_rules_execute_status": "SecurityConnectorGovernanceRulesExecuteStatusOperations", "governance_assignments": "GovernanceAssignmentsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_configuration.py index b48439528e8a..b57abce4011b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-01-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-01-01-preview") # type: Literal["2022-01-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_assignments_operations.py index 430ad91d4585..7be4f81e6edc 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_assignments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_assignments_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -35,6 +36,10 @@ build_list_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -78,7 +83,9 @@ def list(self, scope: str, assessment_name: str, **kwargs: Any) -> AsyncIterable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceAssignmentsList] error_map = { @@ -105,10 +112,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -170,7 +184,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceAssignment] request = build_get_request( @@ -314,7 +330,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceAssignment] @@ -395,7 +413,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rule_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rule_operations.py index 5d04e4554851..2927ce84c770 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rule_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rule_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._governance_rule_operations import build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,7 +70,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.GovernanceRule"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRuleList] error_map = { @@ -91,10 +98,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rules_operations.py index 3b76adc5dc19..d0f4a162976f 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_governance_rules_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -35,6 +36,10 @@ build_rule_id_execute_single_subscription_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -81,7 +86,9 @@ async def get(self, rule_id: str, **kwargs: Any) -> _models.GovernanceRule: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRule] request = build_get_request( @@ -190,7 +197,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRule] @@ -262,7 +271,9 @@ async def delete(self, rule_id: str, **kwargs: Any) -> None: # pylint: disable= _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -308,7 +319,9 @@ async def _rule_id_execute_single_subscription_initial( # pylint: disable=incon _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] @@ -456,7 +469,9 @@ async def begin_rule_id_execute_single_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] @@ -515,7 +530,9 @@ async def _rule_id_execute_single_security_connector_initial( # pylint: disable _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] @@ -686,7 +703,9 @@ async def begin_rule_id_execute_single_security_connector( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rule_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rule_operations.py index bb12d35eae6f..b7e5ea958c44 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rule_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rule_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._security_connector_governance_rule_operations import build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +77,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRuleList] error_map = { @@ -100,10 +107,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rules_execute_status_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rules_execute_status_operations.py index 51ac3f92d41f..f11ac5a5538a 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rules_execute_status_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rules_execute_status_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar, Union, cast from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._security_connector_governance_rules_execute_status_operations import build_get_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +71,9 @@ async def _get_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ExecuteRuleStatus]] request = build_get_request( @@ -143,7 +150,9 @@ async def begin_get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ExecuteRuleStatus] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rules_operations.py index 42a6c6cf62b0..8446d9e5c7d3 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_security_connector_governance_rules_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -31,6 +32,10 @@ build_get_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -84,7 +89,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRule] request = build_get_request( @@ -224,7 +231,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRule] @@ -305,7 +314,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_subscription_governance_rules_execute_status_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_subscription_governance_rules_execute_status_operations.py index 2457fb599e29..792b2aacd816 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_subscription_governance_rules_execute_status_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/aio/operations/_subscription_governance_rules_execute_status_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar, Union, cast from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._subscription_governance_rules_execute_status_operations import build_get_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -64,7 +69,9 @@ async def _get_initial(self, rule_id: str, operation_id: str, **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ExecuteRuleStatus]] request = build_get_request( @@ -134,7 +141,9 @@ async def begin_get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ExecuteRuleStatus] polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_models_py3.py index e497eb1226e1..576f80d26382 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_models_py3.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/models/_models_py3.py @@ -13,13 +13,14 @@ from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_assignments_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_assignments_operations.py index 53a97bc4e782..b5e0bcae48b5 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_assignments_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_assignments_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_list_request(scope: str, assessment_name: str, **kwargs: Any) -> HttpR _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +74,9 @@ def build_get_request(scope: str, assessment_name: str, assignment_key: str, **k _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -96,7 +105,9 @@ def build_create_or_update_request(scope: str, assessment_name: str, assignment_ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -127,7 +138,9 @@ def build_create_or_update_request(scope: str, assessment_name: str, assignment_ def build_delete_request(scope: str, assessment_name: str, assignment_key: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] # Construct URL _url = kwargs.pop( "template_url", @@ -186,7 +199,9 @@ def list(self, scope: str, assessment_name: str, **kwargs: Any) -> Iterable["_mo _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceAssignmentsList] error_map = { @@ -213,10 +228,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -276,7 +298,9 @@ def get(self, scope: str, assessment_name: str, assignment_key: str, **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceAssignment] request = build_get_request( @@ -420,7 +444,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceAssignment] @@ -501,7 +527,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rule_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rule_operations.py index a40b91e86c79..79400be6e24d 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rule_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rule_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +101,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.GovernanceRule"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRuleList] error_map = { @@ -120,10 +129,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rules_operations.py index 7589397cd906..3871d0f36948 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_governance_rules_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, cast, overload from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_get_request(rule_id: str, subscription_id: str, **kwargs: Any) -> Http _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -69,7 +76,9 @@ def build_create_or_update_request(rule_id: str, subscription_id: str, **kwargs: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -100,7 +109,9 @@ def build_create_or_update_request(rule_id: str, subscription_id: str, **kwargs: def build_delete_request(rule_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/governanceRules/{ruleId}" @@ -124,7 +135,9 @@ def build_rule_id_execute_single_subscription_request(rule_id: str, subscription _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -158,7 +171,9 @@ def build_rule_id_execute_single_security_connector_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -233,7 +248,9 @@ def get(self, rule_id: str, **kwargs: Any) -> _models.GovernanceRule: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRule] request = build_get_request( @@ -342,7 +359,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRule] @@ -414,7 +433,9 @@ def delete(self, rule_id: str, **kwargs: Any) -> None: # pylint: disable=incons _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( @@ -460,7 +481,9 @@ def _rule_id_execute_single_subscription_initial( # pylint: disable=inconsisten _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] @@ -608,7 +631,9 @@ def begin_rule_id_execute_single_subscription( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] @@ -667,7 +692,9 @@ def _rule_id_execute_single_security_connector_initial( # pylint: disable=incon _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] @@ -838,7 +865,9 @@ def begin_rule_id_execute_single_security_connector( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[None] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rule_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rule_operations.py index 23ea81aac1d8..3c1dbacd1a65 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rule_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rule_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,9 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,7 +117,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRuleList] error_map = { @@ -138,10 +147,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rules_execute_status_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rules_execute_status_operations.py index 0fb8ca6213b2..506e10ad39a4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rules_execute_status_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rules_execute_status_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar, Union, cast from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -47,7 +52,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -111,7 +118,9 @@ def _get_initial( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ExecuteRuleStatus]] request = build_get_request( @@ -188,7 +197,9 @@ def begin_get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ExecuteRuleStatus] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rules_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rules_operations.py index be077427e69a..2df8e4d1fa94 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rules_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_security_connector_governance_rules_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +83,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -114,7 +123,9 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] # Construct URL _url = kwargs.pop( "template_url", @@ -188,7 +199,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRule] request = build_get_request( @@ -328,7 +341,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.GovernanceRule] @@ -409,7 +424,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_subscription_governance_rules_execute_status_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_subscription_governance_rules_execute_status_operations.py index 8b3fbc640455..cc18a6fa6af6 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_subscription_governance_rules_execute_status_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_01_01_preview/operations/_subscription_governance_rules_execute_status_operations.py @@ -6,6 +6,7 @@ # 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, Optional, TypeVar, Union, cast from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_get_request(rule_id: str, operation_id: str, subscription_id: str, **k _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -98,7 +105,9 @@ def _get_initial(self, rule_id: str, operation_id: str, **kwargs: Any) -> Option _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ExecuteRuleStatus]] request = build_get_request( @@ -166,7 +175,9 @@ def begin_get(self, rule_id: str, operation_id: str, **kwargs: Any) -> LROPoller _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-01-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-01-01-preview") + ) # type: Literal["2022-01-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ExecuteRuleStatus] polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_configuration.py index 895772758283..1f9210f091e9 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-03-01") # type: str + api_version = kwargs.pop("api_version", "2022-03-01") # type: Literal["2022-03-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_metadata.json index d2a08a219eb1..89b310cffc2b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_metadata.json @@ -99,4 +99,4 @@ "operation_groups": { "pricings": "PricingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_configuration.py index 0891dd9909ef..f46270fe370c 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-03-01") # type: str + api_version = kwargs.pop("api_version", "2022-03-01") # type: Literal["2022-03-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_pricings_operations.py index 9c67eb02dd39..f7139469b6e8 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_pricings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/aio/operations/_pricings_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._vendor import _convert_request from ...operations._pricings_operations import build_get_request, build_list_request, build_update_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -70,7 +75,7 @@ async def list(self, **kwargs: Any) -> _models.PricingList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: Literal["2022-03-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.PricingList] request = build_list_request( @@ -124,7 +129,7 @@ async def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: Literal["2022-03-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pricing] request = build_get_request( @@ -222,7 +227,7 @@ async def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO], * _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: Literal["2022-03-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pricing] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_pricings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_pricings_operations.py index e3f2efbd83ce..ae0053fbc7f8 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_pricings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_03_01/operations/_pricings_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,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 = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: Literal["2022-03-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -64,7 +69,7 @@ def build_get_request(pricing_name: str, subscription_id: str, **kwargs: Any) -> _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: Literal["2022-03-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -93,7 +98,7 @@ def build_update_request(pricing_name: str, subscription_id: str, **kwargs: Any) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: Literal["2022-03-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -160,7 +165,7 @@ def list(self, **kwargs: Any) -> _models.PricingList: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: Literal["2022-03-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.PricingList] request = build_list_request( @@ -214,7 +219,7 @@ def get(self, pricing_name: str, **kwargs: Any) -> _models.Pricing: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: Literal["2022-03-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pricing] request = build_get_request( @@ -312,7 +317,7 @@ def update(self, pricing_name: str, pricing: Union[_models.Pricing, IO], **kwarg _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-03-01")) # type: Literal["2022-03-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Pricing] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_configuration.py index 1c87690036fc..cc031b97ea90 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-05-01") # type: str + api_version = kwargs.pop("api_version", "2022-05-01") # type: Literal["2022-05-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_metadata.json index d0385d6b4c72..47a3ee3d7feb 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_metadata.json @@ -99,4 +99,4 @@ "operation_groups": { "settings": "SettingsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_configuration.py index a88122f482d3..74da18d1fbd7 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-05-01") # type: str + api_version = kwargs.pop("api_version", "2022-05-01") # type: Literal["2022-05-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_settings_operations.py index c5f5021f56ec..fc65f030d9dd 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/aio/operations/_settings_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -30,6 +31,10 @@ from ..._vendor import _convert_request from ...operations._settings_operations import build_get_request, build_list_request, build_update_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -66,7 +71,7 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Setting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SettingsList] error_map = { @@ -92,10 +97,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -127,7 +139,7 @@ async def get_next(next_link=None): list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore @distributed_trace_async - async def get(self, setting_name: Union[str, "_models.SettingName"], **kwargs: Any) -> _models.Setting: + async def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> _models.Setting: """Settings of different configurations in Microsoft Defender for Cloud. :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", @@ -149,7 +161,7 @@ async def get(self, setting_name: Union[str, "_models.SettingName"], **kwargs: A _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] request = build_get_request( @@ -185,7 +197,7 @@ async def get(self, setting_name: Union[str, "_models.SettingName"], **kwargs: A @overload async def update( self, - setting_name: Union[str, "_models.SettingName"], + setting_name: Union[str, _models.SettingName], setting: _models.Setting, *, content_type: str = "application/json", @@ -210,7 +222,7 @@ async def update( @overload async def update( self, - setting_name: Union[str, "_models.SettingName"], + setting_name: Union[str, _models.SettingName], setting: IO, *, content_type: str = "application/json", @@ -234,7 +246,7 @@ async def update( @distributed_trace_async async def update( - self, setting_name: Union[str, "_models.SettingName"], setting: Union[_models.Setting, IO], **kwargs: Any + self, setting_name: Union[str, _models.SettingName], setting: Union[_models.Setting, IO], **kwargs: Any ) -> _models.Setting: """updating settings about different configurations in Microsoft Defender for Cloud. @@ -262,7 +274,7 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_settings_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_settings_operations.py index 192309fc7ed9..9bfd1bb6817b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_settings_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01/operations/_settings_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,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 = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -63,12 +68,12 @@ def build_list_request(subscription_id: str, **kwargs: Any) -> HttpRequest: def build_get_request( - setting_name: Union[str, "_models.SettingName"], subscription_id: str, **kwargs: Any + setting_name: Union[str, _models.SettingName], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,12 +99,12 @@ def build_get_request( def build_update_request( - setting_name: Union[str, "_models.SettingName"], subscription_id: str, **kwargs: Any + setting_name: Union[str, _models.SettingName], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -158,7 +163,7 @@ def list(self, **kwargs: Any) -> Iterable["_models.Setting"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SettingsList] error_map = { @@ -184,10 +189,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -219,7 +231,7 @@ def get_next(next_link=None): list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/settings"} # type: ignore @distributed_trace - def get(self, setting_name: Union[str, "_models.SettingName"], **kwargs: Any) -> _models.Setting: + def get(self, setting_name: Union[str, _models.SettingName], **kwargs: Any) -> _models.Setting: """Settings of different configurations in Microsoft Defender for Cloud. :param setting_name: The name of the setting. Known values are: "MCAS", "WDATP", @@ -241,7 +253,7 @@ def get(self, setting_name: Union[str, "_models.SettingName"], **kwargs: Any) -> _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] request = build_get_request( @@ -277,7 +289,7 @@ def get(self, setting_name: Union[str, "_models.SettingName"], **kwargs: Any) -> @overload def update( self, - setting_name: Union[str, "_models.SettingName"], + setting_name: Union[str, _models.SettingName], setting: _models.Setting, *, content_type: str = "application/json", @@ -302,7 +314,7 @@ def update( @overload def update( self, - setting_name: Union[str, "_models.SettingName"], + setting_name: Union[str, _models.SettingName], setting: IO, *, content_type: str = "application/json", @@ -326,7 +338,7 @@ def update( @distributed_trace def update( - self, setting_name: Union[str, "_models.SettingName"], setting: Union[_models.Setting, IO], **kwargs: Any + self, setting_name: Union[str, _models.SettingName], setting: Union[_models.Setting, IO], **kwargs: Any ) -> _models.Setting: """updating settings about different configurations in Microsoft Defender for Cloud. @@ -354,7 +366,7 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Setting] diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_configuration.py index 88208ce0c457..28502606ce6d 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-05-01-preview") # type: Literal["2022-05-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_metadata.json index dbe4b0f53a57..8f808801f946 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_metadata.json @@ -99,4 +99,4 @@ "operation_groups": { "security_connectors": "SecurityConnectorsOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_configuration.py index 645ad34a5a74..2c12da03e992 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-05-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-05-01-preview") # type: Literal["2022-05-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_security_connectors_operations.py index ba821a2b9604..3f7a149b2b74 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/aio/operations/_security_connectors_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, IO, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -37,6 +38,10 @@ build_update_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -74,7 +79,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] error_map = { @@ -100,10 +107,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -153,7 +167,9 @@ def list_by_resource_group( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] error_map = { @@ -180,10 +196,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -241,7 +264,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] request = build_get_request( @@ -372,7 +397,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] @@ -516,7 +543,9 @@ async def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] @@ -589,7 +618,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_models_py3.py index 367dcbb28009..7328d7eb9110 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_models_py3.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/models/_models_py3.py @@ -13,13 +13,14 @@ from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_security_connectors_operations.py index 5805cac04db7..dfc75e6d5f8c 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_security_connectors_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_05_01_preview/operations/_security_connectors_operations.py @@ -6,8 +6,9 @@ # 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, IO, Iterable, Optional, TypeVar, Union, overload -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -66,7 +73,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -100,7 +109,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -135,7 +146,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -173,7 +186,9 @@ def build_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -211,7 +226,9 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -273,7 +290,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] error_map = { @@ -299,10 +318,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -350,7 +376,9 @@ def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Ite _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] error_map = { @@ -377,10 +405,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" @@ -436,7 +471,9 @@ def get(self, resource_group_name: str, security_connector_name: str, **kwargs: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] request = build_get_request( @@ -567,7 +604,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] @@ -711,7 +750,9 @@ def update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] @@ -784,7 +825,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-05-01-preview") + ) # type: Literal["2022-05-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/__init__.py index a5eaeae6d251..b4893ccdf609 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/__init__.py @@ -18,7 +18,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_configuration.py index 4f850ae9dd02..19075a8c40b3 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-07-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-07-01-preview") # type: Literal["2022-07-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_metadata.json index efa3dfcf5512..934d3a1b93c2 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_metadata.json +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_metadata.json @@ -102,4 +102,4 @@ "security_connector_applications": "SecurityConnectorApplicationsOperations", "security_connector_application": "SecurityConnectorApplicationOperations" } -} \ No newline at end of file +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_version.py index 48944bf3938a..cac9f5d10f8b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_version.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.0.0" +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/__init__.py index 17bf2c4a484a..5b78291ec454 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/__init__.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/__init__.py @@ -15,7 +15,9 @@ _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ["SecurityCenter"] +__all__ = [ + "SecurityCenter", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_configuration.py index 0deed982445d..5caa1ff7da9b 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_configuration.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -36,7 +42,7 @@ class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-in def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(SecurityCenterConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop("api_version", "2022-07-01-preview") # type: str + api_version = kwargs.pop("api_version", "2022-07-01-preview") # type: Literal["2022-07-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_application_operations.py index 5316d5c5926f..85dc02912d07 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_application_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_application_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -31,6 +32,10 @@ build_get_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -77,7 +82,9 @@ async def get(self, application_id: str, **kwargs: Any) -> _models.Application: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] request = build_get_request( @@ -186,7 +193,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] @@ -260,7 +269,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_applications_operations.py index 419036d7e72d..007fca2dda37 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_applications_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_applications_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._applications_operations import build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -65,7 +70,9 @@ def list(self, **kwargs: Any) -> AsyncIterable["_models.Application"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationsList] error_map = { @@ -91,10 +98,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_application_operations.py index 91d9ad9b9b71..9d8b5af8b8ef 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_application_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_application_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -31,6 +32,10 @@ build_get_request, ) +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -84,7 +89,9 @@ async def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] request = build_get_request( @@ -224,7 +231,9 @@ async def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] @@ -305,7 +314,9 @@ async def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_applications_operations.py index 2e53ecc05656..92eaa30a2497 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_applications_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/aio/operations/_security_connector_applications_operations.py @@ -6,8 +6,9 @@ # 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, Callable, Dict, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ( @@ -29,6 +30,10 @@ from ..._vendor import _convert_request from ...operations._security_connector_applications_operations import build_list_request +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -72,7 +77,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationsList] error_map = { @@ -100,10 +107,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_models_py3.py index 2c6fc4f63791..335ade6e169d 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_models_py3.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_models_py3.py @@ -12,13 +12,14 @@ from ... import _serialization -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from .. import models as _models if sys.version_info >= (3, 9): from collections.abc import MutableMapping else: from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object @@ -130,7 +131,7 @@ class ApplicationCondition(_serialization.Model): :ivar value: The application Condition's Value like IDs that contain some string, see examples. :vartype value: str :ivar operator: The application Condition's Operator, for example Contains for id or In for - list of possible IDs, see examples. Known values are: "Contains" and "In". + list of possible IDs, see examples. Known values are: "Contains", "Equals", and "In". :vartype operator: str or ~azure.mgmt.security.v2022_07_01_preview.models.ApplicationConditionOperator """ @@ -156,7 +157,7 @@ def __init__( examples. :paramtype value: str :keyword operator: The application Condition's Operator, for example Contains for id or In for - list of possible IDs, see examples. Known values are: "Contains" and "In". + list of possible IDs, see examples. Known values are: "Contains", "Equals", and "In". :paramtype operator: str or ~azure.mgmt.security.v2022_07_01_preview.models.ApplicationConditionOperator """ diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_security_center_enums.py index 12aac085f4d9..5b64e0a4d2a4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_security_center_enums.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/models/_security_center_enums.py @@ -17,6 +17,8 @@ class ApplicationConditionOperator(str, Enum, metaclass=CaseInsensitiveEnumMeta) #: Checks that the string value of the data defined in Property contains the given value CONTAINS = "Contains" + #: Checks that the string value of the data defined in Property equals the given value + EQUALS = "Equals" #: Checks that the string value of the data defined in Property equals any of the given values #: (exact fit) IN = "In" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_application_operations.py index 770083ef312d..e84db16005c4 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_application_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_application_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -38,7 +43,9 @@ def build_get_request(application_id: str, subscription_id: str, **kwargs: Any) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -67,7 +74,9 @@ def build_create_or_update_request(application_id: str, subscription_id: str, ** _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -98,7 +107,9 @@ def build_create_or_update_request(application_id: str, subscription_id: str, ** def build_delete_request(application_id: str, subscription_id: str, **kwargs: Any) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] # Construct URL _url = kwargs.pop( "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/applications/{applicationId}" @@ -160,7 +171,9 @@ def get(self, application_id: str, **kwargs: Any) -> _models.Application: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] request = build_get_request( @@ -269,7 +282,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] @@ -341,7 +356,9 @@ def delete(self, application_id: str, **kwargs: Any) -> None: # pylint: disable _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_applications_operations.py index 7b0535d80620..f8006290b71d 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_applications_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_applications_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -94,7 +101,9 @@ def list(self, **kwargs: Any) -> Iterable["_models.Application"]: _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationsList] error_map = { @@ -120,10 +129,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_application_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_application_operations.py index 08e026b1527c..291bb2803f03 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_application_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_application_operations.py @@ -6,6 +6,7 @@ # 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, IO, Optional, TypeVar, Union, overload from azure.core.exceptions import ( @@ -27,6 +28,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -40,7 +45,9 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -76,7 +83,9 @@ def build_create_or_update_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] accept = _headers.pop("Accept", "application/json") @@ -114,7 +123,9 @@ def build_delete_request( ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] # Construct URL _url = kwargs.pop( "template_url", @@ -188,7 +199,9 @@ def get( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] request = build_get_request( @@ -328,7 +341,9 @@ def create_or_update( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] cls = kwargs.pop("cls", None) # type: ClsType[_models.Application] @@ -409,7 +424,9 @@ def delete( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[None] request = build_delete_request( diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_applications_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_applications_operations.py index ef50603d49e9..858b1ef83b94 100644 --- a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_applications_operations.py +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_07_01_preview/operations/_security_connector_applications_operations.py @@ -6,8 +6,9 @@ # 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, Optional, TypeVar -from urllib.parse import parse_qs, urljoin, urlparse +import urllib.parse from azure.core.exceptions import ( ClientAuthenticationError, @@ -29,6 +30,10 @@ from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section +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 T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] @@ -42,7 +47,9 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] accept = _headers.pop("Accept", "application/json") # Construct URL @@ -110,7 +117,9 @@ def list( _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-07-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-07-01-preview") + ) # type: Literal["2022-07-01-preview"] cls = kwargs.pop("cls", None) # type: ClsType[_models.ApplicationsList] error_map = { @@ -138,10 +147,17 @@ def prepare_request(next_link=None): else: # make call to next link with the client's api-version - _parsed_next_link = urlparse(next_link) - _next_request_params = case_insensitive_dict(parse_qs(_parsed_next_link.query)) + _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", urljoin(next_link, _parsed_next_link.path), params=_next_request_params) + 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) # type: ignore request.method = "GET" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/__init__.py new file mode 100644 index 000000000000..b4893ccdf609 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/__init__.py @@ -0,0 +1,26 @@ +# 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 ._security_center import SecurityCenter +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_configuration.py new file mode 100644 index 000000000000..f5c6e9e2a86e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_configuration.py @@ -0,0 +1,75 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +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 + from azure.core.credentials import TokenCredential + + +class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SecurityCenter. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Azure subscription ID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". 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(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-08-01-preview") # type: Literal["2022-08-01-preview"] + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_metadata.json b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_metadata.json new file mode 100644 index 000000000000..e9aceb5f52df --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_metadata.json @@ -0,0 +1,102 @@ +{ + "chosen_version": "2022-08-01-preview", + "total_api_version_list": ["2022-08-01-preview"], + "client": { + "name": "SecurityCenter", + "filename": "_security_center", + "description": "API spec for Microsoft.Security (Azure Security Center) resource provider.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": false, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"SecurityCenterConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "Azure subscription ID. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "security_connectors": "SecurityConnectorsOperations" + } +} diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_security_center.py new file mode 100644 index 000000000000..db8abdba93dc --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from .._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import SecurityConnectorsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar security_connectors: SecurityConnectorsOperations operations + :vartype security_connectors: + azure.mgmt.security.v2022_08_01_preview.operations.SecurityConnectorsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: Azure subscription ID. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.security_connectors = SecurityConnectorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> SecurityCenter + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_vendor.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_version.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_version.py new file mode 100644 index 000000000000..cac9f5d10f8b --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "3.0.0" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/__init__.py new file mode 100644 index 000000000000..5b78291ec454 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._security_center import SecurityCenter + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityCenter", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_configuration.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_configuration.py new file mode 100644 index 000000000000..c5692cc3dbe4 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_configuration.py @@ -0,0 +1,72 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +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 + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenterConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for SecurityCenter. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Azure subscription ID. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". 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(SecurityCenterConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-08-01-preview") # type: Literal["2022-08-01-preview"] + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-security/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_security_center.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_security_center.py new file mode 100644 index 000000000000..ce5d099e1e9a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/_security_center.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. +# -------------------------------------------------------------------------- + +from copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ..._serialization import Deserializer, Serializer +from ._configuration import SecurityCenterConfiguration +from .operations import SecurityConnectorsOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class SecurityCenter: # pylint: disable=client-accepts-api-version-keyword + """API spec for Microsoft.Security (Azure Security Center) resource provider. + + :ivar security_connectors: SecurityConnectorsOperations operations + :vartype security_connectors: + azure.mgmt.security.v2022_08_01_preview.aio.operations.SecurityConnectorsOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: Azure subscription ID. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-08-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = SecurityCenterConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.security_connectors = SecurityConnectorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "SecurityCenter": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/__init__.py new file mode 100644 index 000000000000..4660a96abf0f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._security_connectors_operations import SecurityConnectorsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityConnectorsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_security_connectors_operations.py new file mode 100644 index 000000000000..342f7cc07e99 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/aio/operations/_security_connectors_operations.py @@ -0,0 +1,651 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._security_connectors_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_by_resource_group_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SecurityConnectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2022_08_01_preview.aio.SecurityCenter`'s + :attr:`security_connectors` 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(self, **kwargs: Any) -> AsyncIterable["_models.SecurityConnector"]: + """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in + the response to get the next page of security connectors for the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SecurityConnector or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.SecurityConnector"]: + """Lists all the security connectors in the specified resource group. Use the 'nextLink' property + in the response to get the next page of security connectors for the specified resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. 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 SecurityConnector or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> _models.SecurityConnector: + """Retrieves details of a specific security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: IO + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO], + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a model type or a IO + type. Required. + :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector 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 + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IO, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: IO + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO], + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a model type or a IO + type. Required. + :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector 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 + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IO, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> None: + """Deletes a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_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 = { + 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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/__init__.py new file mode 100644 index 000000000000..3ae38c38dc10 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/__init__.py @@ -0,0 +1,173 @@ +# 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 ._models_py3 import AwsEnvironmentData +from ._models_py3 import AwsOrganizationalData +from ._models_py3 import AwsOrganizationalDataMaster +from ._models_py3 import AwsOrganizationalDataMember +from ._models_py3 import AzureDevOpsScopeEnvironmentData +from ._models_py3 import AzureTrackedResourceLocation +from ._models_py3 import CloudErrorBody +from ._models_py3 import CloudOffering +from ._models_py3 import CspmMonitorAwsOffering +from ._models_py3 import CspmMonitorAwsOfferingNativeCloudConnection +from ._models_py3 import CspmMonitorAzureDevOpsOffering +from ._models_py3 import CspmMonitorGcpOffering +from ._models_py3 import CspmMonitorGcpOfferingNativeCloudConnection +from ._models_py3 import CspmMonitorGithubOffering +from ._models_py3 import DefenderCspmAwsOffering +from ._models_py3 import DefenderCspmAwsOfferingVmScanners +from ._models_py3 import DefenderCspmAwsOfferingVmScannersConfiguration +from ._models_py3 import DefenderCspmGcpOffering +from ._models_py3 import DefenderFoDatabasesAwsOffering +from ._models_py3 import DefenderFoDatabasesAwsOfferingArcAutoProvisioning +from ._models_py3 import DefenderFoDatabasesAwsOfferingRds +from ._models_py3 import DefenderForContainersAwsOffering +from ._models_py3 import DefenderForContainersAwsOfferingCloudWatchToKinesis +from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessment +from ._models_py3 import DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask +from ._models_py3 import DefenderForContainersAwsOfferingKinesisToS3 +from ._models_py3 import DefenderForContainersAwsOfferingKubernetesScubaReader +from ._models_py3 import DefenderForContainersAwsOfferingKubernetesService +from ._models_py3 import DefenderForContainersGcpOffering +from ._models_py3 import DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection +from ._models_py3 import DefenderForContainersGcpOfferingNativeCloudConnection +from ._models_py3 import DefenderForDatabasesGcpOffering +from ._models_py3 import DefenderForDatabasesGcpOfferingArcAutoProvisioning +from ._models_py3 import DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning +from ._models_py3 import DefenderForDevOpsAzureDevOpsOffering +from ._models_py3 import DefenderForDevOpsGithubOffering +from ._models_py3 import DefenderForServersAwsOffering +from ._models_py3 import DefenderForServersAwsOfferingArcAutoProvisioning +from ._models_py3 import DefenderForServersAwsOfferingDefenderForServers +from ._models_py3 import DefenderForServersAwsOfferingMdeAutoProvisioning +from ._models_py3 import DefenderForServersAwsOfferingSubPlan +from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioning +from ._models_py3 import DefenderForServersAwsOfferingVaAutoProvisioningConfiguration +from ._models_py3 import DefenderForServersAwsOfferingVmScanners +from ._models_py3 import DefenderForServersAwsOfferingVmScannersConfiguration +from ._models_py3 import DefenderForServersGcpOffering +from ._models_py3 import DefenderForServersGcpOfferingArcAutoProvisioning +from ._models_py3 import DefenderForServersGcpOfferingDefenderForServers +from ._models_py3 import DefenderForServersGcpOfferingMdeAutoProvisioning +from ._models_py3 import DefenderForServersGcpOfferingSubPlan +from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioning +from ._models_py3 import DefenderForServersGcpOfferingVaAutoProvisioningConfiguration +from ._models_py3 import ETag +from ._models_py3 import EnvironmentData +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import GcpOrganizationalData +from ._models_py3 import GcpOrganizationalDataMember +from ._models_py3 import GcpOrganizationalDataOrganization +from ._models_py3 import GcpProjectDetails +from ._models_py3 import GcpProjectEnvironmentData +from ._models_py3 import GithubScopeEnvironmentData +from ._models_py3 import InformationProtectionAwsOffering +from ._models_py3 import InformationProtectionAwsOfferingInformationProtection +from ._models_py3 import Kind +from ._models_py3 import Resource +from ._models_py3 import SecurityConnector +from ._models_py3 import SecurityConnectorsList +from ._models_py3 import SystemData +from ._models_py3 import Tags +from ._models_py3 import TrackedResource + +from ._security_center_enums import CloudName +from ._security_center_enums import CreatedByType +from ._security_center_enums import EnvironmentType +from ._security_center_enums import OfferingType +from ._security_center_enums import OrganizationMembershipType +from ._security_center_enums import ScanningMode +from ._security_center_enums import SubPlan +from ._security_center_enums import Type +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AwsEnvironmentData", + "AwsOrganizationalData", + "AwsOrganizationalDataMaster", + "AwsOrganizationalDataMember", + "AzureDevOpsScopeEnvironmentData", + "AzureTrackedResourceLocation", + "CloudErrorBody", + "CloudOffering", + "CspmMonitorAwsOffering", + "CspmMonitorAwsOfferingNativeCloudConnection", + "CspmMonitorAzureDevOpsOffering", + "CspmMonitorGcpOffering", + "CspmMonitorGcpOfferingNativeCloudConnection", + "CspmMonitorGithubOffering", + "DefenderCspmAwsOffering", + "DefenderCspmAwsOfferingVmScanners", + "DefenderCspmAwsOfferingVmScannersConfiguration", + "DefenderCspmGcpOffering", + "DefenderFoDatabasesAwsOffering", + "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", + "DefenderFoDatabasesAwsOfferingRds", + "DefenderForContainersAwsOffering", + "DefenderForContainersAwsOfferingCloudWatchToKinesis", + "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", + "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", + "DefenderForContainersAwsOfferingKinesisToS3", + "DefenderForContainersAwsOfferingKubernetesScubaReader", + "DefenderForContainersAwsOfferingKubernetesService", + "DefenderForContainersGcpOffering", + "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", + "DefenderForContainersGcpOfferingNativeCloudConnection", + "DefenderForDatabasesGcpOffering", + "DefenderForDatabasesGcpOfferingArcAutoProvisioning", + "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", + "DefenderForDevOpsAzureDevOpsOffering", + "DefenderForDevOpsGithubOffering", + "DefenderForServersAwsOffering", + "DefenderForServersAwsOfferingArcAutoProvisioning", + "DefenderForServersAwsOfferingDefenderForServers", + "DefenderForServersAwsOfferingMdeAutoProvisioning", + "DefenderForServersAwsOfferingSubPlan", + "DefenderForServersAwsOfferingVaAutoProvisioning", + "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", + "DefenderForServersAwsOfferingVmScanners", + "DefenderForServersAwsOfferingVmScannersConfiguration", + "DefenderForServersGcpOffering", + "DefenderForServersGcpOfferingArcAutoProvisioning", + "DefenderForServersGcpOfferingDefenderForServers", + "DefenderForServersGcpOfferingMdeAutoProvisioning", + "DefenderForServersGcpOfferingSubPlan", + "DefenderForServersGcpOfferingVaAutoProvisioning", + "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", + "ETag", + "EnvironmentData", + "ErrorAdditionalInfo", + "GcpOrganizationalData", + "GcpOrganizationalDataMember", + "GcpOrganizationalDataOrganization", + "GcpProjectDetails", + "GcpProjectEnvironmentData", + "GithubScopeEnvironmentData", + "InformationProtectionAwsOffering", + "InformationProtectionAwsOfferingInformationProtection", + "Kind", + "Resource", + "SecurityConnector", + "SecurityConnectorsList", + "SystemData", + "Tags", + "TrackedResource", + "CloudName", + "CreatedByType", + "EnvironmentType", + "OfferingType", + "OrganizationMembershipType", + "ScanningMode", + "SubPlan", + "Type", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_models_py3.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_models_py3.py new file mode 100644 index 000000000000..29f7a7f69034 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_models_py3.py @@ -0,0 +1,2767 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# 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 datetime +import sys +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +if sys.version_info >= (3, 9): + from collections.abc import MutableMapping +else: + from typing import MutableMapping # type: ignore # pylint: disable=ungrouped-imports + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object + + +class EnvironmentData(_serialization.Model): + """The security connector environment data. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AwsEnvironmentData, AzureDevOpsScopeEnvironmentData, GcpProjectEnvironmentData, + GithubScopeEnvironmentData + + All required parameters must be populated in order to send to Azure. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". + :vartype environment_type: str or + ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentType + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + } + + _subtype_map = { + "environment_type": { + "AwsAccount": "AwsEnvironmentData", + "AzureDevOpsScope": "AzureDevOpsScopeEnvironmentData", + "GcpProject": "GcpProjectEnvironmentData", + "GithubScope": "GithubScopeEnvironmentData", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.environment_type = None # type: Optional[str] + + +class AwsEnvironmentData(EnvironmentData): + """The aws connector environment data. + + All required parameters must be populated in order to send to Azure. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". + :vartype environment_type: str or + ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentType + :ivar organizational_data: The AWS account's organizational data. + :vartype organizational_data: + ~azure.mgmt.security.v2022_08_01_preview.models.AwsOrganizationalData + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + "organizational_data": {"key": "organizationalData", "type": "AwsOrganizationalData"}, + } + + def __init__(self, *, organizational_data: Optional["_models.AwsOrganizationalData"] = None, **kwargs): + """ + :keyword organizational_data: The AWS account's organizational data. + :paramtype organizational_data: + ~azure.mgmt.security.v2022_08_01_preview.models.AwsOrganizationalData + """ + super().__init__(**kwargs) + self.environment_type = "AwsAccount" # type: str + self.organizational_data = organizational_data + + +class AwsOrganizationalData(_serialization.Model): + """The awsOrganization data. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + AwsOrganizationalDataMember, AwsOrganizationalDataMaster + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + } + + _subtype_map = { + "organization_membership_type": { + "Member": "AwsOrganizationalDataMember", + "Organization": "AwsOrganizationalDataMaster", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.organization_membership_type = None # type: Optional[str] + + +class AwsOrganizationalDataMaster(AwsOrganizationalData): + """The awsOrganization data for the master account. + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType + :ivar stackset_name: If the multi cloud account is of membership type organization, this will + be the name of the onboarding stackset. + :vartype stackset_name: str + :ivar excluded_account_ids: If the multi cloud account is of membership type organization, list + of accounts excluded from offering. + :vartype excluded_account_ids: list[str] + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "stackset_name": {"key": "stacksetName", "type": "str"}, + "excluded_account_ids": {"key": "excludedAccountIds", "type": "[str]"}, + } + + def __init__( + self, *, stackset_name: Optional[str] = None, excluded_account_ids: Optional[List[str]] = None, **kwargs + ): + """ + :keyword stackset_name: If the multi cloud account is of membership type organization, this + will be the name of the onboarding stackset. + :paramtype stackset_name: str + :keyword excluded_account_ids: If the multi cloud account is of membership type organization, + list of accounts excluded from offering. + :paramtype excluded_account_ids: list[str] + """ + super().__init__(**kwargs) + self.organization_membership_type = "Organization" # type: str + self.stackset_name = stackset_name + self.excluded_account_ids = excluded_account_ids + + +class AwsOrganizationalDataMember(AwsOrganizationalData): + """The awsOrganization data for the member account. + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType + :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, + this will be the ID of the account's parent. + :vartype parent_hierarchy_id: str + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, + } + + def __init__(self, *, parent_hierarchy_id: Optional[str] = None, **kwargs): + """ + :keyword parent_hierarchy_id: If the multi cloud account is not of membership type + organization, this will be the ID of the account's parent. + :paramtype parent_hierarchy_id: str + """ + super().__init__(**kwargs) + self.organization_membership_type = "Member" # type: str + self.parent_hierarchy_id = parent_hierarchy_id + + +class AzureDevOpsScopeEnvironmentData(EnvironmentData): + """The AzureDevOps scope connector's environment data. + + All required parameters must be populated in order to send to Azure. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". + :vartype environment_type: str or + ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentType + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.environment_type = "AzureDevOpsScope" # type: str + + +class AzureTrackedResourceLocation(_serialization.Model): + """Describes an Azure resource with location. + + :ivar location: Location where the resource is stored. + :vartype location: str + """ + + _attribute_map = { + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: Optional[str] = None, **kwargs): + """ + :keyword location: Location where the resource is stored. + :paramtype location: str + """ + super().__init__(**kwargs) + self.location = location + + +class CloudErrorBody(_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.security.v2022_08_01_preview.models.CloudErrorBody] + :ivar additional_info: The error additional info. + :vartype additional_info: + list[~azure.mgmt.security.v2022_08_01_preview.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": "[CloudErrorBody]"}, + "additional_info": {"key": "additionalInfo", "type": "[ErrorAdditionalInfo]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.code = None + self.message = None + self.target = None + self.details = None + self.additional_info = None + + +class CloudOffering(_serialization.Model): + """The security offering details. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + CspmMonitorAwsOffering, CspmMonitorAzureDevOpsOffering, CspmMonitorGcpOffering, + CspmMonitorGithubOffering, DefenderCspmAwsOffering, DefenderCspmGcpOffering, + DefenderForContainersAwsOffering, DefenderForContainersGcpOffering, + DefenderFoDatabasesAwsOffering, DefenderForDatabasesGcpOffering, + DefenderForDevOpsAzureDevOpsOffering, DefenderForDevOpsGithubOffering, + DefenderForServersAwsOffering, DefenderForServersGcpOffering, InformationProtectionAwsOffering + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + _subtype_map = { + "offering_type": { + "CspmMonitorAws": "CspmMonitorAwsOffering", + "CspmMonitorAzureDevOps": "CspmMonitorAzureDevOpsOffering", + "CspmMonitorGcp": "CspmMonitorGcpOffering", + "CspmMonitorGithub": "CspmMonitorGithubOffering", + "DefenderCspmAws": "DefenderCspmAwsOffering", + "DefenderCspmGcp": "DefenderCspmGcpOffering", + "DefenderForContainersAws": "DefenderForContainersAwsOffering", + "DefenderForContainersGcp": "DefenderForContainersGcpOffering", + "DefenderForDatabasesAws": "DefenderFoDatabasesAwsOffering", + "DefenderForDatabasesGcp": "DefenderForDatabasesGcpOffering", + "DefenderForDevOpsAzureDevOps": "DefenderForDevOpsAzureDevOpsOffering", + "DefenderForDevOpsGithub": "DefenderForDevOpsGithubOffering", + "DefenderForServersAws": "DefenderForServersAwsOffering", + "DefenderForServersGcp": "DefenderForServersGcpOffering", + "InformationProtectionAws": "InformationProtectionAwsOffering", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.offering_type = None # type: Optional[str] + self.description = None + + +class CspmMonitorAwsOffering(CloudOffering): + """The CSPM monitoring for AWS offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar native_cloud_connection: The native cloud connection configuration. + :vartype native_cloud_connection: + ~azure.mgmt.security.v2022_08_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "native_cloud_connection": { + "key": "nativeCloudConnection", + "type": "CspmMonitorAwsOfferingNativeCloudConnection", + }, + } + + def __init__( + self, + *, + native_cloud_connection: Optional["_models.CspmMonitorAwsOfferingNativeCloudConnection"] = None, + **kwargs + ): + """ + :keyword native_cloud_connection: The native cloud connection configuration. + :paramtype native_cloud_connection: + ~azure.mgmt.security.v2022_08_01_preview.models.CspmMonitorAwsOfferingNativeCloudConnection + """ + super().__init__(**kwargs) + self.offering_type = "CspmMonitorAws" # type: str + self.native_cloud_connection = native_cloud_connection + + +class CspmMonitorAwsOfferingNativeCloudConnection(_serialization.Model): + """The native cloud connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class CspmMonitorAzureDevOpsOffering(CloudOffering): + """The CSPM monitoring for AzureDevOps offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.offering_type = "CspmMonitorAzureDevOps" # type: str + + +class CspmMonitorGcpOffering(CloudOffering): + """The CSPM monitoring for GCP offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar native_cloud_connection: The native cloud connection configuration. + :vartype native_cloud_connection: + ~azure.mgmt.security.v2022_08_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "native_cloud_connection": { + "key": "nativeCloudConnection", + "type": "CspmMonitorGcpOfferingNativeCloudConnection", + }, + } + + def __init__( + self, + *, + native_cloud_connection: Optional["_models.CspmMonitorGcpOfferingNativeCloudConnection"] = None, + **kwargs + ): + """ + :keyword native_cloud_connection: The native cloud connection configuration. + :paramtype native_cloud_connection: + ~azure.mgmt.security.v2022_08_01_preview.models.CspmMonitorGcpOfferingNativeCloudConnection + """ + super().__init__(**kwargs) + self.offering_type = "CspmMonitorGcp" # type: str + self.native_cloud_connection = native_cloud_connection + + +class CspmMonitorGcpOfferingNativeCloudConnection(_serialization.Model): + """The native cloud connection configuration. + + :ivar workload_identity_provider_id: The GCP workload identity provider id for the offering. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this + offering. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs + ): + """ + :keyword workload_identity_provider_id: The GCP workload identity provider id for the offering. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + offering. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class CspmMonitorGithubOffering(CloudOffering): + """The CSPM monitoring for github offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.offering_type = "CspmMonitorGithub" # type: str + + +class DefenderCspmAwsOffering(CloudOffering): + """The CSPM P1 for Aws offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :vartype vm_scanners: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderCspmAwsOfferingVmScanners + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "vm_scanners": {"key": "vmScanners", "type": "DefenderCspmAwsOfferingVmScanners"}, + } + + def __init__(self, *, vm_scanners: Optional["_models.DefenderCspmAwsOfferingVmScanners"] = None, **kwargs): + """ + :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :paramtype vm_scanners: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderCspmAwsOfferingVmScanners + """ + super().__init__(**kwargs) + self.offering_type = "DefenderCspmAws" # type: str + self.vm_scanners = vm_scanners + + +class DefenderCspmAwsOfferingVmScanners(_serialization.Model): + """The Microsoft Defender for Server VM scanning configuration. + + :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Server VM scanning. + :vartype configuration: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderCspmAwsOfferingVmScannersConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "DefenderCspmAwsOfferingVmScannersConfiguration"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderCspmAwsOfferingVmScannersConfiguration"] = None, + **kwargs + ): + """ + :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Server VM scanning. + :paramtype configuration: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderCspmAwsOfferingVmScannersConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderCspmAwsOfferingVmScannersConfiguration(_serialization.Model): + """configuration for Microsoft Defender for Server VM scanning. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + :ivar scanning_mode: The scanning mode for the vm scan. "Default" + :vartype scanning_mode: str or ~azure.mgmt.security.v2022_08_01_preview.models.ScanningMode + :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. + :vartype exclusion_tags: dict[str, str] + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + "scanning_mode": {"key": "scanningMode", "type": "str"}, + "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, + } + + def __init__( + self, + *, + cloud_role_arn: Optional[str] = None, + scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, + exclusion_tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + :keyword scanning_mode: The scanning mode for the vm scan. "Default" + :paramtype scanning_mode: str or ~azure.mgmt.security.v2022_08_01_preview.models.ScanningMode + :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. + :paramtype exclusion_tags: dict[str, str] + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + self.scanning_mode = scanning_mode + self.exclusion_tags = exclusion_tags + + +class DefenderCspmGcpOffering(CloudOffering): + """The CSPM P1 for GCP offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.offering_type = "DefenderCspmGcp" # type: str + + +class DefenderFoDatabasesAwsOffering(CloudOffering): + """The Defender for Databases AWS offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning + :ivar rds: The RDS configuration. + :vartype rds: ~azure.mgmt.security.v2022_08_01_preview.models.DefenderFoDatabasesAwsOfferingRds + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderFoDatabasesAwsOfferingArcAutoProvisioning", + }, + "rds": {"key": "rds", "type": "DefenderFoDatabasesAwsOfferingRds"}, + } + + def __init__( + self, + *, + arc_auto_provisioning: Optional["_models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning"] = None, + rds: Optional["_models.DefenderFoDatabasesAwsOfferingRds"] = None, + **kwargs + ): + """ + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderFoDatabasesAwsOfferingArcAutoProvisioning + :keyword rds: The RDS configuration. + :paramtype rds: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderFoDatabasesAwsOfferingRds + """ + super().__init__(**kwargs) + self.offering_type = "DefenderForDatabasesAws" # type: str + self.arc_auto_provisioning = arc_auto_provisioning + self.rds = rds + + +class DefenderFoDatabasesAwsOfferingArcAutoProvisioning(_serialization.Model): + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword enabled: Is arc auto provisioning enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderFoDatabasesAwsOfferingRds(_serialization.Model): + """The RDS configuration. + + :ivar enabled: Is RDS protection enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword enabled: Is RDS protection enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOffering(CloudOffering): # pylint: disable=too-many-instance-attributes + """The Defender for Containers AWS offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar kubernetes_service: The kubernetes service connection configuration. + :vartype kubernetes_service: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKubernetesService + :ivar kubernetes_scuba_reader: The kubernetes to scuba connection configuration. + :vartype kubernetes_scuba_reader: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader + :ivar cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. + :vartype cloud_watch_to_kinesis: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis + :ivar kinesis_to_s3: The kinesis to s3 connection configuration. + :vartype kinesis_to_s3: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 + :ivar container_vulnerability_assessment: The container vulnerability assessment configuration. + :vartype container_vulnerability_assessment: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment + :ivar container_vulnerability_assessment_task: The container vulnerability assessment task + configuration. + :vartype container_vulnerability_assessment_task: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask + :ivar enable_container_vulnerability_assessment: Enable container vulnerability assessment + feature. + :vartype enable_container_vulnerability_assessment: bool + :ivar auto_provisioning: Is audit logs pipeline auto provisioning enabled. + :vartype auto_provisioning: bool + :ivar kube_audit_retention_time: The retention time in days of kube audit logs set on the + CloudWatch log group. + :vartype kube_audit_retention_time: int + :ivar scuba_external_id: The externalId used by the data reader to prevent the confused deputy + attack. + :vartype scuba_external_id: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "kubernetes_service": {"key": "kubernetesService", "type": "DefenderForContainersAwsOfferingKubernetesService"}, + "kubernetes_scuba_reader": { + "key": "kubernetesScubaReader", + "type": "DefenderForContainersAwsOfferingKubernetesScubaReader", + }, + "cloud_watch_to_kinesis": { + "key": "cloudWatchToKinesis", + "type": "DefenderForContainersAwsOfferingCloudWatchToKinesis", + }, + "kinesis_to_s3": {"key": "kinesisToS3", "type": "DefenderForContainersAwsOfferingKinesisToS3"}, + "container_vulnerability_assessment": { + "key": "containerVulnerabilityAssessment", + "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessment", + }, + "container_vulnerability_assessment_task": { + "key": "containerVulnerabilityAssessmentTask", + "type": "DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask", + }, + "enable_container_vulnerability_assessment": {"key": "enableContainerVulnerabilityAssessment", "type": "bool"}, + "auto_provisioning": {"key": "autoProvisioning", "type": "bool"}, + "kube_audit_retention_time": {"key": "kubeAuditRetentionTime", "type": "int"}, + "scuba_external_id": {"key": "scubaExternalId", "type": "str"}, + } + + def __init__( + self, + *, + kubernetes_service: Optional["_models.DefenderForContainersAwsOfferingKubernetesService"] = None, + kubernetes_scuba_reader: Optional["_models.DefenderForContainersAwsOfferingKubernetesScubaReader"] = None, + cloud_watch_to_kinesis: Optional["_models.DefenderForContainersAwsOfferingCloudWatchToKinesis"] = None, + kinesis_to_s3: Optional["_models.DefenderForContainersAwsOfferingKinesisToS3"] = None, + container_vulnerability_assessment: Optional[ + "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment" + ] = None, + container_vulnerability_assessment_task: Optional[ + "_models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask" + ] = None, + enable_container_vulnerability_assessment: Optional[bool] = None, + auto_provisioning: Optional[bool] = None, + kube_audit_retention_time: Optional[int] = None, + scuba_external_id: Optional[str] = None, + **kwargs + ): + """ + :keyword kubernetes_service: The kubernetes service connection configuration. + :paramtype kubernetes_service: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKubernetesService + :keyword kubernetes_scuba_reader: The kubernetes to scuba connection configuration. + :paramtype kubernetes_scuba_reader: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKubernetesScubaReader + :keyword cloud_watch_to_kinesis: The cloudwatch to kinesis connection configuration. + :paramtype cloud_watch_to_kinesis: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingCloudWatchToKinesis + :keyword kinesis_to_s3: The kinesis to s3 connection configuration. + :paramtype kinesis_to_s3: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingKinesisToS3 + :keyword container_vulnerability_assessment: The container vulnerability assessment + configuration. + :paramtype container_vulnerability_assessment: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessment + :keyword container_vulnerability_assessment_task: The container vulnerability assessment task + configuration. + :paramtype container_vulnerability_assessment_task: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask + :keyword enable_container_vulnerability_assessment: Enable container vulnerability assessment + feature. + :paramtype enable_container_vulnerability_assessment: bool + :keyword auto_provisioning: Is audit logs pipeline auto provisioning enabled. + :paramtype auto_provisioning: bool + :keyword kube_audit_retention_time: The retention time in days of kube audit logs set on the + CloudWatch log group. + :paramtype kube_audit_retention_time: int + :keyword scuba_external_id: The externalId used by the data reader to prevent the confused + deputy attack. + :paramtype scuba_external_id: str + """ + super().__init__(**kwargs) + self.offering_type = "DefenderForContainersAws" # type: str + self.kubernetes_service = kubernetes_service + self.kubernetes_scuba_reader = kubernetes_scuba_reader + self.cloud_watch_to_kinesis = cloud_watch_to_kinesis + self.kinesis_to_s3 = kinesis_to_s3 + self.container_vulnerability_assessment = container_vulnerability_assessment + self.container_vulnerability_assessment_task = container_vulnerability_assessment_task + self.enable_container_vulnerability_assessment = enable_container_vulnerability_assessment + self.auto_provisioning = auto_provisioning + self.kube_audit_retention_time = kube_audit_retention_time + self.scuba_external_id = scuba_external_id + + +class DefenderForContainersAwsOfferingCloudWatchToKinesis(_serialization.Model): + """The cloudwatch to kinesis connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into + Kinesis. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword cloud_role_arn: The cloud role ARN in AWS used by CloudWatch to transfer data into + Kinesis. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingContainerVulnerabilityAssessment(_serialization.Model): + """The container vulnerability assessment configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingContainerVulnerabilityAssessmentTask(_serialization.Model): + """The container vulnerability assessment task configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingKinesisToS3(_serialization.Model): + """The kinesis to s3 connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword cloud_role_arn: The cloud role ARN in AWS used by Kinesis to transfer data into S3. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingKubernetesScubaReader(_serialization.Model): + """The kubernetes to scuba connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for reading data. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersAwsOfferingKubernetesService(_serialization.Model): + """The kubernetes service connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning + resources. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature used for provisioning + resources. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForContainersGcpOffering(CloudOffering): + """The containers GCP offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar native_cloud_connection: The native cloud connection configuration. + :vartype native_cloud_connection: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection + :ivar data_pipeline_native_cloud_connection: The native cloud connection configuration. + :vartype data_pipeline_native_cloud_connection: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection + :ivar audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. + :vartype audit_logs_auto_provisioning_flag: bool + :ivar defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes agent + auto provisioning enabled. + :vartype defender_agent_auto_provisioning_flag: bool + :ivar policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning + enabled. + :vartype policy_agent_auto_provisioning_flag: bool + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "native_cloud_connection": { + "key": "nativeCloudConnection", + "type": "DefenderForContainersGcpOfferingNativeCloudConnection", + }, + "data_pipeline_native_cloud_connection": { + "key": "dataPipelineNativeCloudConnection", + "type": "DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection", + }, + "audit_logs_auto_provisioning_flag": {"key": "auditLogsAutoProvisioningFlag", "type": "bool"}, + "defender_agent_auto_provisioning_flag": {"key": "defenderAgentAutoProvisioningFlag", "type": "bool"}, + "policy_agent_auto_provisioning_flag": {"key": "policyAgentAutoProvisioningFlag", "type": "bool"}, + } + + def __init__( + self, + *, + native_cloud_connection: Optional["_models.DefenderForContainersGcpOfferingNativeCloudConnection"] = None, + data_pipeline_native_cloud_connection: Optional[ + "_models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection" + ] = None, + audit_logs_auto_provisioning_flag: Optional[bool] = None, + defender_agent_auto_provisioning_flag: Optional[bool] = None, + policy_agent_auto_provisioning_flag: Optional[bool] = None, + **kwargs + ): + """ + :keyword native_cloud_connection: The native cloud connection configuration. + :paramtype native_cloud_connection: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersGcpOfferingNativeCloudConnection + :keyword data_pipeline_native_cloud_connection: The native cloud connection configuration. + :paramtype data_pipeline_native_cloud_connection: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection + :keyword audit_logs_auto_provisioning_flag: Is audit logs data collection enabled. + :paramtype audit_logs_auto_provisioning_flag: bool + :keyword defender_agent_auto_provisioning_flag: Is Microsoft Defender for Cloud Kubernetes + agent auto provisioning enabled. + :paramtype defender_agent_auto_provisioning_flag: bool + :keyword policy_agent_auto_provisioning_flag: Is Policy Kubernetes agent auto provisioning + enabled. + :paramtype policy_agent_auto_provisioning_flag: bool + """ + super().__init__(**kwargs) + self.offering_type = "DefenderForContainersGcp" # type: str + self.native_cloud_connection = native_cloud_connection + self.data_pipeline_native_cloud_connection = data_pipeline_native_cloud_connection + self.audit_logs_auto_provisioning_flag = audit_logs_auto_provisioning_flag + self.defender_agent_auto_provisioning_flag = defender_agent_auto_provisioning_flag + self.policy_agent_auto_provisioning_flag = policy_agent_auto_provisioning_flag + + +class DefenderForContainersGcpOfferingDataPipelineNativeCloudConnection(_serialization.Model): + """The native cloud connection configuration. + + :ivar service_account_email_address: The data collection service account email address in GCP + for this offering. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The data collection GCP workload identity provider id for + this offering. + :vartype workload_identity_provider_id: str + """ + + _attribute_map = { + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + } + + def __init__( + self, + *, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs + ): + """ + :keyword service_account_email_address: The data collection service account email address in + GCP for this offering. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The data collection GCP workload identity provider id + for this offering. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + + +class DefenderForContainersGcpOfferingNativeCloudConnection(_serialization.Model): + """The native cloud connection configuration. + + :ivar service_account_email_address: The service account email address in GCP for this + offering. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. + :vartype workload_identity_provider_id: str + """ + + _attribute_map = { + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + } + + def __init__( + self, + *, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs + ): + """ + :keyword service_account_email_address: The service account email address in GCP for this + offering. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The GCP workload identity provider id for this + offering. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + + +class DefenderForDatabasesGcpOffering(CloudOffering): + """The Defender for Databases GCP offering configurations. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning + :ivar defender_for_databases_arc_auto_provisioning: The native cloud connection configuration. + :vartype defender_for_databases_arc_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderForDatabasesGcpOfferingArcAutoProvisioning", + }, + "defender_for_databases_arc_auto_provisioning": { + "key": "defenderForDatabasesArcAutoProvisioning", + "type": "DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning", + }, + } + + def __init__( + self, + *, + arc_auto_provisioning: Optional["_models.DefenderForDatabasesGcpOfferingArcAutoProvisioning"] = None, + defender_for_databases_arc_auto_provisioning: Optional[ + "_models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning" + ] = None, + **kwargs + ): + """ + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForDatabasesGcpOfferingArcAutoProvisioning + :keyword defender_for_databases_arc_auto_provisioning: The native cloud connection + configuration. + :paramtype defender_for_databases_arc_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning + """ + super().__init__(**kwargs) + self.offering_type = "DefenderForDatabasesGcp" # type: str + self.arc_auto_provisioning = arc_auto_provisioning + self.defender_for_databases_arc_auto_provisioning = defender_for_databases_arc_auto_provisioning + + +class DefenderForDatabasesGcpOfferingArcAutoProvisioning(_serialization.Model): + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): + """ + :keyword enabled: Is arc auto provisioning enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + + +class DefenderForDatabasesGcpOfferingDefenderForDatabasesArcAutoProvisioning(_serialization.Model): + """The native cloud connection configuration. + + :ivar service_account_email_address: The service account email address in GCP for this + offering. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The GCP workload identity provider id for this offering. + :vartype workload_identity_provider_id: str + """ + + _attribute_map = { + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + } + + def __init__( + self, + *, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs + ): + """ + :keyword service_account_email_address: The service account email address in GCP for this + offering. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The GCP workload identity provider id for this + offering. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + + +class DefenderForDevOpsAzureDevOpsOffering(CloudOffering): + """The Defender for DevOps for Azure DevOps offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.offering_type = "DefenderForDevOpsAzureDevOps" # type: str + + +class DefenderForDevOpsGithubOffering(CloudOffering): + """The Defender for DevOps for Github offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.offering_type = "DefenderForDevOpsGithub" # type: str + + +class DefenderForServersAwsOffering(CloudOffering): + """The Defender for Servers AWS offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar defender_for_servers: The Defender for servers connection configuration. + :vartype defender_for_servers: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingDefenderForServers + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning + :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :vartype va_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning + :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :vartype mde_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning + :ivar sub_plan: configuration for the servers offering subPlan. + :vartype sub_plan: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingSubPlan + :ivar vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :vartype vm_scanners: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVmScanners + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "defender_for_servers": { + "key": "defenderForServers", + "type": "DefenderForServersAwsOfferingDefenderForServers", + }, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderForServersAwsOfferingArcAutoProvisioning", + }, + "va_auto_provisioning": { + "key": "vaAutoProvisioning", + "type": "DefenderForServersAwsOfferingVaAutoProvisioning", + }, + "mde_auto_provisioning": { + "key": "mdeAutoProvisioning", + "type": "DefenderForServersAwsOfferingMdeAutoProvisioning", + }, + "sub_plan": {"key": "subPlan", "type": "DefenderForServersAwsOfferingSubPlan"}, + "vm_scanners": {"key": "vmScanners", "type": "DefenderForServersAwsOfferingVmScanners"}, + } + + def __init__( + self, + *, + defender_for_servers: Optional["_models.DefenderForServersAwsOfferingDefenderForServers"] = None, + arc_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingArcAutoProvisioning"] = None, + va_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioning"] = None, + mde_auto_provisioning: Optional["_models.DefenderForServersAwsOfferingMdeAutoProvisioning"] = None, + sub_plan: Optional["_models.DefenderForServersAwsOfferingSubPlan"] = None, + vm_scanners: Optional["_models.DefenderForServersAwsOfferingVmScanners"] = None, + **kwargs + ): + """ + :keyword defender_for_servers: The Defender for servers connection configuration. + :paramtype defender_for_servers: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingDefenderForServers + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingArcAutoProvisioning + :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :paramtype va_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioning + :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :paramtype mde_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingMdeAutoProvisioning + :keyword sub_plan: configuration for the servers offering subPlan. + :paramtype sub_plan: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingSubPlan + :keyword vm_scanners: The Microsoft Defender for Server VM scanning configuration. + :paramtype vm_scanners: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVmScanners + """ + super().__init__(**kwargs) + self.offering_type = "DefenderForServersAws" # type: str + self.defender_for_servers = defender_for_servers + self.arc_auto_provisioning = arc_auto_provisioning + self.va_auto_provisioning = va_auto_provisioning + self.mde_auto_provisioning = mde_auto_provisioning + self.sub_plan = sub_plan + self.vm_scanners = vm_scanners + + +class DefenderForServersAwsOfferingArcAutoProvisioning(_serialization.Model): + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword enabled: Is arc auto provisioning enabled. + :paramtype enabled: bool + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.enabled = enabled + self.cloud_role_arn = cloud_role_arn + + +class DefenderForServersAwsOfferingDefenderForServers(_serialization.Model): + """The Defender for servers connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class DefenderForServersAwsOfferingMdeAutoProvisioning(_serialization.Model): + """The Microsoft Defender for Endpoint autoprovisioning configuration. + + :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :vartype configuration: JSON + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "object"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs): + """ + :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :paramtype configuration: JSON + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersAwsOfferingSubPlan(_serialization.Model): + """configuration for the servers offering subPlan. + + :ivar type: The available sub plans. Known values are: "P1" and "P2". + :vartype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.SubPlan + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs): + """ + :keyword type: The available sub plans. Known values are: "P1" and "P2". + :paramtype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.SubPlan + """ + super().__init__(**kwargs) + self.type = type + + +class DefenderForServersAwsOfferingVaAutoProvisioning(_serialization.Model): + """The Vulnerability Assessment autoprovisioning configuration. + + :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. + :vartype configuration: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": { + "key": "configuration", + "type": "DefenderForServersAwsOfferingVaAutoProvisioningConfiguration", + }, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration"] = None, + **kwargs + ): + """ + :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. + :paramtype configuration: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVaAutoProvisioningConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersAwsOfferingVaAutoProvisioningConfiguration(_serialization.Model): + """configuration for Vulnerability Assessment autoprovisioning. + + :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :vartype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.Type + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs): + """ + :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :paramtype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.Type + """ + super().__init__(**kwargs) + self.type = type + + +class DefenderForServersAwsOfferingVmScanners(_serialization.Model): + """The Microsoft Defender for Server VM scanning configuration. + + :ivar enabled: Is Microsoft Defender for Server VM scanning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Server VM scanning. + :vartype configuration: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "DefenderForServersAwsOfferingVmScannersConfiguration"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderForServersAwsOfferingVmScannersConfiguration"] = None, + **kwargs + ): + """ + :keyword enabled: Is Microsoft Defender for Server VM scanning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Server VM scanning. + :paramtype configuration: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersAwsOfferingVmScannersConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersAwsOfferingVmScannersConfiguration(_serialization.Model): + """configuration for Microsoft Defender for Server VM scanning. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + :ivar scanning_mode: The scanning mode for the vm scan. "Default" + :vartype scanning_mode: str or ~azure.mgmt.security.v2022_08_01_preview.models.ScanningMode + :ivar exclusion_tags: VM tags that indicates that VM should not be scanned. + :vartype exclusion_tags: dict[str, str] + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + "scanning_mode": {"key": "scanningMode", "type": "str"}, + "exclusion_tags": {"key": "exclusionTags", "type": "{str}"}, + } + + def __init__( + self, + *, + cloud_role_arn: Optional[str] = None, + scanning_mode: Optional[Union[str, "_models.ScanningMode"]] = None, + exclusion_tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + :keyword scanning_mode: The scanning mode for the vm scan. "Default" + :paramtype scanning_mode: str or ~azure.mgmt.security.v2022_08_01_preview.models.ScanningMode + :keyword exclusion_tags: VM tags that indicates that VM should not be scanned. + :paramtype exclusion_tags: dict[str, str] + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + self.scanning_mode = scanning_mode + self.exclusion_tags = exclusion_tags + + +class DefenderForServersGcpOffering(CloudOffering): + """The Defender for Servers GCP offering configurations. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar defender_for_servers: The Defender for servers connection configuration. + :vartype defender_for_servers: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingDefenderForServers + :ivar arc_auto_provisioning: The ARC autoprovisioning configuration. + :vartype arc_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning + :ivar va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :vartype va_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning + :ivar mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :vartype mde_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning + :ivar sub_plan: configuration for the servers offering subPlan. + :vartype sub_plan: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingSubPlan + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "defender_for_servers": { + "key": "defenderForServers", + "type": "DefenderForServersGcpOfferingDefenderForServers", + }, + "arc_auto_provisioning": { + "key": "arcAutoProvisioning", + "type": "DefenderForServersGcpOfferingArcAutoProvisioning", + }, + "va_auto_provisioning": { + "key": "vaAutoProvisioning", + "type": "DefenderForServersGcpOfferingVaAutoProvisioning", + }, + "mde_auto_provisioning": { + "key": "mdeAutoProvisioning", + "type": "DefenderForServersGcpOfferingMdeAutoProvisioning", + }, + "sub_plan": {"key": "subPlan", "type": "DefenderForServersGcpOfferingSubPlan"}, + } + + def __init__( + self, + *, + defender_for_servers: Optional["_models.DefenderForServersGcpOfferingDefenderForServers"] = None, + arc_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingArcAutoProvisioning"] = None, + va_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioning"] = None, + mde_auto_provisioning: Optional["_models.DefenderForServersGcpOfferingMdeAutoProvisioning"] = None, + sub_plan: Optional["_models.DefenderForServersGcpOfferingSubPlan"] = None, + **kwargs + ): + """ + :keyword defender_for_servers: The Defender for servers connection configuration. + :paramtype defender_for_servers: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingDefenderForServers + :keyword arc_auto_provisioning: The ARC autoprovisioning configuration. + :paramtype arc_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingArcAutoProvisioning + :keyword va_auto_provisioning: The Vulnerability Assessment autoprovisioning configuration. + :paramtype va_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioning + :keyword mde_auto_provisioning: The Microsoft Defender for Endpoint autoprovisioning + configuration. + :paramtype mde_auto_provisioning: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingMdeAutoProvisioning + :keyword sub_plan: configuration for the servers offering subPlan. + :paramtype sub_plan: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingSubPlan + """ + super().__init__(**kwargs) + self.offering_type = "DefenderForServersGcp" # type: str + self.defender_for_servers = defender_for_servers + self.arc_auto_provisioning = arc_auto_provisioning + self.va_auto_provisioning = va_auto_provisioning + self.mde_auto_provisioning = mde_auto_provisioning + self.sub_plan = sub_plan + + +class DefenderForServersGcpOfferingArcAutoProvisioning(_serialization.Model): + """The ARC autoprovisioning configuration. + + :ivar enabled: Is arc auto provisioning enabled. + :vartype enabled: bool + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): + """ + :keyword enabled: Is arc auto provisioning enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + + +class DefenderForServersGcpOfferingDefenderForServers(_serialization.Model): + """The Defender for servers connection configuration. + + :ivar workload_identity_provider_id: The workload identity provider id in GCP for this feature. + :vartype workload_identity_provider_id: str + :ivar service_account_email_address: The service account email address in GCP for this feature. + :vartype service_account_email_address: str + """ + + _attribute_map = { + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + } + + def __init__( + self, + *, + workload_identity_provider_id: Optional[str] = None, + service_account_email_address: Optional[str] = None, + **kwargs + ): + """ + :keyword workload_identity_provider_id: The workload identity provider id in GCP for this + feature. + :paramtype workload_identity_provider_id: str + :keyword service_account_email_address: The service account email address in GCP for this + feature. + :paramtype service_account_email_address: str + """ + super().__init__(**kwargs) + self.workload_identity_provider_id = workload_identity_provider_id + self.service_account_email_address = service_account_email_address + + +class DefenderForServersGcpOfferingMdeAutoProvisioning(_serialization.Model): + """The Microsoft Defender for Endpoint autoprovisioning configuration. + + :ivar enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :vartype configuration: JSON + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": {"key": "configuration", "type": "object"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, configuration: Optional[JSON] = None, **kwargs): + """ + :keyword enabled: Is Microsoft Defender for Endpoint auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Microsoft Defender for Endpoint autoprovisioning. + :paramtype configuration: JSON + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersGcpOfferingSubPlan(_serialization.Model): + """configuration for the servers offering subPlan. + + :ivar type: The available sub plans. Known values are: "P1" and "P2". + :vartype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.SubPlan + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.SubPlan"]] = None, **kwargs): + """ + :keyword type: The available sub plans. Known values are: "P1" and "P2". + :paramtype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.SubPlan + """ + super().__init__(**kwargs) + self.type = type + + +class DefenderForServersGcpOfferingVaAutoProvisioning(_serialization.Model): + """The Vulnerability Assessment autoprovisioning configuration. + + :ivar enabled: Is Vulnerability Assessment auto provisioning enabled. + :vartype enabled: bool + :ivar configuration: configuration for Vulnerability Assessment autoprovisioning. + :vartype configuration: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "configuration": { + "key": "configuration", + "type": "DefenderForServersGcpOfferingVaAutoProvisioningConfiguration", + }, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + configuration: Optional["_models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration"] = None, + **kwargs + ): + """ + :keyword enabled: Is Vulnerability Assessment auto provisioning enabled. + :paramtype enabled: bool + :keyword configuration: configuration for Vulnerability Assessment autoprovisioning. + :paramtype configuration: + ~azure.mgmt.security.v2022_08_01_preview.models.DefenderForServersGcpOfferingVaAutoProvisioningConfiguration + """ + super().__init__(**kwargs) + self.enabled = enabled + self.configuration = configuration + + +class DefenderForServersGcpOfferingVaAutoProvisioningConfiguration(_serialization.Model): + """configuration for Vulnerability Assessment autoprovisioning. + + :ivar type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :vartype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.Type + """ + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, *, type: Optional[Union[str, "_models.Type"]] = None, **kwargs): + """ + :keyword type: The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or + 'Qualys'. Known values are: "Qualys" and "TVM". + :paramtype type: str or ~azure.mgmt.security.v2022_08_01_preview.models.Type + """ + super().__init__(**kwargs) + self.type = type + + +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): + """ """ + super().__init__(**kwargs) + self.type = None + self.info = None + + +class ETag(_serialization.Model): + """Entity tag is used for comparing two or more entities from the same requested resource. + + :ivar etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :vartype etag: str + """ + + _attribute_map = { + "etag": {"key": "etag", "type": "str"}, + } + + def __init__(self, *, etag: Optional[str] = None, **kwargs): + """ + :keyword etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :paramtype etag: str + """ + super().__init__(**kwargs) + self.etag = etag + + +class GcpOrganizationalData(_serialization.Model): + """The gcpOrganization data. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + GcpOrganizationalDataMember, GcpOrganizationalDataOrganization + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + } + + _subtype_map = { + "organization_membership_type": { + "Member": "GcpOrganizationalDataMember", + "Organization": "GcpOrganizationalDataOrganization", + } + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.organization_membership_type = None # type: Optional[str] + + +class GcpOrganizationalDataMember(GcpOrganizationalData): + """The gcpOrganization data for the member account. + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType + :ivar parent_hierarchy_id: If the multi cloud account is not of membership type organization, + this will be the ID of the project's parent. + :vartype parent_hierarchy_id: str + :ivar management_project_number: The GCP management project number from organizational + onboarding. + :vartype management_project_number: str + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "parent_hierarchy_id": {"key": "parentHierarchyId", "type": "str"}, + "management_project_number": {"key": "managementProjectNumber", "type": "str"}, + } + + def __init__( + self, *, parent_hierarchy_id: Optional[str] = None, management_project_number: Optional[str] = None, **kwargs + ): + """ + :keyword parent_hierarchy_id: If the multi cloud account is not of membership type + organization, this will be the ID of the project's parent. + :paramtype parent_hierarchy_id: str + :keyword management_project_number: The GCP management project number from organizational + onboarding. + :paramtype management_project_number: str + """ + super().__init__(**kwargs) + self.organization_membership_type = "Member" # type: str + self.parent_hierarchy_id = parent_hierarchy_id + self.management_project_number = management_project_number + + +class GcpOrganizationalDataOrganization(GcpOrganizationalData): + """The gcpOrganization data for the parent account. + + All required parameters must be populated in order to send to Azure. + + :ivar organization_membership_type: The multi cloud account's membership type in the + organization. Required. Known values are: "Member" and "Organization". + :vartype organization_membership_type: str or + ~azure.mgmt.security.v2022_08_01_preview.models.OrganizationMembershipType + :ivar excluded_project_numbers: If the multi cloud account is of membership type organization, + list of accounts excluded from offering. + :vartype excluded_project_numbers: list[str] + :ivar service_account_email_address: The service account email address which represents the + organization level permissions container. + :vartype service_account_email_address: str + :ivar workload_identity_provider_id: The GCP workload identity provider id which represents the + permissions required to auto provision security connectors. + :vartype workload_identity_provider_id: str + """ + + _validation = { + "organization_membership_type": {"required": True}, + } + + _attribute_map = { + "organization_membership_type": {"key": "organizationMembershipType", "type": "str"}, + "excluded_project_numbers": {"key": "excludedProjectNumbers", "type": "[str]"}, + "service_account_email_address": {"key": "serviceAccountEmailAddress", "type": "str"}, + "workload_identity_provider_id": {"key": "workloadIdentityProviderId", "type": "str"}, + } + + def __init__( + self, + *, + excluded_project_numbers: Optional[List[str]] = None, + service_account_email_address: Optional[str] = None, + workload_identity_provider_id: Optional[str] = None, + **kwargs + ): + """ + :keyword excluded_project_numbers: If the multi cloud account is of membership type + organization, list of accounts excluded from offering. + :paramtype excluded_project_numbers: list[str] + :keyword service_account_email_address: The service account email address which represents the + organization level permissions container. + :paramtype service_account_email_address: str + :keyword workload_identity_provider_id: The GCP workload identity provider id which represents + the permissions required to auto provision security connectors. + :paramtype workload_identity_provider_id: str + """ + super().__init__(**kwargs) + self.organization_membership_type = "Organization" # type: str + self.excluded_project_numbers = excluded_project_numbers + self.service_account_email_address = service_account_email_address + self.workload_identity_provider_id = workload_identity_provider_id + + +class GcpProjectDetails(_serialization.Model): + """The details about the project represented by the security connector. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar project_number: The unique GCP Project number. + :vartype project_number: str + :ivar project_id: The GCP Project id. + :vartype project_id: str + :ivar workload_identity_pool_id: The GCP workload identity federation pool id. + :vartype workload_identity_pool_id: str + """ + + _validation = { + "workload_identity_pool_id": {"readonly": True}, + } + + _attribute_map = { + "project_number": {"key": "projectNumber", "type": "str"}, + "project_id": {"key": "projectId", "type": "str"}, + "workload_identity_pool_id": {"key": "workloadIdentityPoolId", "type": "str"}, + } + + def __init__(self, *, project_number: Optional[str] = None, project_id: Optional[str] = None, **kwargs): + """ + :keyword project_number: The unique GCP Project number. + :paramtype project_number: str + :keyword project_id: The GCP Project id. + :paramtype project_id: str + """ + super().__init__(**kwargs) + self.project_number = project_number + self.project_id = project_id + self.workload_identity_pool_id = None + + +class GcpProjectEnvironmentData(EnvironmentData): + """The GCP project connector environment data. + + All required parameters must be populated in order to send to Azure. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". + :vartype environment_type: str or + ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentType + :ivar organizational_data: The Gcp project's organizational data. + :vartype organizational_data: + ~azure.mgmt.security.v2022_08_01_preview.models.GcpOrganizationalData + :ivar project_details: The Gcp project's details. + :vartype project_details: ~azure.mgmt.security.v2022_08_01_preview.models.GcpProjectDetails + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + "organizational_data": {"key": "organizationalData", "type": "GcpOrganizationalData"}, + "project_details": {"key": "projectDetails", "type": "GcpProjectDetails"}, + } + + def __init__( + self, + *, + organizational_data: Optional["_models.GcpOrganizationalData"] = None, + project_details: Optional["_models.GcpProjectDetails"] = None, + **kwargs + ): + """ + :keyword organizational_data: The Gcp project's organizational data. + :paramtype organizational_data: + ~azure.mgmt.security.v2022_08_01_preview.models.GcpOrganizationalData + :keyword project_details: The Gcp project's details. + :paramtype project_details: ~azure.mgmt.security.v2022_08_01_preview.models.GcpProjectDetails + """ + super().__init__(**kwargs) + self.environment_type = "GcpProject" # type: str + self.organizational_data = organizational_data + self.project_details = project_details + + +class GithubScopeEnvironmentData(EnvironmentData): + """The github scope connector's environment data. + + All required parameters must be populated in order to send to Azure. + + :ivar environment_type: The type of the environment data. Required. Known values are: + "AwsAccount", "GcpProject", "GithubScope", and "AzureDevOpsScope". + :vartype environment_type: str or + ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentType + """ + + _validation = { + "environment_type": {"required": True}, + } + + _attribute_map = { + "environment_type": {"key": "environmentType", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.environment_type = "GithubScope" # type: str + + +class InformationProtectionAwsOffering(CloudOffering): + """The information protection for AWS offering. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar offering_type: The type of the security offering. Required. Known values are: + "CspmMonitorAws", "DefenderForContainersAws", "DefenderForServersAws", + "DefenderForDatabasesAws", "InformationProtectionAws", "CspmMonitorGcp", "CspmMonitorGithub", + "CspmMonitorAzureDevOps", "DefenderForServersGcp", "DefenderForContainersGcp", + "DefenderForDatabasesGcp", "DefenderCspmAws", "DefenderCspmGcp", "DefenderForDevOpsGithub", and + "DefenderForDevOpsAzureDevOps". + :vartype offering_type: str or ~azure.mgmt.security.v2022_08_01_preview.models.OfferingType + :ivar description: The offering description. + :vartype description: str + :ivar information_protection: The native cloud connection configuration. + :vartype information_protection: + ~azure.mgmt.security.v2022_08_01_preview.models.InformationProtectionAwsOfferingInformationProtection + """ + + _validation = { + "offering_type": {"required": True}, + "description": {"readonly": True}, + } + + _attribute_map = { + "offering_type": {"key": "offeringType", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "information_protection": { + "key": "informationProtection", + "type": "InformationProtectionAwsOfferingInformationProtection", + }, + } + + def __init__( + self, + *, + information_protection: Optional["_models.InformationProtectionAwsOfferingInformationProtection"] = None, + **kwargs + ): + """ + :keyword information_protection: The native cloud connection configuration. + :paramtype information_protection: + ~azure.mgmt.security.v2022_08_01_preview.models.InformationProtectionAwsOfferingInformationProtection + """ + super().__init__(**kwargs) + self.offering_type = "InformationProtectionAws" # type: str + self.information_protection = information_protection + + +class InformationProtectionAwsOfferingInformationProtection(_serialization.Model): + """The native cloud connection configuration. + + :ivar cloud_role_arn: The cloud role ARN in AWS for this feature. + :vartype cloud_role_arn: str + """ + + _attribute_map = { + "cloud_role_arn": {"key": "cloudRoleArn", "type": "str"}, + } + + def __init__(self, *, cloud_role_arn: Optional[str] = None, **kwargs): + """ + :keyword cloud_role_arn: The cloud role ARN in AWS for this feature. + :paramtype cloud_role_arn: str + """ + super().__init__(**kwargs) + self.cloud_role_arn = cloud_role_arn + + +class Kind(_serialization.Model): + """Describes an Azure resource with kind. + + :ivar kind: Kind of the resource. + :vartype kind: str + """ + + _attribute_map = { + "kind": {"key": "kind", "type": "str"}, + } + + def __init__(self, *, kind: Optional[str] = None, **kwargs): + """ + :keyword kind: Kind of the resource. + :paramtype kind: str + """ + super().__init__(**kwargs) + self.kind = kind + + +class Resource(_serialization.Model): + """Describes an Azure resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class Tags(_serialization.Model): + """A list of key value pairs that describe the resource. + + :ivar tags: A list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + """ + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + } + + def __init__(self, *, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: A list of key value pairs that describe the resource. + :paramtype tags: dict[str, str] + """ + super().__init__(**kwargs) + self.tags = tags + + +class TrackedResource(Resource, AzureTrackedResourceLocation, Kind, ETag, Tags): + """Describes an Azure tracked resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: A list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + :ivar etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :vartype etag: str + :ivar kind: Kind of the resource. + :vartype kind: str + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + kind: Optional[str] = None, + location: Optional[str] = None, + **kwargs + ): + """ + :keyword tags: A list of key value pairs that describe the resource. + :paramtype tags: dict[str, str] + :keyword etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :paramtype etag: str + :keyword kind: Kind of the resource. + :paramtype kind: str + :keyword location: Location where the resource is stored. + :paramtype location: str + """ + super().__init__(location=location, kind=kind, etag=etag, tags=tags, **kwargs) + self.tags = tags + self.etag = etag + self.kind = kind + self.location = location + self.id = None + self.name = None + self.type = None + + +class SecurityConnector(TrackedResource): # pylint: disable=too-many-instance-attributes + """The security connector resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tags: A list of key value pairs that describe the resource. + :vartype tags: dict[str, str] + :ivar etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :vartype etag: str + :ivar kind: Kind of the resource. + :vartype kind: str + :ivar location: Location where the resource is stored. + :vartype location: str + :ivar id: Resource Id. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy + information. + :vartype system_data: ~azure.mgmt.security.v2022_08_01_preview.models.SystemData + :ivar hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS + connector, project number in case of GCP connector). + :vartype hierarchy_identifier: str + :ivar hierarchy_identifier_trial_end_date: The date on which the trial period will end, if + applicable. Trial period exists for 30 days after upgrading to payed offerings. + :vartype hierarchy_identifier_trial_end_date: ~datetime.datetime + :ivar environment_name: The multi cloud resource's cloud name. Known values are: "Azure", + "AWS", "GCP", "Github", and "AzureDevOps". + :vartype environment_name: str or ~azure.mgmt.security.v2022_08_01_preview.models.CloudName + :ivar offerings: A collection of offerings for the security connector. + :vartype offerings: list[~azure.mgmt.security.v2022_08_01_preview.models.CloudOffering] + :ivar environment_data: The security connector environment data. + :vartype environment_data: ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentData + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "hierarchy_identifier_trial_end_date": {"readonly": True}, + } + + _attribute_map = { + "tags": {"key": "tags", "type": "{str}"}, + "etag": {"key": "etag", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "hierarchy_identifier": {"key": "properties.hierarchyIdentifier", "type": "str"}, + "hierarchy_identifier_trial_end_date": { + "key": "properties.hierarchyIdentifierTrialEndDate", + "type": "iso-8601", + }, + "environment_name": {"key": "properties.environmentName", "type": "str"}, + "offerings": {"key": "properties.offerings", "type": "[CloudOffering]"}, + "environment_data": {"key": "properties.environmentData", "type": "EnvironmentData"}, + } + + def __init__( + self, + *, + tags: Optional[Dict[str, str]] = None, + etag: Optional[str] = None, + kind: Optional[str] = None, + location: Optional[str] = None, + hierarchy_identifier: Optional[str] = None, + environment_name: Optional[Union[str, "_models.CloudName"]] = None, + offerings: Optional[List["_models.CloudOffering"]] = None, + environment_data: Optional["_models.EnvironmentData"] = None, + **kwargs + ): + """ + :keyword tags: A list of key value pairs that describe the resource. + :paramtype tags: dict[str, str] + :keyword etag: Entity tag is used for comparing two or more entities from the same requested + resource. + :paramtype etag: str + :keyword kind: Kind of the resource. + :paramtype kind: str + :keyword location: Location where the resource is stored. + :paramtype location: str + :keyword hierarchy_identifier: The multi cloud resource identifier (account id in case of AWS + connector, project number in case of GCP connector). + :paramtype hierarchy_identifier: str + :keyword environment_name: The multi cloud resource's cloud name. Known values are: "Azure", + "AWS", "GCP", "Github", and "AzureDevOps". + :paramtype environment_name: str or ~azure.mgmt.security.v2022_08_01_preview.models.CloudName + :keyword offerings: A collection of offerings for the security connector. + :paramtype offerings: list[~azure.mgmt.security.v2022_08_01_preview.models.CloudOffering] + :keyword environment_data: The security connector environment data. + :paramtype environment_data: ~azure.mgmt.security.v2022_08_01_preview.models.EnvironmentData + """ + super().__init__(tags=tags, etag=etag, kind=kind, location=location, **kwargs) + self.system_data = None + self.hierarchy_identifier = hierarchy_identifier + self.hierarchy_identifier_trial_end_date = None + self.environment_name = environment_name + self.offerings = offerings + self.environment_data = environment_data + + +class SecurityConnectorsList(_serialization.Model): + """List of security connectors response. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar value: The list of security connectors under the given scope. Required. + :vartype value: list[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] + :ivar next_link: The URI to fetch the next page. + :vartype next_link: str + """ + + _validation = { + "value": {"required": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SecurityConnector]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, *, value: List["_models.SecurityConnector"], **kwargs): + """ + :keyword value: The list of security connectors under the given scope. Required. + :paramtype value: list[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] + """ + super().__init__(**kwargs) + self.value = value + 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.security.v2022_08_01_preview.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.security.v2022_08_01_preview.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 + ): + """ + :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.security.v2022_08_01_preview.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.security.v2022_08_01_preview.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 diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_security_center_enums.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_security_center_enums.py new file mode 100644 index 000000000000..dfcd185f366a --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/models/_security_center_enums.py @@ -0,0 +1,85 @@ +# 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 enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class CloudName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The multi cloud resource's cloud name.""" + + AZURE = "Azure" + AWS = "AWS" + GCP = "GCP" + GITHUB = "Github" + AZURE_DEV_OPS = "AzureDevOps" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class EnvironmentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the environment data.""" + + AWS_ACCOUNT = "AwsAccount" + GCP_PROJECT = "GcpProject" + GITHUB_SCOPE = "GithubScope" + AZURE_DEV_OPS_SCOPE = "AzureDevOpsScope" + + +class OfferingType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of the security offering.""" + + CSPM_MONITOR_AWS = "CspmMonitorAws" + DEFENDER_FOR_CONTAINERS_AWS = "DefenderForContainersAws" + DEFENDER_FOR_SERVERS_AWS = "DefenderForServersAws" + DEFENDER_FOR_DATABASES_AWS = "DefenderForDatabasesAws" + INFORMATION_PROTECTION_AWS = "InformationProtectionAws" + CSPM_MONITOR_GCP = "CspmMonitorGcp" + CSPM_MONITOR_GITHUB = "CspmMonitorGithub" + CSPM_MONITOR_AZURE_DEV_OPS = "CspmMonitorAzureDevOps" + DEFENDER_FOR_SERVERS_GCP = "DefenderForServersGcp" + DEFENDER_FOR_CONTAINERS_GCP = "DefenderForContainersGcp" + DEFENDER_FOR_DATABASES_GCP = "DefenderForDatabasesGcp" + DEFENDER_CSPM_AWS = "DefenderCspmAws" + DEFENDER_CSPM_GCP = "DefenderCspmGcp" + DEFENDER_FOR_DEV_OPS_GITHUB = "DefenderForDevOpsGithub" + DEFENDER_FOR_DEV_OPS_AZURE_DEV_OPS = "DefenderForDevOpsAzureDevOps" + + +class OrganizationMembershipType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The multi cloud account's membership type in the organization.""" + + MEMBER = "Member" + ORGANIZATION = "Organization" + + +class ScanningMode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The scanning mode for the vm scan.""" + + DEFAULT = "Default" + + +class SubPlan(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The available sub plans.""" + + P1 = "P1" + P2 = "P2" + + +class Type(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Vulnerability Assessment solution to be provisioned. Can be either 'TVM' or 'Qualys'.""" + + QUALYS = "Qualys" + TVM = "TVM" diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/__init__.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/__init__.py new file mode 100644 index 000000000000..4660a96abf0f --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._security_connectors_operations import SecurityConnectorsOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "SecurityConnectorsOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_patch.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_security_connectors_operations.py b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_security_connectors_operations.py new file mode 100644 index 000000000000..908cc9cbd6fd --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/operations/_security_connectors_operations.py @@ -0,0 +1,858 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_list_by_resource_group_request(resource_group_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_request( + resource_group_name: str, security_connector_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_create_or_update_request( + resource_group_name: str, security_connector_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, security_connector_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, security_connector_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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url( + "subscription_id", subscription_id, "str", pattern=r"^[0-9A-Fa-f]{8}-([0-9A-Fa-f]{4}-){3}[0-9A-Fa-f]{12}$" + ), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "securityConnectorName": _SERIALIZER.url("security_connector_name", security_connector_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class SecurityConnectorsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.security.v2022_08_01_preview.SecurityCenter`'s + :attr:`security_connectors` 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(self, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: + """Lists all the security connectors in the specified subscription. Use the 'nextLink' property in + the response to get the next page of security connectors for the specified subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SecurityConnector or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Security/securityConnectors"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.SecurityConnector"]: + """Lists all the security connectors in the specified resource group. Use the 'nextLink' property + in the response to get the next page of security connectors for the specified resource group. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. 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 SecurityConnector or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnectorsList] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("SecurityConnectorsList", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, security_connector_name: str, **kwargs: Any) -> _models.SecurityConnector: + """Retrieves details of a specific security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] + + request = build_get_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: IO + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO], + **kwargs: Any + ) -> _models.SecurityConnector: + """Creates or updates a security connector. If a security connector is already created and a + subsequent request is issued for the same security connector id, then it will be updated. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a model type or a IO + type. Required. + :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector 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 + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IO, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: _models.SecurityConnector, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Required. + :type security_connector: IO + :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: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + security_connector_name: str, + security_connector: Union[_models.SecurityConnector, IO], + **kwargs: Any + ) -> _models.SecurityConnector: + """Updates a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_name: str + :param security_connector: The security connector resource. Is either a model type or a IO + type. Required. + :type security_connector: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector 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 + :return: SecurityConnector or the result of cls(response) + :rtype: ~azure.mgmt.security.v2022_08_01_preview.models.SecurityConnector + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.SecurityConnector] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(security_connector, (IO, bytes)): + _content = security_connector + else: + _json = self._serialize.body(security_connector, "SecurityConnector") + + request = build_update_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("SecurityConnector", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, security_connector_name: str, **kwargs: Any + ) -> None: + """Deletes a security connector. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param security_connector_name: The security connector name. Required. + :type security_connector_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 = { + 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 = kwargs.pop( + "api_version", _params.pop("api-version", "2022-08-01-preview") + ) # type: Literal["2022-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + security_connector_name=security_connector_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Security/securityConnectors/{securityConnectorName}"} # type: ignore diff --git a/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/py.typed b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/security/azure-mgmt-security/azure/mgmt/security/v2022_08_01_preview/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/security/azure-mgmt-security/setup.py b/sdk/security/azure-mgmt-security/setup.py index d4e819cf19b1..d30c70caf9f2 100644 --- a/sdk/security/azure-mgmt-security/setup.py +++ b/sdk/security/azure-mgmt-security/setup.py @@ -55,6 +55,7 @@ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'License :: OSI Approved :: MIT License', ], zip_safe=False, @@ -69,9 +70,10 @@ 'pytyped': ['py.typed'], }, install_requires=[ - 'msrest>=0.7.1', - 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.2,<2.0.0', + "msrest>=0.7.1", + "azure-common~=1.1", + "azure-mgmt-core>=1.3.2,<2.0.0", + "typing-extensions>=4.3.0; python_version<'3.8.0'", ], python_requires=">=3.7" ) diff --git a/shared_requirements.txt b/shared_requirements.txt index 8c88df504850..72e3c8d1006f 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -673,6 +673,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-datalake-analytics msrest>=0.6.21 #override azure-mgmt-iothubprovisioningservices typing-extensions>=4.3.0; python_version<'3.8.0' #override azure-mgmt-datalake-analytics azure-mgmt-core>=1.3.1,<2.0.0 +#override azure-mgmt-security typing-extensions>=4.3.0; python_version<'3.8.0' #override azure-mgmt-datalake-store msrest>=0.7.1 #override azure-mgmt-operationsmanagement msrest>=0.7.1 #override azure-mgmt-compute typing-extensions>=4.3.0; python_version<'3.8.0' From d7426ceba517dd53e04c297906ba15922054bca9 Mon Sep 17 00:00:00 2001 From: Zhengfei Wang <38847871+zhengfeiwang@users.noreply.github.com> Date: Thu, 17 Nov 2022 11:06:46 +0800 Subject: [PATCH 6/7] [ML][Pipelines] Enable AutoML DSL tests (#27453) * test: enable AutoML DSL tests * test: add missing recordings * test: update recording using twice upload * test: add variables for compute --- .../dsl/e2etests/test_automl_dsl_pipeline.py | 126 ++-- ...est_automl_classification_in_pipeline.json | 583 +++++++++++++++++ ...netest_automl_forecasting_in_pipeline.json | 409 ++++++++++++ ...inetest_automl_regression_in_pipeline.json | 397 ++++++++++++ ...utoml_text_classification_in_pipeline.json | 575 ++++++++++++++++ ...classification_multilabel_in_pipeline.json | 569 ++++++++++++++++ ...elinetest_automl_text_ner_in_pipeline.json | 557 ++++++++++++++++ ...ml_vision_multiclass_node_in_pipeline.json | 611 ++++++++++++++++++ ...ml_vision_multilabel_node_in_pipeline.json | 611 ++++++++++++++++++ ...est_automl_vision_od_node_in_pipeline.json | 611 ++++++++++++++++++ ..._vision_segmentation_node_in_pipeline.json | 601 +++++++++++++++++ 11 files changed, 5592 insertions(+), 58 deletions(-) create mode 100644 sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_classification_in_pipeline.json create mode 100644 sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_forecasting_in_pipeline.json create mode 100644 sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_regression_in_pipeline.json create mode 100644 sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_classification_in_pipeline.json create mode 100644 sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_classification_multilabel_in_pipeline.json create mode 100644 sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_ner_in_pipeline.json create mode 100644 sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_multiclass_node_in_pipeline.json create mode 100644 sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_multilabel_node_in_pipeline.json create mode 100644 sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_od_node_in_pipeline.json create mode 100644 sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_segmentation_node_in_pipeline.json diff --git a/sdk/ml/azure-ai-ml/tests/dsl/e2etests/test_automl_dsl_pipeline.py b/sdk/ml/azure-ai-ml/tests/dsl/e2etests/test_automl_dsl_pipeline.py index 9b52d5f35068..36232fa0aa2a 100644 --- a/sdk/ml/azure-ai-ml/tests/dsl/e2etests/test_automl_dsl_pipeline.py +++ b/sdk/ml/azure-ai-ml/tests/dsl/e2etests/test_automl_dsl_pipeline.py @@ -2,7 +2,6 @@ import pydash import pytest -from test_utilities.utils import assert_final_job_status from azure.ai.ml import Input, MLClient, automl, dsl from azure.ai.ml.automl import ( @@ -16,24 +15,33 @@ from azure.ai.ml.constants._common import AssetTypes from azure.ai.ml.entities import PipelineJob from azure.ai.ml.entities._job.automl import SearchSpace -from azure.ai.ml.entities._job.automl.image import ImageClassificationSearchSpace, ImageObjectDetectionSearchSpace from azure.ai.ml.entities._job.automl.nlp import NlpFeaturizationSettings from azure.ai.ml.entities._job.automl.tabular import TabularFeaturizationSettings from azure.ai.ml.entities._job.automl.tabular.forecasting_settings import ForecastingSettings -from azure.ai.ml.operations._run_history_constants import JobStatus from azure.ai.ml.sweep import BanditPolicy, Choice, Uniform from devtools_testutils import AzureRecordedTestCase +from test_utilities.utils import cancel_job tests_root_dir = Path(__file__).parent.parent.parent +# declare variables for compute, so that we can easily change them later +CPU_CLUSTER = "cpu-cluster" +GPU_CLUSTER = "gpu-cluster" + +@pytest.mark.usefixtures( + "enable_environment_id_arm_expansion", + "enable_pipeline_private_preview_features", + "mock_code_hash", + "mock_component_hash", + "recorded_test", +) @pytest.mark.automle2etest -@pytest.mark.skip(reason="migration skip: gpu-cluster is not available yet.") @pytest.mark.pipeline_test class TestAutomlDSLPipeline(AzureRecordedTestCase): def test_automl_classification_in_pipeline(self, client: MLClient): - @dsl.pipeline(name="train_automl_classification_in_pipeline", default_compute_target="automl-cpu-cluster") + @dsl.pipeline(name="train_automl_classification_in_pipeline") def train_automl_classification_in_pipeline( class_train_data, class_valid_data, @@ -59,9 +67,10 @@ def train_automl_classification_in_pipeline( ) pipeline_job: PipelineJob = train_automl_classification_in_pipeline(class_train, class_valid) + pipeline_job.settings.default_compute = CPU_CLUSTER from_rest_pipeline_job = client.jobs.create_or_update(pipeline_job) - assert_final_job_status(from_rest_pipeline_job, client, PipelineJob, JobStatus.COMPLETED) + cancel_job(client, from_rest_pipeline_job) actual_dict = from_rest_pipeline_job._to_rest_object().as_dict() fields_to_omit = ["name", "display_name", "experiment_name", "properties"] @@ -78,17 +87,13 @@ def train_automl_classification_in_pipeline( "log_verbosity": "info", "limits": {"max_trials": 1}, "featurization": {"mode": "auto"}, - "training": { - "enable_model_explainability": True, - "enable_stack_ensemble": False, - "enable_vote_ensemble": False, - }, + "training": {"enable_stack_ensemble": False, "enable_vote_ensemble": False}, "task": "classification", "primary_metric": "accuracy", } def test_automl_regression_in_pipeline(self, client: MLClient): - @dsl.pipeline(name="train_automl_regression_in_pipeline", default_compute_target="automl-cpu-cluster") + @dsl.pipeline(name="train_automl_regression_in_pipeline") def train_automl_regression_in_pipeline(regression_train_data): regression_node = regression( primary_metric="r2_score", @@ -105,9 +110,10 @@ def train_automl_regression_in_pipeline(regression_train_data): ) pipeline_job: PipelineJob = train_automl_regression_in_pipeline(regression_train) + pipeline_job.settings.default_compute = CPU_CLUSTER from_rest_pipeline_job = client.jobs.create_or_update(pipeline_job) - assert_final_job_status(from_rest_pipeline_job, client, PipelineJob, JobStatus.COMPLETED) + cancel_job(client, from_rest_pipeline_job) actual_dict = from_rest_pipeline_job._to_rest_object().as_dict() fields_to_omit = ["name", "display_name", "experiment_name", "properties"] @@ -122,17 +128,13 @@ def train_automl_regression_in_pipeline(regression_train_data): "log_verbosity": "info", "limits": {"max_trials": 1}, "featurization": {"mode": "auto"}, - "training": { - "enable_model_explainability": True, - "enable_stack_ensemble": False, - "enable_vote_ensemble": False, - }, + "training": {"enable_stack_ensemble": False, "enable_vote_ensemble": False}, "task": "regression", "primary_metric": "r2_score", } def test_automl_forecasting_in_pipeline(self, client: MLClient): - @dsl.pipeline(name="train_with_automl_in_pipeline", default_compute_target="automl-cpu-cluster") + @dsl.pipeline(name="train_with_automl_in_pipeline") def train_automl_forecasting_in_pipeline( forecasting_train_data, ): @@ -155,9 +157,10 @@ def train_automl_forecasting_in_pipeline( ) pipeline_job: PipelineJob = train_automl_forecasting_in_pipeline(forecasting_train_data=forecasting_train) + pipeline_job.settings.default_compute = CPU_CLUSTER from_rest_pipeline_job = client.jobs.create_or_update(pipeline_job) - assert_final_job_status(from_rest_pipeline_job, client, PipelineJob, JobStatus.COMPLETED) + cancel_job(client, from_rest_pipeline_job) actual_dict = from_rest_pipeline_job._to_rest_object().as_dict() fields_to_omit = ["name", "display_name", "experiment_name", "properties"] @@ -173,18 +176,14 @@ def train_automl_forecasting_in_pipeline( "log_verbosity": "info", "limits": {"max_trials": 1}, "featurization": {"mode": "auto"}, - "training": { - "enable_model_explainability": True, - "enable_stack_ensemble": False, - "enable_vote_ensemble": False, - }, + "training": {"enable_stack_ensemble": False, "enable_vote_ensemble": False}, "task": "forecasting", "forecasting": {"forecast_horizon": 12, "time_column_name": "DATE", "frequency": "MS"}, "primary_metric": "normalized_root_mean_squared_error", } def test_automl_text_classification_in_pipeline(self, client: MLClient): - @dsl.pipeline(name="train_automl_text_class_in_pipeline", default_compute_target="gpu-cluster") + @dsl.pipeline(name="train_automl_text_class_in_pipeline") def train_automl_text_class_in_pipeline( text_classification_train, text_classification_valid, @@ -210,8 +209,9 @@ def train_automl_text_class_in_pipeline( pipeline_job: PipelineJob = train_automl_text_class_in_pipeline( text_classification_train, text_classification_valid ) + pipeline_job.settings.default_compute = GPU_CLUSTER from_rest_pipeline_job = client.jobs.create_or_update(pipeline_job) - assert_final_job_status(from_rest_pipeline_job, client, PipelineJob, JobStatus.COMPLETED) + cancel_job(client, from_rest_pipeline_job) actual_dict = from_rest_pipeline_job._to_rest_object().as_dict() fields_to_omit = ["name", "display_name", "experiment_name", "properties"] @@ -224,14 +224,14 @@ def train_automl_text_class_in_pipeline( "tags": {}, "type": "automl", "outputs": {}, - "limits": {"max_trials": 1, "max_concurrent_trials": 1}, + "limits": {"max_trials": 1, "max_nodes": 1, "max_concurrent_trials": 1}, "featurization": {"dataset_language": "eng"}, "task": "text_classification", "primary_metric": "accuracy", } def test_automl_text_classification_multilabel_in_pipeline(self, client: MLClient): - @dsl.pipeline(name="train_automl_text_class_multilabel_in_pipeline", default_compute_target="gpu-cluster") + @dsl.pipeline(name="train_automl_text_class_multilabel_in_pipeline") def train_automl_text_class_multilabel_in_pipeline( text_classification_multilabel_train, text_classification_multilabel_valid, @@ -257,8 +257,9 @@ def train_automl_text_class_multilabel_in_pipeline( pipeline_job: PipelineJob = train_automl_text_class_multilabel_in_pipeline( text_classification_multilabel_train, text_classification_multilabel_valid ) + pipeline_job.settings.default_compute = GPU_CLUSTER from_rest_pipeline_job = client.jobs.create_or_update(pipeline_job) - assert_final_job_status(from_rest_pipeline_job, client, PipelineJob, JobStatus.COMPLETED) + cancel_job(client, from_rest_pipeline_job) actual_dict = from_rest_pipeline_job._to_rest_object().as_dict() fields_to_omit = ["name", "display_name", "experiment_name", "properties"] @@ -271,13 +272,13 @@ def train_automl_text_class_multilabel_in_pipeline( "tags": {}, "type": "automl", "outputs": {}, - "limits": {"max_trials": 1, "max_concurrent_trials": 1}, + "limits": {"max_trials": 1, "max_nodes": 1, "max_concurrent_trials": 1}, "task": "text_classification_multilabel", "primary_metric": "accuracy", } def test_automl_text_ner_in_pipeline(self, client: MLClient): - @dsl.pipeline(name="train_automl_text_ner_in_pipeline", default_compute_target="gpu-cluster") + @dsl.pipeline(name="train_automl_text_ner_in_pipeline") def train_automl_text_ner_in_pipeline( text_ner_train, text_ner_valid, @@ -300,8 +301,9 @@ def train_automl_text_ner_in_pipeline( ) pipeline_job: PipelineJob = train_automl_text_ner_in_pipeline(text_ner_train, text_ner_valid) + pipeline_job.settings.default_compute = GPU_CLUSTER from_rest_pipeline_job = client.jobs.create_or_update(pipeline_job) - assert_final_job_status(from_rest_pipeline_job, client, PipelineJob, JobStatus.COMPLETED) + cancel_job(client, from_rest_pipeline_job) actual_dict = from_rest_pipeline_job._to_rest_object().as_dict() fields_to_omit = ["name", "display_name", "experiment_name", "properties"] @@ -314,13 +316,13 @@ def train_automl_text_ner_in_pipeline( "tags": {}, "type": "automl", "outputs": {}, - "limits": {"max_trials": 1, "max_concurrent_trials": 1}, + "limits": {"max_trials": 1, "max_nodes": 1, "max_concurrent_trials": 1}, "task": "text_ner", "primary_metric": "accuracy", } def test_automl_vision_multiclass_node_in_pipeline(self, client: MLClient): - @dsl.pipeline(name="train_multiclass_with_automl_in_pipeline", default_compute_target="gpu-cluster") + @dsl.pipeline(name="train_multiclass_with_automl_in_pipeline") def train_multiclass_with_automl_in_pipeline( image_multiclass_train_data, image_multiclass_valid_data, @@ -347,11 +349,13 @@ def train_multiclass_with_automl_in_pipeline( ] ) image_multiclass_node.set_sweep( - max_trials=1, - max_concurrent_trials=1, sampling_algorithm="Random", early_termination=BanditPolicy(evaluation_interval=2, slack_factor=0.2, delay_evaluation=6), ) + image_multiclass_node.set_limits( + max_trials=1, + max_concurrent_trials=1, + ) multiclass_train = Input( type=AssetTypes.MLTABLE, @@ -363,16 +367,17 @@ def train_multiclass_with_automl_in_pipeline( ) pipeline_job: PipelineJob = train_multiclass_with_automl_in_pipeline(multiclass_train, multiclass_valid) + pipeline_job.settings.default_compute = GPU_CLUSTER from_rest_pipeline_job = client.jobs.create_or_update(pipeline_job) - assert_final_job_status(from_rest_pipeline_job, client, PipelineJob, JobStatus.COMPLETED) + cancel_job(client, from_rest_pipeline_job) actual_dict = from_rest_pipeline_job._to_rest_object().as_dict() fields_to_omit = ["name", "display_name", "experiment_name", "properties"] image_multiclass_dict = pydash.omit(actual_dict["properties"]["jobs"]["image_multiclass_node"], fields_to_omit) assert image_multiclass_dict == { - "limits": {"timeout_minutes": 60}, + "limits": {"max_concurrent_trials": 1, "max_trials": 1, "timeout_minutes": 60}, "log_verbosity": "info", "outputs": {}, "primary_metric": "accuracy", @@ -384,7 +389,6 @@ def train_multiclass_with_automl_in_pipeline( "validation_data": "${{parent.inputs.image_multiclass_valid_data}}", "sweep": { "sampling_algorithm": "random", - "limits": {"max_concurrent_trials": 1, "max_trials": 1}, "early_termination": { "evaluation_interval": 2, "delay_evaluation": 6, @@ -406,7 +410,7 @@ def train_multiclass_with_automl_in_pipeline( } def test_automl_vision_multilabel_node_in_pipeline(self, client: MLClient): - @dsl.pipeline(name="train_multilabel_with_automl_in_pipeline", default_compute_target="gpu-cluster") + @dsl.pipeline(name="train_multilabel_with_automl_in_pipeline") def train_multilabel_with_automl_in_pipeline( image_multilabel_train_data, image_multilabel_valid_data, @@ -433,11 +437,13 @@ def train_multilabel_with_automl_in_pipeline( ] ) image_multilabel_node.set_sweep( - max_trials=1, - max_concurrent_trials=1, sampling_algorithm="Random", early_termination=BanditPolicy(evaluation_interval=2, slack_factor=0.2, delay_evaluation=6), ) + image_multilabel_node.set_limits( + max_trials=1, + max_concurrent_trials=1, + ) multilabel_train = Input( type=AssetTypes.MLTABLE, @@ -449,16 +455,17 @@ def train_multilabel_with_automl_in_pipeline( ) pipeline_job: PipelineJob = train_multilabel_with_automl_in_pipeline(multilabel_train, multilabel_valid) + pipeline_job.settings.default_compute = GPU_CLUSTER from_rest_pipeline_job = client.jobs.create_or_update(pipeline_job) - assert_final_job_status(from_rest_pipeline_job, client, PipelineJob, JobStatus.COMPLETED) + cancel_job(client, from_rest_pipeline_job) actual_dict = from_rest_pipeline_job._to_rest_object().as_dict() fields_to_omit = ["name", "display_name", "experiment_name", "properties"] image_multilabel_dict = pydash.omit(actual_dict["properties"]["jobs"]["image_multilabel_node"], fields_to_omit) assert image_multilabel_dict == { - "limits": {"timeout_minutes": 60}, + "limits": {"max_concurrent_trials": 1, "max_trials": 1, "timeout_minutes": 60}, "log_verbosity": "info", "outputs": {}, "primary_metric": "iou", @@ -470,7 +477,6 @@ def train_multilabel_with_automl_in_pipeline( "validation_data": "${{parent.inputs.image_multilabel_valid_data}}", "sweep": { "sampling_algorithm": "random", - "limits": {"max_concurrent_trials": 1, "max_trials": 1}, "early_termination": { "evaluation_interval": 2, "delay_evaluation": 6, @@ -492,7 +498,7 @@ def train_multilabel_with_automl_in_pipeline( } def test_automl_vision_od_node_in_pipeline(self, client: MLClient): - @dsl.pipeline(name="train_od_with_automl_in_pipeline", default_compute_target="gpu-cluster") + @dsl.pipeline(name="train_od_with_automl_in_pipeline") def train_od_with_automl_in_pipeline( image_object_detection_train_data, image_object_detection_valid_data, @@ -524,11 +530,13 @@ def train_od_with_automl_in_pipeline( timeout_minutes=60, ) image_object_detection_node.set_sweep( - max_trials=1, - max_concurrent_trials=1, sampling_algorithm="Random", early_termination=BanditPolicy(evaluation_interval=2, slack_factor=0.2, delay_evaluation=6), ) + image_object_detection_node.set_limits( + max_trials=1, + max_concurrent_trials=1, + ) object_detection_train = Input( type=AssetTypes.MLTABLE, @@ -540,9 +548,10 @@ def train_od_with_automl_in_pipeline( ) pipeline_job: PipelineJob = train_od_with_automl_in_pipeline(object_detection_train, object_detection_valid) + pipeline_job.settings.default_compute = GPU_CLUSTER from_rest_pipeline_job = client.jobs.create_or_update(pipeline_job) - assert_final_job_status(from_rest_pipeline_job, client, PipelineJob, JobStatus.COMPLETED) + cancel_job(client, from_rest_pipeline_job) actual_dict = from_rest_pipeline_job._to_rest_object().as_dict() fields_to_omit = ["name", "display_name", "experiment_name", "properties"] @@ -551,7 +560,7 @@ def train_od_with_automl_in_pipeline( actual_dict["properties"]["jobs"]["image_object_detection_node"], fields_to_omit ) assert image_object_detection_dict == { - "limits": {"timeout_minutes": 60}, + "limits": {"max_concurrent_trials": 1, "max_trials": 1, "timeout_minutes": 60}, "log_verbosity": "info", "outputs": {}, "primary_metric": "mean_average_precision", @@ -564,7 +573,6 @@ def train_od_with_automl_in_pipeline( "training_parameters": {"nms_iou_threshold": 0.7}, "sweep": { "sampling_algorithm": "random", - "limits": {"max_concurrent_trials": 1, "max_trials": 1}, "early_termination": { "evaluation_interval": 2, "delay_evaluation": 6, @@ -589,7 +597,7 @@ def train_od_with_automl_in_pipeline( } def test_automl_vision_segmentation_node_in_pipeline(self, client: MLClient): - @dsl.pipeline(name="train_with_automl_in_pipeline", default_compute_target="gpu-cluster") + @dsl.pipeline(name="train_with_automl_in_pipeline") def train_segmentation_with_automl_in_pipeline( image_instance_segmentation_train_data, image_instance_segmentation_valid_data, @@ -617,11 +625,13 @@ def train_segmentation_with_automl_in_pipeline( ) image_instance_segmentation_node.set_sweep( - max_trials=10, - max_concurrent_trials=2, sampling_algorithm="Random", early_termination=BanditPolicy(evaluation_interval=2, slack_factor=0.2, delay_evaluation=6), ) + image_instance_segmentation_node.set_limits( + max_trials=10, + max_concurrent_trials=2, + ) instance_segmentation_train = Input( type=AssetTypes.MLTABLE, @@ -635,9 +645,10 @@ def train_segmentation_with_automl_in_pipeline( pipeline_job: PipelineJob = train_segmentation_with_automl_in_pipeline( instance_segmentation_train, instance_segmentation_valid ) + pipeline_job.settings.default_compute = GPU_CLUSTER from_rest_pipeline_job = client.jobs.create_or_update(pipeline_job) - assert_final_job_status(from_rest_pipeline_job, client, PipelineJob, JobStatus.COMPLETED) + cancel_job(client, from_rest_pipeline_job) actual_dict = from_rest_pipeline_job._to_rest_object().as_dict() fields_to_omit = ["name", "display_name", "experiment_name", "properties"] @@ -646,7 +657,7 @@ def train_segmentation_with_automl_in_pipeline( actual_dict["properties"]["jobs"]["image_instance_segmentation_node"], fields_to_omit ) assert image_instance_segmentation_dict == { - "limits": {"timeout_minutes": 60}, + "limits": {"max_concurrent_trials": 2, "max_trials": 10, "timeout_minutes": 60}, "log_verbosity": "info", "outputs": {}, "primary_metric": "mean_average_precision", @@ -659,7 +670,6 @@ def train_segmentation_with_automl_in_pipeline( "training_parameters": {"nms_iou_threshold": 0.7}, "sweep": { "sampling_algorithm": "random", - "limits": {"max_concurrent_trials": 2, "max_trials": 10}, "early_termination": { "evaluation_interval": 2, "delay_evaluation": 6, diff --git a/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_classification_in_pipeline.json b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_classification_in_pipeline.json new file mode 100644 index 000000000000..adea7e300666 --- /dev/null +++ b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_classification_in_pipeline.json @@ -0,0 +1,583 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:39:08 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-7a97a10045e972b995afa0743ede999e-ae5cfdcb6f9c75d4-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "4b732853-de4c-4eac-946e-dff3e7e0dd77", + "x-ms-ratelimit-remaining-subscription-reads": "11989", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T083909Z:4b732853-de4c-4eac-946e-dff3e7e0dd77", + "x-request-time": "0.282" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:39:10 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-d11a43af59ccf0519aa4edb77ab1cc6d-9acc9124ecad027e-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "1c620b11-d1e8-49f5-885d-fe0763cc50cb", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T083910Z:1c620b11-d1e8-49f5-885d-fe0763cc50cb", + "x-request-time": "0.710" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:39:10 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "242", + "Content-MD5": "kmRcIQnGyx1Tyt/S3D45Mw==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 08:39:11 GMT", + "ETag": "\u00220x8DAC0887A711E95\u0022", + "Last-Modified": "Mon, 07 Nov 2022 06:22:42 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Mon, 07 Nov 2022 06:22:42 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "b2c15ee1-19a5-414f-b559-cca1e38bf3d3", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "26854fe0-e8cb-45cb-96c1-7797cc52f6ff", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:39:11 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 08:39:11 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:39:11 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-8237634e9810b591f13d6f0b06a07ec8-06968fe5e2b6cd8a-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "565a997e-8194-48c4-9b36-b2c4f3c8a153", + "x-ms-ratelimit-remaining-subscription-reads": "11988", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T083912Z:565a997e-8194-48c4-9b36-b2c4f3c8a153", + "x-request-time": "0.102" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:39:12 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-29ef40487b742f8b5cd29810f87ad090-56f7be29488b8bcd-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "b77b66b2-fc69-499c-ab39-b54da28f7995", + "x-ms-ratelimit-remaining-subscription-writes": "1198", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T083913Z:b77b66b2-fc69-499c-ab39-b54da28f7995", + "x-request-time": "0.157" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:39:13 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "245", + "Content-MD5": "7GKuyqO9jeUS5UVRWrgMSw==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 08:39:13 GMT", + "ETag": "\u00220x8DAC0887BD73110\u0022", + "Last-Modified": "Mon, 07 Nov 2022 06:22:45 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Mon, 07 Nov 2022 06:22:44 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "fd02d36f-5672-43f4-b8a4-9b4d58d0814a", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "3133b98b-688a-45ca-9f57-79a10262da2b", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:39:13 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 08:39:13 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "1270", + "Content-Type": "application/json", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": { + "properties": { + "properties": {}, + "tags": {}, + "displayName": "train_automl_classification_in_pipeline", + "experimentName": "azure-ai-ml", + "isArchived": false, + "jobType": "Pipeline", + "inputs": { + "class_train_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "jobInputType": "mltable" + }, + "class_valid_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "jobInputType": "mltable" + } + }, + "jobs": { + "classification_node": { + "name": "classification_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.class_train_data}}", + "limits": { + "max_trials": 1 + }, + "featurization": { + "mode": "auto" + }, + "target_column_name": "y", + "validation_data": "${{parent.inputs.class_valid_data}}", + "test_data": "${{parent.inputs.class_valid_data}}", + "task": "classification", + "primary_metric": "accuracy", + "training": { + "enable_stack_ensemble": false, + "enable_vote_ensemble": false + } + } + }, + "outputs": {}, + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/cpu-cluster", + "_source": "DSL" + } + } + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "3506", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:39:23 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-c8911a33a9907050cb3e3d57e53f7841-805e597e5ca50dc0-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "d2f60c8a-abe2-49f4-8a86-08ab751c2919", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T083924Z:d2f60c8a-abe2-49f4-8a86-08ab751c2919", + "x-request-time": "5.540" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000", + "name": "000000000000000000000", + "type": "Microsoft.MachineLearningServices/workspaces/jobs", + "properties": { + "description": null, + "tags": {}, + "properties": { + "azureml.DevPlatv2": "true", + "azureml.runsource": "azureml.PipelineRun", + "runSource": "MFE", + "runType": "HTTP", + "azureml.parameters": "{}", + "azureml.continue_on_step_failure": "False", + "azureml.continue_on_failed_optional_input": "True", + "azureml.defaultComputeName": "cpu-cluster", + "azureml.defaultDataStoreName": "workspaceblobstore", + "azureml.pipelineComponent": "pipelinerun" + }, + "displayName": "train_automl_classification_in_pipeline", + "status": "Preparing", + "experimentName": "azure-ai-ml", + "services": { + "Tracking": { + "jobServiceType": "Tracking", + "port": null, + "endpoint": "azureml://master.api.azureml-test.ms/mlflow/v1.0/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000?", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + }, + "Studio": { + "jobServiceType": "Studio", + "port": null, + "endpoint": "https://ml.azure.com/runs/000000000000000000000?wsid=/subscriptions/00000000-0000-0000-0000-000000000/resourcegroups/00000/workspaces/00000", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + } + }, + "computeId": null, + "isArchived": false, + "identity": null, + "componentId": null, + "jobType": "Pipeline", + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/cpu-cluster", + "_source": "DSL" + }, + "jobs": { + "classification_node": { + "name": "classification_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.class_train_data}}", + "limits": { + "max_trials": 1 + }, + "featurization": { + "mode": "auto" + }, + "target_column_name": "y", + "validation_data": "${{parent.inputs.class_valid_data}}", + "test_data": "${{parent.inputs.class_valid_data}}", + "task": "classification", + "primary_metric": "accuracy", + "training": { + "enable_stack_ensemble": false, + "enable_vote_ensemble": false + } + } + }, + "inputs": { + "class_train_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + }, + "class_valid_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + } + }, + "outputs": {}, + "sourceJobId": null + }, + "systemData": { + "createdAt": "2022-11-11T08:39:23.2661537\u002B00:00", + "createdBy": "Zhengfei Wang", + "createdByType": "User" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000/cancel?api-version=2022-10-01-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:39:26 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-async-operation-timeout": "PT1H", + "x-ms-correlation-request-id": "dcb68f18-17b0-4577-8a48-cfc25c578ad0", + "x-ms-ratelimit-remaining-subscription-writes": "1197", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T083927Z:dcb68f18-17b0-4577-8a48-cfc25c578ad0", + "x-request-time": "1.095" + }, + "ResponseBody": "null" + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Fri, 11 Nov 2022 08:39:57 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-6317efbf74adeac39735a70cbcc6846b-1730b5f49bfec36c-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "dca8f3b9-5c51-4ea8-887d-2389469da4df", + "x-ms-ratelimit-remaining-subscription-reads": "11987", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T083958Z:dca8f3b9-5c51-4ea8-887d-2389469da4df", + "x-request-time": "0.059" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_forecasting_in_pipeline.json b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_forecasting_in_pipeline.json new file mode 100644 index 000000000000..391cc85502a1 --- /dev/null +++ b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_forecasting_in_pipeline.json @@ -0,0 +1,409 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "1067", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 10:21:05 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-fcbcefcddabfdafc15af023fbae72885-69617bcc9aaa463e-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "be2b6998-3a89-42b9-a83a-6bdb0e7226f7", + "x-ms-ratelimit-remaining-subscription-reads": "11997", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T102105Z:be2b6998-3a89-42b9-a83a-6bdb0e7226f7", + "x-request-time": "0.104" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "61", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 10:21:05 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-aaad4aa8f97a66d53713db7e8644cb2e-5013f464a807029b-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "044c719c-24f6-4edf-88cd-65883e6eb10f", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T102106Z:044c719c-24f6-4edf-88cd-65883e6eb10f", + "x-request-time": "0.096" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 10:21:06 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "248", + "Content-MD5": "gzKXoPqTu85Rz1sGY4HgaA==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 10:21:06 GMT", + "ETag": "\u00220x8DAC3C167F06293\u0022", + "Last-Modified": "Fri, 11 Nov 2022 08:47:46 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Fri, 11 Nov 2022 08:47:46 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "185a700f-0f83-487a-9671-db3533cca68c", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "b342a12a-4218-4ba6-861e-96ceef3258b5", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 10:21:07 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 10:21:07 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "1150", + "Content-Type": "application/json", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": { + "properties": { + "properties": {}, + "tags": {}, + "displayName": "train_with_automl_in_pipeline", + "experimentName": "azure-ai-ml", + "isArchived": false, + "jobType": "Pipeline", + "inputs": { + "forecasting_train_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "jobInputType": "mltable" + } + }, + "jobs": { + "forecasting_node": { + "name": "forecasting_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.forecasting_train_data}}", + "limits": { + "max_trials": 1 + }, + "featurization": { + "mode": "auto" + }, + "target_column_name": "BeerProduction", + "n_cross_validations": 2, + "task": "forecasting", + "primary_metric": "normalized_root_mean_squared_error", + "training": { + "enable_stack_ensemble": false, + "enable_vote_ensemble": false + }, + "forecasting": { + "forecast_horizon": 12, + "time_column_name": "DATE", + "frequency": "MS" + } + } + }, + "outputs": {}, + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/cpu-cluster", + "_source": "DSL" + } + } + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "3334", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 10:21:15 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-b3bae4a67b8927c63b195575ce7cb11a-af150746a23f5694-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "f0993e53-f0a7-4a86-b87f-15cab9b98e45", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T102116Z:f0993e53-f0a7-4a86-b87f-15cab9b98e45", + "x-request-time": "4.158" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000", + "name": "000000000000000000000", + "type": "Microsoft.MachineLearningServices/workspaces/jobs", + "properties": { + "description": null, + "tags": {}, + "properties": { + "azureml.DevPlatv2": "true", + "azureml.runsource": "azureml.PipelineRun", + "runSource": "MFE", + "runType": "HTTP", + "azureml.parameters": "{}", + "azureml.continue_on_step_failure": "False", + "azureml.continue_on_failed_optional_input": "True", + "azureml.defaultComputeName": "cpu-cluster", + "azureml.defaultDataStoreName": "workspaceblobstore", + "azureml.pipelineComponent": "pipelinerun" + }, + "displayName": "train_with_automl_in_pipeline", + "status": "Preparing", + "experimentName": "azure-ai-ml", + "services": { + "Tracking": { + "jobServiceType": "Tracking", + "port": null, + "endpoint": "azureml://master.api.azureml-test.ms/mlflow/v1.0/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000?", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + }, + "Studio": { + "jobServiceType": "Studio", + "port": null, + "endpoint": "https://ml.azure.com/runs/000000000000000000000?wsid=/subscriptions/00000000-0000-0000-0000-000000000/resourcegroups/00000/workspaces/00000", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + } + }, + "computeId": null, + "isArchived": false, + "identity": null, + "componentId": null, + "jobType": "Pipeline", + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/cpu-cluster", + "_source": "DSL" + }, + "jobs": { + "forecasting_node": { + "name": "forecasting_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.forecasting_train_data}}", + "limits": { + "max_trials": 1 + }, + "featurization": { + "mode": "auto" + }, + "target_column_name": "BeerProduction", + "n_cross_validations": 2, + "task": "forecasting", + "primary_metric": "normalized_root_mean_squared_error", + "training": { + "enable_stack_ensemble": false, + "enable_vote_ensemble": false + }, + "forecasting": { + "forecast_horizon": 12, + "time_column_name": "DATE", + "frequency": "MS" + } + } + }, + "inputs": { + "forecasting_train_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + } + }, + "outputs": {}, + "sourceJobId": null + }, + "systemData": { + "createdAt": "2022-11-11T10:21:15.5742919\u002B00:00", + "createdBy": "Zhengfei Wang", + "createdByType": "User" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000/cancel?api-version=2022-10-01-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 10:21:19 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-async-operation-timeout": "PT1H", + "x-ms-correlation-request-id": "bdac8651-8345-4f1d-80bd-036f5f5a3840", + "x-ms-ratelimit-remaining-subscription-writes": "1198", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T102120Z:bdac8651-8345-4f1d-80bd-036f5f5a3840", + "x-request-time": "1.246" + }, + "ResponseBody": "null" + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Fri, 11 Nov 2022 10:21:50 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-7d0e8aefa877905f55a9300f30c06728-6e4fec7f96269748-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "ebacb505-dfa9-4ce9-81f5-c9a42cf97762", + "x-ms-ratelimit-remaining-subscription-reads": "11996", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T102150Z:ebacb505-dfa9-4ce9-81f5-c9a42cf97762", + "x-request-time": "0.060" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_regression_in_pipeline.json b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_regression_in_pipeline.json new file mode 100644 index 000000000000..e2cf5480cb82 --- /dev/null +++ b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_regression_in_pipeline.json @@ -0,0 +1,397 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "1067", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:45:34 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-fc685355ff884e630ad680d90db16f2f-fea559731cd95298-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "8e44c975-3a3e-45f0-af93-165257d068c9", + "x-ms-ratelimit-remaining-subscription-reads": "11998", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T084535Z:8e44c975-3a3e-45f0-af93-165257d068c9", + "x-request-time": "0.157" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "61", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:45:35 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-34a93d1dc8bc496a85c1a5091b33f8e1-b2df81d02901d003-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "037c3134-1cee-4b73-a974-6493e9a7b448", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T084536Z:037c3134-1cee-4b73-a974-6493e9a7b448", + "x-request-time": "0.109" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:45:36 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "234", + "Content-MD5": "FA\u002B3GvjhmFfSmdNQpxc/PA==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 08:45:37 GMT", + "ETag": "\u00220x8DAC3C0E43A00AF\u0022", + "Last-Modified": "Fri, 11 Nov 2022 08:44:05 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Fri, 11 Nov 2022 08:44:05 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "7728d1a8-8df1-4d79-9aae-673cd30d24c6", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "004d4490-ddea-448d-9c42-17127a4107ee", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:45:37 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 08:45:37 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "1000", + "Content-Type": "application/json", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": { + "properties": { + "properties": {}, + "tags": {}, + "displayName": "train_automl_regression_in_pipeline", + "experimentName": "azure-ai-ml", + "isArchived": false, + "jobType": "Pipeline", + "inputs": { + "regression_train_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "jobInputType": "mltable" + } + }, + "jobs": { + "regression_node": { + "name": "regression_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.regression_train_data}}", + "limits": { + "max_trials": 1 + }, + "featurization": { + "mode": "auto" + }, + "target_column_name": "ERP", + "task": "regression", + "primary_metric": "r2_score", + "training": { + "enable_stack_ensemble": false, + "enable_vote_ensemble": false + } + } + }, + "outputs": {}, + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/cpu-cluster", + "_source": "DSL" + } + } + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "3128", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:45:46 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-eb2f8bf789378d93206a9db22d7341b0-e5b5df86ed07389b-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "f67b21d1-8a4f-4ac8-9214-91cc24a68369", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T084546Z:f67b21d1-8a4f-4ac8-9214-91cc24a68369", + "x-request-time": "3.806" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000", + "name": "000000000000000000000", + "type": "Microsoft.MachineLearningServices/workspaces/jobs", + "properties": { + "description": null, + "tags": {}, + "properties": { + "azureml.DevPlatv2": "true", + "azureml.runsource": "azureml.PipelineRun", + "runSource": "MFE", + "runType": "HTTP", + "azureml.parameters": "{}", + "azureml.continue_on_step_failure": "False", + "azureml.continue_on_failed_optional_input": "True", + "azureml.defaultComputeName": "cpu-cluster", + "azureml.defaultDataStoreName": "workspaceblobstore", + "azureml.pipelineComponent": "pipelinerun" + }, + "displayName": "train_automl_regression_in_pipeline", + "status": "Preparing", + "experimentName": "azure-ai-ml", + "services": { + "Tracking": { + "jobServiceType": "Tracking", + "port": null, + "endpoint": "azureml://master.api.azureml-test.ms/mlflow/v1.0/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000?", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + }, + "Studio": { + "jobServiceType": "Studio", + "port": null, + "endpoint": "https://ml.azure.com/runs/000000000000000000000?wsid=/subscriptions/00000000-0000-0000-0000-000000000/resourcegroups/00000/workspaces/00000", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + } + }, + "computeId": null, + "isArchived": false, + "identity": null, + "componentId": null, + "jobType": "Pipeline", + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/cpu-cluster", + "_source": "DSL" + }, + "jobs": { + "regression_node": { + "name": "regression_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.regression_train_data}}", + "limits": { + "max_trials": 1 + }, + "featurization": { + "mode": "auto" + }, + "target_column_name": "ERP", + "task": "regression", + "primary_metric": "r2_score", + "training": { + "enable_stack_ensemble": false, + "enable_vote_ensemble": false + } + } + }, + "inputs": { + "regression_train_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + } + }, + "outputs": {}, + "sourceJobId": null + }, + "systemData": { + "createdAt": "2022-11-11T08:45:46.0950944\u002B00:00", + "createdBy": "Zhengfei Wang", + "createdByType": "User" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000/cancel?api-version=2022-10-01-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:45:49 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-async-operation-timeout": "PT1H", + "x-ms-correlation-request-id": "3597c7a9-980c-4a9a-9f82-7db29f4f55ae", + "x-ms-ratelimit-remaining-subscription-writes": "1198", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T084550Z:3597c7a9-980c-4a9a-9f82-7db29f4f55ae", + "x-request-time": "1.002" + }, + "ResponseBody": "null" + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Fri, 11 Nov 2022 08:46:21 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-4a98e7d623e181c236583dceb85a8d30-308bcf9f4b4d40c9-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "70f3b10e-c80f-4eec-8a41-e1bf25512d31", + "x-ms-ratelimit-remaining-subscription-reads": "11997", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T084621Z:70f3b10e-c80f-4eec-8a41-e1bf25512d31", + "x-request-time": "0.050" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_classification_in_pipeline.json b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_classification_in_pipeline.json new file mode 100644 index 000000000000..fc314ca9c193 --- /dev/null +++ b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_classification_in_pipeline.json @@ -0,0 +1,575 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:54:18 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-5dfb39d75928bbc3f3174ee6595e5ae6-d3c4be398dfe2246-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "06b87da1-a231-4d1e-9c67-2ee04c910c15", + "x-ms-ratelimit-remaining-subscription-reads": "11993", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085419Z:06b87da1-a231-4d1e-9c67-2ee04c910c15", + "x-request-time": "0.086" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:54:19 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-fbd650e6d7c5e52da1b587b4b85263d1-3dbac7f95c812740-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "8f34a27e-72e3-419d-a6aa-ee13af473a23", + "x-ms-ratelimit-remaining-subscription-writes": "1196", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085420Z:8f34a27e-72e3-419d-a6aa-ee13af473a23", + "x-request-time": "0.142" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:54:20 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "242", + "Content-MD5": "NqAcSUWnqc4P\u002B0m2TKgOyQ==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 08:54:21 GMT", + "ETag": "\u00220x8DAC3C1D2D92BD7\u0022", + "Last-Modified": "Fri, 11 Nov 2022 08:50:45 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Fri, 11 Nov 2022 08:50:45 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "f9221b52-1585-4f80-b16d-f0f0d47fce04", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "1eaac992-76d3-45ff-b97f-3376cfa3643a", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:54:21 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 08:54:21 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:54:21 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-6ff96ecd9ce2327d88464dfd8d69185d-a84a63dc1c77fa07-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "86704c62-25d1-4a9a-955f-1257fe647be6", + "x-ms-ratelimit-remaining-subscription-reads": "11992", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085422Z:86704c62-25d1-4a9a-955f-1257fe647be6", + "x-request-time": "0.113" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:54:22 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-0c342785cca5a90e45d6dc076133d394-e2aed475282fc48e-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "9dd18d25-8852-480a-b5c9-bb279d9c62d4", + "x-ms-ratelimit-remaining-subscription-writes": "1195", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085422Z:9dd18d25-8852-480a-b5c9-bb279d9c62d4", + "x-request-time": "0.099" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:54:22 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "242", + "Content-MD5": "dSNPUJ/1XJb7PLBObFnwjg==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 08:54:23 GMT", + "ETag": "\u00220x8DAC3C1D6CD7826\u0022", + "Last-Modified": "Fri, 11 Nov 2022 08:50:52 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Fri, 11 Nov 2022 08:50:52 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "e0ee4018-92a2-4764-911d-49cca8f6d285", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "bc3d7b81-5c9b-4b9b-b7bc-a82e4ea7e02c", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:54:23 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 08:54:23 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "1218", + "Content-Type": "application/json", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": { + "properties": { + "properties": {}, + "tags": {}, + "displayName": "train_automl_text_class_in_pipeline", + "experimentName": "azure-ai-ml", + "isArchived": false, + "jobType": "Pipeline", + "inputs": { + "text_classification_train": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "jobInputType": "mltable" + }, + "text_classification_valid": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "jobInputType": "mltable" + } + }, + "jobs": { + "text_classification_node": { + "name": "text_classification_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "training_data": "${{parent.inputs.text_classification_train}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "max_nodes": 1 + }, + "featurization": { + "dataset_language": "eng" + }, + "validation_data": "${{parent.inputs.text_classification_valid}}", + "task": "text_classification", + "primary_metric": "accuracy", + "target_column_name": "y" + } + }, + "outputs": {}, + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + } + } + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "3420", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:54:30 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-ee7c2ede093a91a9795177c92eb5554d-583ea3e7ba92730f-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "b20b2a20-8efa-4c50-8cd3-68895679ac60", + "x-ms-ratelimit-remaining-subscription-writes": "1198", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085431Z:b20b2a20-8efa-4c50-8cd3-68895679ac60", + "x-request-time": "3.367" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000", + "name": "000000000000000000000", + "type": "Microsoft.MachineLearningServices/workspaces/jobs", + "properties": { + "description": null, + "tags": {}, + "properties": { + "azureml.DevPlatv2": "true", + "azureml.runsource": "azureml.PipelineRun", + "runSource": "MFE", + "runType": "HTTP", + "azureml.parameters": "{}", + "azureml.continue_on_step_failure": "False", + "azureml.continue_on_failed_optional_input": "True", + "azureml.defaultComputeName": "gpu-cluster", + "azureml.defaultDataStoreName": "workspaceblobstore", + "azureml.pipelineComponent": "pipelinerun" + }, + "displayName": "train_automl_text_class_in_pipeline", + "status": "Preparing", + "experimentName": "azure-ai-ml", + "services": { + "Tracking": { + "jobServiceType": "Tracking", + "port": null, + "endpoint": "azureml://master.api.azureml-test.ms/mlflow/v1.0/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000?", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + }, + "Studio": { + "jobServiceType": "Studio", + "port": null, + "endpoint": "https://ml.azure.com/runs/000000000000000000000?wsid=/subscriptions/00000000-0000-0000-0000-000000000/resourcegroups/00000/workspaces/00000", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + } + }, + "computeId": null, + "isArchived": false, + "identity": null, + "componentId": null, + "jobType": "Pipeline", + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + }, + "jobs": { + "text_classification_node": { + "name": "text_classification_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "training_data": "${{parent.inputs.text_classification_train}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "max_nodes": 1 + }, + "featurization": { + "dataset_language": "eng" + }, + "validation_data": "${{parent.inputs.text_classification_valid}}", + "task": "text_classification", + "primary_metric": "accuracy", + "target_column_name": "y" + } + }, + "inputs": { + "text_classification_train": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + }, + "text_classification_valid": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + } + }, + "outputs": {}, + "sourceJobId": null + }, + "systemData": { + "createdAt": "2022-11-11T08:54:30.3491173\u002B00:00", + "createdBy": "Zhengfei Wang", + "createdByType": "User" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000/cancel?api-version=2022-10-01-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:54:34 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-async-operation-timeout": "PT1H", + "x-ms-correlation-request-id": "2445c12f-cd96-456d-826d-f44681fd25f2", + "x-ms-ratelimit-remaining-subscription-writes": "1194", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085435Z:2445c12f-cd96-456d-826d-f44681fd25f2", + "x-request-time": "1.510" + }, + "ResponseBody": "null" + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Fri, 11 Nov 2022 08:55:05 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-db8dc289c4c5088dd1725fa083207b63-36b76c0814710369-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "51695312-671c-48b3-933f-be99c966acc0", + "x-ms-ratelimit-remaining-subscription-reads": "11991", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085505Z:51695312-671c-48b3-933f-be99c966acc0", + "x-request-time": "0.048" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_classification_multilabel_in_pipeline.json b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_classification_multilabel_in_pipeline.json new file mode 100644 index 000000000000..7ce529004e14 --- /dev/null +++ b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_classification_multilabel_in_pipeline.json @@ -0,0 +1,569 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:58:16 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-8e901c75181bcaecf4707e265f5a8619-86fafb15a78a25be-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "2da06e58-afc0-4fff-9425-1646a98955e7", + "x-ms-ratelimit-remaining-subscription-reads": "11996", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085816Z:2da06e58-afc0-4fff-9425-1646a98955e7", + "x-request-time": "0.149" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:58:16 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-737e252338d010142e483c9b0dbe751d-773572feb7bf535c-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "e9eb9fa3-4524-4cc5-b05e-6a888053240d", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085817Z:e9eb9fa3-4524-4cc5-b05e-6a888053240d", + "x-request-time": "0.139" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:58:16 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "237", + "Content-MD5": "d5iUinY\u002Bmn6eahGwCIVgug==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 08:58:17 GMT", + "ETag": "\u00220x8DAC3C2B058A438\u0022", + "Last-Modified": "Fri, 11 Nov 2022 08:56:57 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Fri, 11 Nov 2022 08:56:57 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "2f85697d-1e47-4f28-98ac-8891ce6c8b76", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "d308d1b2-edd7-450e-8592-a46d6e6a753e", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:58:18 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 08:58:18 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:58:18 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-98136d54a3d8c8a8906855a06d7f1234-de195f571e5701b5-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "f54f2442-cb30-446a-b0af-f4a79889444a", + "x-ms-ratelimit-remaining-subscription-reads": "11995", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085818Z:f54f2442-cb30-446a-b0af-f4a79889444a", + "x-request-time": "0.093" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:58:19 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-d4688c8806b4f0518a6c756ad13d0bcd-5900e903f01fe7c0-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "dd48e3dd-32b0-4472-952d-8f47b87be150", + "x-ms-ratelimit-remaining-subscription-writes": "1198", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085819Z:dd48e3dd-32b0-4472-952d-8f47b87be150", + "x-request-time": "0.098" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:58:19 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "237", + "Content-MD5": "zJkcQ9x3KihpmL2EgNCrfA==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 08:58:19 GMT", + "ETag": "\u00220x8DAC3C2B190321C\u0022", + "Last-Modified": "Fri, 11 Nov 2022 08:56:59 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Fri, 11 Nov 2022 08:56:59 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "ed56427c-4ff4-4f35-bbd7-ca575d6a7c67", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "ea9a2adc-6150-4a92-a724-23a7789dadb7", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 08:58:19 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 08:58:19 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "1264", + "Content-Type": "application/json", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": { + "properties": { + "properties": {}, + "tags": {}, + "displayName": "train_automl_text_class_multilabel_in_pipeline", + "experimentName": "azure-ai-ml", + "isArchived": false, + "jobType": "Pipeline", + "inputs": { + "text_classification_multilabel_train": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "jobInputType": "mltable" + }, + "text_classification_multilabel_valid": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "jobInputType": "mltable" + } + }, + "jobs": { + "text_classification_multilabel_node": { + "name": "text_classification_multilabel_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "training_data": "${{parent.inputs.text_classification_multilabel_train}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "max_nodes": 1 + }, + "validation_data": "${{parent.inputs.text_classification_multilabel_valid}}", + "task": "text_classification_multilabel", + "primary_metric": "accuracy", + "target_column_name": "terms" + } + }, + "outputs": {}, + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + } + } + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "3438", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:58:29 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-7269d8ac9a9cdc4c0a67128ecbe469ba-05568df4f226d304-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "9838b236-861f-4122-b874-3942d71a810f", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085829Z:9838b236-861f-4122-b874-3942d71a810f", + "x-request-time": "4.594" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000", + "name": "000000000000000000000", + "type": "Microsoft.MachineLearningServices/workspaces/jobs", + "properties": { + "description": null, + "tags": {}, + "properties": { + "azureml.DevPlatv2": "true", + "azureml.runsource": "azureml.PipelineRun", + "runSource": "MFE", + "runType": "HTTP", + "azureml.parameters": "{}", + "azureml.continue_on_step_failure": "False", + "azureml.continue_on_failed_optional_input": "True", + "azureml.defaultComputeName": "gpu-cluster", + "azureml.defaultDataStoreName": "workspaceblobstore", + "azureml.pipelineComponent": "pipelinerun" + }, + "displayName": "train_automl_text_class_multilabel_in_pipeline", + "status": "Preparing", + "experimentName": "azure-ai-ml", + "services": { + "Tracking": { + "jobServiceType": "Tracking", + "port": null, + "endpoint": "azureml://master.api.azureml-test.ms/mlflow/v1.0/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000?", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + }, + "Studio": { + "jobServiceType": "Studio", + "port": null, + "endpoint": "https://ml.azure.com/runs/000000000000000000000?wsid=/subscriptions/00000000-0000-0000-0000-000000000/resourcegroups/00000/workspaces/00000", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + } + }, + "computeId": null, + "isArchived": false, + "identity": null, + "componentId": null, + "jobType": "Pipeline", + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + }, + "jobs": { + "text_classification_multilabel_node": { + "name": "text_classification_multilabel_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "training_data": "${{parent.inputs.text_classification_multilabel_train}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "max_nodes": 1 + }, + "validation_data": "${{parent.inputs.text_classification_multilabel_valid}}", + "task": "text_classification_multilabel", + "primary_metric": "accuracy", + "target_column_name": "terms" + } + }, + "inputs": { + "text_classification_multilabel_train": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + }, + "text_classification_multilabel_valid": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + } + }, + "outputs": {}, + "sourceJobId": null + }, + "systemData": { + "createdAt": "2022-11-11T08:58:28.6020984\u002B00:00", + "createdBy": "Zhengfei Wang", + "createdByType": "User" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000/cancel?api-version=2022-10-01-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 08:58:35 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-async-operation-timeout": "PT1H", + "x-ms-correlation-request-id": "defcd2e9-5b52-41ff-bb2e-9ac78c5e4d3b", + "x-ms-ratelimit-remaining-subscription-writes": "1197", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085836Z:defcd2e9-5b52-41ff-bb2e-9ac78c5e4d3b", + "x-request-time": "0.945" + }, + "ResponseBody": "null" + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Fri, 11 Nov 2022 08:59:06 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-7c5ff9e8a3bcc7dc4eb789da1c0eb573-4ade62cdd4dbcec1-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "5513a0ec-9fac-4d6c-8f6b-621da3b781a8", + "x-ms-ratelimit-remaining-subscription-reads": "11994", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T085906Z:5513a0ec-9fac-4d6c-8f6b-621da3b781a8", + "x-request-time": "0.029" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_ner_in_pipeline.json b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_ner_in_pipeline.json new file mode 100644 index 000000000000..737ae059edc5 --- /dev/null +++ b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_text_ner_in_pipeline.json @@ -0,0 +1,557 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "1067", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:04:16 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-e4f2453eb072d916a682182ca660bb12-c6af4cb38acdcf4b-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "bae86461-7b41-4ba8-9e2f-f04f6b47bbc2", + "x-ms-ratelimit-remaining-subscription-reads": "11991", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T090416Z:bae86461-7b41-4ba8-9e2f-f04f6b47bbc2", + "x-request-time": "0.186" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "61", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:04:17 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-5790de6627b88c07bcc333c3874f18ee-9f6ce48ec43d3a9a-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "65045ddc-43ba-4111-af4e-30a62558caca", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T090418Z:65045ddc-43ba-4111-af4e-30a62558caca", + "x-request-time": "0.294" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:04:18 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "147", + "Content-MD5": "P7GsnZaXDEDX/DJLN0O5nA==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 09:04:18 GMT", + "ETag": "\u00220x8DAC3C391C63FBD\u0022", + "Last-Modified": "Fri, 11 Nov 2022 09:03:15 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Fri, 11 Nov 2022 09:03:15 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "6f92f540-c2ac-43d2-a8db-95d113188439", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "e9aa8f9b-130b-4b73-ac74-672445371564", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:04:19 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 09:04:18 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "1067", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:04:20 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-470f6b3dd75c7b9e2070e93af2301ec1-f1200dfcfe9ca89f-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "6034743c-645e-45cc-b6e6-88920408aa43", + "x-ms-ratelimit-remaining-subscription-reads": "11990", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T090420Z:6034743c-645e-45cc-b6e6-88920408aa43", + "x-request-time": "0.119" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "61", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:04:20 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-bc9a26c6f0220b26edb278a2db23298c-c02c9aa19ca49b28-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "cbe77c6f-5843-4452-a330-adbbb014e638", + "x-ms-ratelimit-remaining-subscription-writes": "1198", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T090421Z:cbe77c6f-5843-4452-a330-adbbb014e638", + "x-request-time": "0.095" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:04:21 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "147", + "Content-MD5": "rPxzBke97x5/DWxWuJSBsQ==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 09:04:20 GMT", + "ETag": "\u00220x8DAC3C392EBF6D8\u0022", + "Last-Modified": "Fri, 11 Nov 2022 09:03:17 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Fri, 11 Nov 2022 09:03:17 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "09b0b5a8-9ef3-41e5-bb1a-b8235aa1cb41", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "9d27883c-e673-47d7-86ab-e61c425114c5", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:04:21 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 09:04:20 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "1097", + "Content-Type": "application/json", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": { + "properties": { + "properties": {}, + "tags": {}, + "displayName": "train_automl_text_ner_in_pipeline", + "experimentName": "azure-ai-ml", + "isArchived": false, + "jobType": "Pipeline", + "inputs": { + "text_ner_train": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "jobInputType": "mltable" + }, + "text_ner_valid": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "jobInputType": "mltable" + } + }, + "jobs": { + "text_ner_node": { + "name": "text_ner_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "training_data": "${{parent.inputs.text_ner_train}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "max_nodes": 1 + }, + "validation_data": "${{parent.inputs.text_ner_valid}}", + "task": "text_ner", + "primary_metric": "accuracy", + "target_column_name": "label" + } + }, + "outputs": {}, + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + } + } + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "3271", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:04:31 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-5f2952556b369c52e1c43493d5f0a3e3-9888d6c95a01341e-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "49bf4b3d-96bd-4648-9c4d-946ccb81be90", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T090432Z:49bf4b3d-96bd-4648-9c4d-946ccb81be90", + "x-request-time": "5.362" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000", + "name": "000000000000000000000", + "type": "Microsoft.MachineLearningServices/workspaces/jobs", + "properties": { + "description": null, + "tags": {}, + "properties": { + "azureml.DevPlatv2": "true", + "azureml.runsource": "azureml.PipelineRun", + "runSource": "MFE", + "runType": "HTTP", + "azureml.parameters": "{}", + "azureml.continue_on_step_failure": "False", + "azureml.continue_on_failed_optional_input": "True", + "azureml.defaultComputeName": "gpu-cluster", + "azureml.defaultDataStoreName": "workspaceblobstore", + "azureml.pipelineComponent": "pipelinerun" + }, + "displayName": "train_automl_text_ner_in_pipeline", + "status": "Preparing", + "experimentName": "azure-ai-ml", + "services": { + "Tracking": { + "jobServiceType": "Tracking", + "port": null, + "endpoint": "azureml://master.api.azureml-test.ms/mlflow/v1.0/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000?", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + }, + "Studio": { + "jobServiceType": "Studio", + "port": null, + "endpoint": "https://ml.azure.com/runs/000000000000000000000?wsid=/subscriptions/00000000-0000-0000-0000-000000000/resourcegroups/00000/workspaces/00000", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + } + }, + "computeId": null, + "isArchived": false, + "identity": null, + "componentId": null, + "jobType": "Pipeline", + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + }, + "jobs": { + "text_ner_node": { + "name": "text_ner_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "training_data": "${{parent.inputs.text_ner_train}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "max_nodes": 1 + }, + "validation_data": "${{parent.inputs.text_ner_valid}}", + "task": "text_ner", + "primary_metric": "accuracy", + "target_column_name": "label" + } + }, + "inputs": { + "text_ner_train": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + }, + "text_ner_valid": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + } + }, + "outputs": {}, + "sourceJobId": null + }, + "systemData": { + "createdAt": "2022-11-11T09:04:31.4850976\u002B00:00", + "createdBy": "Zhengfei Wang", + "createdByType": "User" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000/cancel?api-version=2022-10-01-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:04:35 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-async-operation-timeout": "PT1H", + "x-ms-correlation-request-id": "be71cd2d-399b-4c88-8c1e-31e6a441214d", + "x-ms-ratelimit-remaining-subscription-writes": "1197", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T090436Z:be71cd2d-399b-4c88-8c1e-31e6a441214d", + "x-request-time": "1.093" + }, + "ResponseBody": "null" + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Fri, 11 Nov 2022 09:05:06 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-45364fbeab903a79bf18a71e78b798e5-c0b85452a743d065-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "a22503df-3204-4e74-aba1-bb52a34b193e", + "x-ms-ratelimit-remaining-subscription-reads": "11988", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T090506Z:a22503df-3204-4e74-aba1-bb52a34b193e", + "x-request-time": "0.037" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_multiclass_node_in_pipeline.json b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_multiclass_node_in_pipeline.json new file mode 100644 index 000000000000..89ae9e10e0e7 --- /dev/null +++ b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_multiclass_node_in_pipeline.json @@ -0,0 +1,611 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:11:02 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-148ef62094b241caffdee189afab97b3-c8a296b3873f177c-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "626b6bab-1ce9-4f19-812f-375feea1016b", + "x-ms-ratelimit-remaining-subscription-reads": "11981", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091102Z:626b6bab-1ce9-4f19-812f-375feea1016b", + "x-request-time": "0.101" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:11:02 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-d7b80d2189a81918e11dd50f7156705f-2f7bf21b16298c5a-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "f618d891-2225-43e1-b230-ff5034c8d52c", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091103Z:f618d891-2225-43e1-b230-ff5034c8d52c", + "x-request-time": "0.098" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:11:02 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "264", + "Content-MD5": "bxQgDk/2/IhOiVcx8\u002BLMhg==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 09:11:03 GMT", + "ETag": "\u00220x8DAC087F03D060C\u0022", + "Last-Modified": "Mon, 07 Nov 2022 06:18:50 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Mon, 07 Nov 2022 06:18:50 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "cfaf7334-b59f-46ae-891a-fd5f1517cc91", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "e56f7f02-9854-45ce-9616-80395a43f0ea", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:11:04 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 09:11:04 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:11:04 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-c48642773d299919097463738ba10ecd-e05dd36367164629-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "5a8184f0-e22f-4d98-b5c1-705541f88d5f", + "x-ms-ratelimit-remaining-subscription-reads": "11980", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091104Z:5a8184f0-e22f-4d98-b5c1-705541f88d5f", + "x-request-time": "0.100" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:11:05 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-3b95686f9997cab309c325cb94d7bef3-bb1b965f56ebe6f3-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "042ee1a6-ba7b-4f87-895d-39d73f9412e0", + "x-ms-ratelimit-remaining-subscription-writes": "1198", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091105Z:042ee1a6-ba7b-4f87-895d-39d73f9412e0", + "x-request-time": "0.096" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:11:05 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "269", + "Content-MD5": "WaHfrrWZTI6RIAay8\u002BmxMg==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 09:11:05 GMT", + "ETag": "\u00220x8DAC087F183D572\u0022", + "Last-Modified": "Mon, 07 Nov 2022 06:18:53 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Mon, 07 Nov 2022 06:18:52 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "fad8da95-e033-46ca-8bbc-b0cfb176a55c", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "23f0116c-2f00-493e-a191-94e7f37bbfbf", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:11:05 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 09:11:05 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "1568", + "Content-Type": "application/json", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": { + "properties": { + "properties": {}, + "tags": {}, + "displayName": "train_multiclass_with_automl_in_pipeline", + "experimentName": "azure-ai-ml", + "isArchived": false, + "jobType": "Pipeline", + "inputs": { + "image_multiclass_train_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "jobInputType": "mltable" + }, + "image_multiclass_valid_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "jobInputType": "mltable" + } + }, + "jobs": { + "image_multiclass_node": { + "name": "image_multiclass_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.image_multiclass_train_data}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "timeout_minutes": 60 + }, + "sweep": { + "sampling_algorithm": "random", + "early_termination": { + "evaluation_interval": 2, + "delay_evaluation": 6, + "type": "bandit", + "slack_factor": 0.2, + "slack_amount": 0.0 + } + }, + "target_column_name": "label", + "validation_data": "${{parent.inputs.image_multiclass_valid_data}}", + "search_space": [ + { + "learning_rate": "uniform(0.001,0.01)", + "model_name": "choice(\u0027vits16r224\u0027)" + }, + { + "learning_rate": "uniform(0.001,0.01)", + "model_name": "choice(\u0027seresnext\u0027)" + } + ], + "task": "image_classification", + "primary_metric": "accuracy" + } + }, + "outputs": {}, + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + } + } + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "3969", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:11:14 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-a9ef0acc8fa876dac1ab68d4cbee684c-6f14b993ab1969fb-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "e895b626-143a-4239-9937-24d97a912dac", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091114Z:e895b626-143a-4239-9937-24d97a912dac", + "x-request-time": "3.804" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000", + "name": "000000000000000000000", + "type": "Microsoft.MachineLearningServices/workspaces/jobs", + "properties": { + "description": null, + "tags": {}, + "properties": { + "azureml.DevPlatv2": "true", + "azureml.runsource": "azureml.PipelineRun", + "runSource": "MFE", + "runType": "HTTP", + "azureml.parameters": "{}", + "azureml.continue_on_step_failure": "False", + "azureml.continue_on_failed_optional_input": "True", + "azureml.defaultComputeName": "gpu-cluster", + "azureml.defaultDataStoreName": "workspaceblobstore", + "azureml.pipelineComponent": "pipelinerun" + }, + "displayName": "train_multiclass_with_automl_in_pipeline", + "status": "Preparing", + "experimentName": "azure-ai-ml", + "services": { + "Tracking": { + "jobServiceType": "Tracking", + "port": null, + "endpoint": "azureml://master.api.azureml-test.ms/mlflow/v1.0/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000?", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + }, + "Studio": { + "jobServiceType": "Studio", + "port": null, + "endpoint": "https://ml.azure.com/runs/000000000000000000000?wsid=/subscriptions/00000000-0000-0000-0000-000000000/resourcegroups/00000/workspaces/00000", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + } + }, + "computeId": null, + "isArchived": false, + "identity": null, + "componentId": null, + "jobType": "Pipeline", + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + }, + "jobs": { + "image_multiclass_node": { + "name": "image_multiclass_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.image_multiclass_train_data}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "timeout_minutes": 60 + }, + "sweep": { + "sampling_algorithm": "random", + "early_termination": { + "evaluation_interval": 2, + "delay_evaluation": 6, + "type": "bandit", + "slack_factor": 0.2, + "slack_amount": 0.0 + } + }, + "target_column_name": "label", + "validation_data": "${{parent.inputs.image_multiclass_valid_data}}", + "search_space": [ + { + "learning_rate": "uniform(0.001,0.01)", + "model_name": "choice(\u0027vits16r224\u0027)" + }, + { + "learning_rate": "uniform(0.001,0.01)", + "model_name": "choice(\u0027seresnext\u0027)" + } + ], + "task": "image_classification", + "primary_metric": "accuracy" + } + }, + "inputs": { + "image_multiclass_train_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + }, + "image_multiclass_valid_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + } + }, + "outputs": {}, + "sourceJobId": null + }, + "systemData": { + "createdAt": "2022-11-11T09:11:13.759289\u002B00:00", + "createdBy": "Zhengfei Wang", + "createdByType": "User" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000/cancel?api-version=2022-10-01-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:11:17 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-async-operation-timeout": "PT1H", + "x-ms-correlation-request-id": "ce7890df-77a3-4726-8697-0ccbd1295b2c", + "x-ms-ratelimit-remaining-subscription-writes": "1197", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091118Z:ce7890df-77a3-4726-8697-0ccbd1295b2c", + "x-request-time": "0.965" + }, + "ResponseBody": "null" + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Fri, 11 Nov 2022 09:11:47 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-e0238d1d38cf1cce5bca8c1ec7a41ea1-846d57de52499226-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "37b84117-74d0-4e2b-a3b0-cfbeb2d24163", + "x-ms-ratelimit-remaining-subscription-reads": "11979", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091148Z:37b84117-74d0-4e2b-a3b0-cfbeb2d24163", + "x-request-time": "0.043" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_multilabel_node_in_pipeline.json b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_multilabel_node_in_pipeline.json new file mode 100644 index 000000000000..b6ae5b76b5be --- /dev/null +++ b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_multilabel_node_in_pipeline.json @@ -0,0 +1,611 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:14:38 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-f86e9af8cbb111ddff9c9a36c6459c61-9e411aaae09396e9-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "a3aae817-4bd8-4253-b6d1-7075b93c9ef2", + "x-ms-ratelimit-remaining-subscription-reads": "11981", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091438Z:a3aae817-4bd8-4253-b6d1-7075b93c9ef2", + "x-request-time": "0.952" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:14:39 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-59f444fb8364e8bc3bac4adafc031a93-8df856dac2629499-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "b4bf27ca-9e46-4938-99a8-30237fd4686c", + "x-ms-ratelimit-remaining-subscription-writes": "1190", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091439Z:b4bf27ca-9e46-4938-99a8-30237fd4686c", + "x-request-time": "0.100" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:14:39 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "264", + "Content-MD5": "bxQgDk/2/IhOiVcx8\u002BLMhg==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 09:14:40 GMT", + "ETag": "\u00220x8DAC3C4F6933739\u0022", + "Last-Modified": "Fri, 11 Nov 2022 09:13:14 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Fri, 11 Nov 2022 09:13:13 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "72115561-e81b-4487-86dc-6aa7f1ebbacc", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "0dc91dc7-9b69-4644-91ca-74ad9a689884", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:14:40 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 09:14:40 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:14:40 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-39ab3e92207684b6a6b4865a23f75b8c-9b31ebff6c69a1d9-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": [ + "Accept-Encoding", + "Accept-Encoding" + ], + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "f661d362-5c9f-439f-872c-24d81997ef4a", + "x-ms-ratelimit-remaining-subscription-reads": "11980", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091441Z:f661d362-5c9f-439f-872c-24d81997ef4a", + "x-request-time": "0.108" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Encoding": "gzip", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:14:41 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-7846453c6a86e324e61980f2b9df4c88-7f0a7af5c9306e01-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Transfer-Encoding": "chunked", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "f447e60d-fd37-47ed-86db-cbf7817dd3f1", + "x-ms-ratelimit-remaining-subscription-writes": "1189", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091441Z:f447e60d-fd37-47ed-86db-cbf7817dd3f1", + "x-request-time": "0.089" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:14:41 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "269", + "Content-MD5": "WaHfrrWZTI6RIAay8\u002BmxMg==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 09:14:42 GMT", + "ETag": "\u00220x8DAC3C4F7D65BEC\u0022", + "Last-Modified": "Fri, 11 Nov 2022 09:13:16 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Fri, 11 Nov 2022 09:13:16 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "3d6707f3-b51e-4988-8d4d-4a1d28b7b2e5", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "654518b9-6d47-4942-8e50-330332b8cd9b", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:14:42 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 09:14:42 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "1574", + "Content-Type": "application/json", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": { + "properties": { + "properties": {}, + "tags": {}, + "displayName": "train_multilabel_with_automl_in_pipeline", + "experimentName": "azure-ai-ml", + "isArchived": false, + "jobType": "Pipeline", + "inputs": { + "image_multilabel_train_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "jobInputType": "mltable" + }, + "image_multilabel_valid_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "jobInputType": "mltable" + } + }, + "jobs": { + "image_multilabel_node": { + "name": "image_multilabel_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.image_multilabel_train_data}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "timeout_minutes": 60 + }, + "sweep": { + "sampling_algorithm": "random", + "early_termination": { + "evaluation_interval": 2, + "delay_evaluation": 6, + "type": "bandit", + "slack_factor": 0.2, + "slack_amount": 0.0 + } + }, + "target_column_name": "label", + "validation_data": "${{parent.inputs.image_multilabel_valid_data}}", + "search_space": [ + { + "learning_rate": "uniform(0.001,0.01)", + "model_name": "choice(\u0027vitb16r224\u0027)" + }, + { + "learning_rate": "uniform(0.001,0.01)", + "model_name": "choice(\u0027seresnext\u0027)" + } + ], + "task": "image_classification_multilabel", + "primary_metric": "iou" + } + }, + "outputs": {}, + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + } + } + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "3976", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:14:50 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-871a58276c4394237b44970a5691758c-e1e0c4668a2b8e82-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "30270e93-d065-4cdd-b36e-af8b39c2a253", + "x-ms-ratelimit-remaining-subscription-writes": "1196", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091450Z:30270e93-d065-4cdd-b36e-af8b39c2a253", + "x-request-time": "3.377" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000", + "name": "000000000000000000000", + "type": "Microsoft.MachineLearningServices/workspaces/jobs", + "properties": { + "description": null, + "tags": {}, + "properties": { + "azureml.DevPlatv2": "true", + "azureml.runsource": "azureml.PipelineRun", + "runSource": "MFE", + "runType": "HTTP", + "azureml.parameters": "{}", + "azureml.continue_on_step_failure": "False", + "azureml.continue_on_failed_optional_input": "True", + "azureml.defaultComputeName": "gpu-cluster", + "azureml.defaultDataStoreName": "workspaceblobstore", + "azureml.pipelineComponent": "pipelinerun" + }, + "displayName": "train_multilabel_with_automl_in_pipeline", + "status": "Preparing", + "experimentName": "azure-ai-ml", + "services": { + "Tracking": { + "jobServiceType": "Tracking", + "port": null, + "endpoint": "azureml://master.api.azureml-test.ms/mlflow/v1.0/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000?", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + }, + "Studio": { + "jobServiceType": "Studio", + "port": null, + "endpoint": "https://ml.azure.com/runs/000000000000000000000?wsid=/subscriptions/00000000-0000-0000-0000-000000000/resourcegroups/00000/workspaces/00000", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + } + }, + "computeId": null, + "isArchived": false, + "identity": null, + "componentId": null, + "jobType": "Pipeline", + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + }, + "jobs": { + "image_multilabel_node": { + "name": "image_multilabel_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.image_multilabel_train_data}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "timeout_minutes": 60 + }, + "sweep": { + "sampling_algorithm": "random", + "early_termination": { + "evaluation_interval": 2, + "delay_evaluation": 6, + "type": "bandit", + "slack_factor": 0.2, + "slack_amount": 0.0 + } + }, + "target_column_name": "label", + "validation_data": "${{parent.inputs.image_multilabel_valid_data}}", + "search_space": [ + { + "learning_rate": "uniform(0.001,0.01)", + "model_name": "choice(\u0027vitb16r224\u0027)" + }, + { + "learning_rate": "uniform(0.001,0.01)", + "model_name": "choice(\u0027seresnext\u0027)" + } + ], + "task": "image_classification_multilabel", + "primary_metric": "iou" + } + }, + "inputs": { + "image_multilabel_train_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + }, + "image_multilabel_valid_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + } + }, + "outputs": {}, + "sourceJobId": null + }, + "systemData": { + "createdAt": "2022-11-11T09:14:50.0974208\u002B00:00", + "createdBy": "Zhengfei Wang", + "createdByType": "User" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000/cancel?api-version=2022-10-01-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:14:53 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-async-operation-timeout": "PT1H", + "x-ms-correlation-request-id": "76e5402a-80a8-4bb1-abea-35f14a9c21d5", + "x-ms-ratelimit-remaining-subscription-writes": "1188", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091454Z:76e5402a-80a8-4bb1-abea-35f14a9c21d5", + "x-request-time": "0.830" + }, + "ResponseBody": "null" + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Fri, 11 Nov 2022 09:15:24 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-7aaab5ef0932ef0c57ff83cd7be1e1e7-5a510eb812d43450-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "b1de8ed2-295c-4dd5-8fe5-d47363533ce7", + "x-ms-ratelimit-remaining-subscription-reads": "11979", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091525Z:b1de8ed2-295c-4dd5-8fe5-d47363533ce7", + "x-request-time": "0.031" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_od_node_in_pipeline.json b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_od_node_in_pipeline.json new file mode 100644 index 000000000000..0bd3a48be718 --- /dev/null +++ b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_od_node_in_pipeline.json @@ -0,0 +1,611 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "1067", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:18:39 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-28387c060d0409fa3bb8f51a3e219039-6f176c4eead6514b-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "4e7a2051-90c2-4a7e-a19a-b645eaedaeb2", + "x-ms-ratelimit-remaining-subscription-reads": "11985", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091840Z:4e7a2051-90c2-4a7e-a19a-b645eaedaeb2", + "x-request-time": "0.108" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "61", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:18:40 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-6d020ba50283205ac7202d9a36fdfeec-f11f9f9b1cf03faf-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "0eb47a5a-c27d-49eb-8bee-2ca4602af4d3", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091840Z:0eb47a5a-c27d-49eb-8bee-2ca4602af4d3", + "x-request-time": "0.214" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:18:40 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "264", + "Content-MD5": "bxQgDk/2/IhOiVcx8\u002BLMhg==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 09:18:41 GMT", + "ETag": "\u00220x8DAC087F03D060C\u0022", + "Last-Modified": "Mon, 07 Nov 2022 06:18:50 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Mon, 07 Nov 2022 06:18:50 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "cfaf7334-b59f-46ae-891a-fd5f1517cc91", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "e56f7f02-9854-45ce-9616-80395a43f0ea", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:18:41 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 09:18:41 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "1067", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:18:42 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-1773e9b6ab8a24d3a0fc4428cd7b5dcb-f01617e36b420f47-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "06f963fb-10e7-4109-98f6-a8ec2659252a", + "x-ms-ratelimit-remaining-subscription-reads": "11984", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091842Z:06f963fb-10e7-4109-98f6-a8ec2659252a", + "x-request-time": "0.101" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "61", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:18:42 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-555af9282d6a035e2657a7551ae6cd1f-c3f378041bdad1a2-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "97f1827f-f163-4480-8084-5a98dda3d686", + "x-ms-ratelimit-remaining-subscription-writes": "1198", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091843Z:97f1827f-f163-4480-8084-5a98dda3d686", + "x-request-time": "0.134" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:18:43 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "269", + "Content-MD5": "WaHfrrWZTI6RIAay8\u002BmxMg==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 09:18:43 GMT", + "ETag": "\u00220x8DAC087F183D572\u0022", + "Last-Modified": "Mon, 07 Nov 2022 06:18:53 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Mon, 07 Nov 2022 06:18:52 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "fad8da95-e033-46ca-8bbc-b0cfb176a55c", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "23f0116c-2f00-493e-a191-94e7f37bbfbf", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:18:43 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 09:18:43 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "1794", + "Content-Type": "application/json", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": { + "properties": { + "properties": {}, + "tags": {}, + "displayName": "train_od_with_automl_in_pipeline", + "experimentName": "azure-ai-ml", + "isArchived": false, + "jobType": "Pipeline", + "inputs": { + "image_object_detection_train_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "jobInputType": "mltable" + }, + "image_object_detection_valid_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "jobInputType": "mltable" + } + }, + "jobs": { + "image_object_detection_node": { + "name": "image_object_detection_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.image_object_detection_train_data}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "timeout_minutes": 60 + }, + "sweep": { + "sampling_algorithm": "random", + "early_termination": { + "evaluation_interval": 2, + "delay_evaluation": 6, + "type": "bandit", + "slack_factor": 0.2, + "slack_amount": 0.0 + } + }, + "target_column_name": "label", + "validation_data": "${{parent.inputs.image_object_detection_valid_data}}", + "task": "image_object_detection", + "primary_metric": "mean_average_precision", + "training_parameters": { + "nms_iou_threshold": 0.7 + }, + "search_space": [ + { + "learning_rate": "uniform(0.0001,0.01)", + "model_size": "choice(\u0027small\u0027,\u0027medium\u0027)", + "model_name": "choice(\u0027yolov5\u0027)" + }, + { + "learning_rate": "uniform(0.0001,0.001)", + "optimizer": "choice(\u0027sgd\u0027,\u0027adam\u0027,\u0027adamw\u0027)", + "min_size": "choice(600,800)", + "model_name": "choice(\u0027fasterrcnn_resnet50_fpn\u0027)" + } + ] + } + }, + "outputs": {}, + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + } + } + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4260", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:18:51 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-b54b5cd4172081f821b8d21ed635f04d-30956afd734ea69c-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "259287da-f3d5-47c1-bcae-9009e350570d", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091852Z:259287da-f3d5-47c1-bcae-9009e350570d", + "x-request-time": "3.939" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000", + "name": "000000000000000000000", + "type": "Microsoft.MachineLearningServices/workspaces/jobs", + "properties": { + "description": null, + "tags": {}, + "properties": { + "azureml.DevPlatv2": "true", + "azureml.runsource": "azureml.PipelineRun", + "runSource": "MFE", + "runType": "HTTP", + "azureml.parameters": "{}", + "azureml.continue_on_step_failure": "False", + "azureml.continue_on_failed_optional_input": "True", + "azureml.defaultComputeName": "gpu-cluster", + "azureml.defaultDataStoreName": "workspaceblobstore", + "azureml.pipelineComponent": "pipelinerun" + }, + "displayName": "train_od_with_automl_in_pipeline", + "status": "Preparing", + "experimentName": "azure-ai-ml", + "services": { + "Tracking": { + "jobServiceType": "Tracking", + "port": null, + "endpoint": "azureml://master.api.azureml-test.ms/mlflow/v1.0/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000?", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + }, + "Studio": { + "jobServiceType": "Studio", + "port": null, + "endpoint": "https://ml.azure.com/runs/000000000000000000000?wsid=/subscriptions/00000000-0000-0000-0000-000000000/resourcegroups/00000/workspaces/00000", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + } + }, + "computeId": null, + "isArchived": false, + "identity": null, + "componentId": null, + "jobType": "Pipeline", + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + }, + "jobs": { + "image_object_detection_node": { + "name": "image_object_detection_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.image_object_detection_train_data}}", + "limits": { + "max_concurrent_trials": 1, + "max_trials": 1, + "timeout_minutes": 60 + }, + "sweep": { + "sampling_algorithm": "random", + "early_termination": { + "evaluation_interval": 2, + "delay_evaluation": 6, + "type": "bandit", + "slack_factor": 0.2, + "slack_amount": 0.0 + } + }, + "target_column_name": "label", + "validation_data": "${{parent.inputs.image_object_detection_valid_data}}", + "task": "image_object_detection", + "primary_metric": "mean_average_precision", + "training_parameters": { + "nms_iou_threshold": 0.7 + }, + "search_space": [ + { + "learning_rate": "uniform(0.0001,0.01)", + "model_size": "choice(\u0027small\u0027,\u0027medium\u0027)", + "model_name": "choice(\u0027yolov5\u0027)" + }, + { + "learning_rate": "uniform(0.0001,0.001)", + "optimizer": "choice(\u0027sgd\u0027,\u0027adam\u0027,\u0027adamw\u0027)", + "min_size": "choice(600,800)", + "model_name": "choice(\u0027fasterrcnn_resnet50_fpn\u0027)" + } + ] + } + }, + "inputs": { + "image_object_detection_train_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + }, + "image_object_detection_valid_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + } + }, + "outputs": {}, + "sourceJobId": null + }, + "systemData": { + "createdAt": "2022-11-11T09:18:51.6586447\u002B00:00", + "createdBy": "Zhengfei Wang", + "createdByType": "User" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000/cancel?api-version=2022-10-01-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:18:55 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-async-operation-timeout": "PT1H", + "x-ms-correlation-request-id": "d2bce305-8fb2-4e29-879b-d04f97e9b54e", + "x-ms-ratelimit-remaining-subscription-writes": "1197", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091855Z:d2bce305-8fb2-4e29-879b-d04f97e9b54e", + "x-request-time": "0.783" + }, + "ResponseBody": "null" + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Fri, 11 Nov 2022 09:19:26 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-f1c0433d0684ee956c0fea86dbd3d488-b42135ff24bc9297-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "e31f02ce-2640-4989-a87e-b3dffbd66060", + "x-ms-ratelimit-remaining-subscription-reads": "11983", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T091926Z:e31f02ce-2640-4989-a87e-b3dffbd66060", + "x-request-time": "0.051" + }, + "ResponseBody": null + } + ], + "Variables": {} +} diff --git a/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_segmentation_node_in_pipeline.json b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_segmentation_node_in_pipeline.json new file mode 100644 index 000000000000..ffe74beada0f --- /dev/null +++ b/sdk/ml/azure-ai-ml/tests/recordings/dsl/e2etests/test_automl_dsl_pipeline.pyTestAutomlDSLPipelinetest_automl_vision_segmentation_node_in_pipeline.json @@ -0,0 +1,601 @@ +{ + "Entries": [ + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "1067", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:21:26 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-cb8b4bde99114324f8cf3fb405fed220-92c83148d09592ed-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "007c4272-c01c-4277-80a3-89261312f69d", + "x-ms-ratelimit-remaining-subscription-reads": "11987", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T092127Z:007c4272-c01c-4277-80a3-89261312f69d", + "x-request-time": "0.099" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "61", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:21:27 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-6d85271553fa54bcfe70725b540df038-a21682485a66274e-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "0559f15e-efa6-4aea-ad09-7e2241f75297", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T092127Z:0559f15e-efa6-4aea-ad09-7e2241f75297", + "x-request-time": "0.118" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:21:27 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "264", + "Content-MD5": "bxQgDk/2/IhOiVcx8\u002BLMhg==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 09:21:28 GMT", + "ETag": "\u00220x8DAC087F03D060C\u0022", + "Last-Modified": "Mon, 07 Nov 2022 06:18:50 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Mon, 07 Nov 2022 06:18:50 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "cfaf7334-b59f-46ae-891a-fd5f1517cc91", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "e56f7f02-9854-45ce-9616-80395a43f0ea", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/train/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:21:28 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 09:21:28 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore?api-version=2022-05-01", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "1067", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:21:29 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-54f5a7e5f3b965c337d9100734bf9b8c-1b7b782af3257d6e-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "Vary": "Accept-Encoding", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "34bd632e-a4e0-4fe6-aa05-4cc75541c8d7", + "x-ms-ratelimit-remaining-subscription-reads": "11986", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T092129Z:34bd632e-a4e0-4fe6-aa05-4cc75541c8d7", + "x-request-time": "0.098" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore", + "name": "workspaceblobstore", + "type": "Microsoft.MachineLearningServices/workspaces/datastores", + "properties": { + "description": null, + "tags": null, + "properties": null, + "isDefault": true, + "credentials": { + "credentialsType": "AccountKey" + }, + "datastoreType": "AzureBlob", + "accountName": "sagvgsoim6nmhbq", + "containerName": "azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8", + "endpoint": "core.windows.net", + "protocol": "https", + "serviceDataAccessAuthIdentity": "WorkspaceSystemAssignedIdentity" + }, + "systemData": { + "createdAt": "2022-09-22T09:02:03.2629568\u002B00:00", + "createdBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "createdByType": "Application", + "lastModifiedAt": "2022-09-22T09:02:04.166989\u002B00:00", + "lastModifiedBy": "779301c0-18b2-4cdc-801b-a0a3368fee0a", + "lastModifiedByType": "Application" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/datastores/workspaceblobstore/listSecrets?api-version=2022-05-01", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "61", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:21:29 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-81e9f4513b506c2172c36f9bb66f360c-c5af549d64425408-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "350e5bf0-daed-4959-94a7-c24879dfdf3e", + "x-ms-ratelimit-remaining-subscription-writes": "1198", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T092130Z:350e5bf0-daed-4959-94a7-c24879dfdf3e", + "x-request-time": "0.096" + }, + "ResponseBody": { + "secretsType": "AccountKey", + "key": "dGhpcyBpcyBmYWtlIGtleQ==" + } + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/LocalUpload/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:21:30 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Accept-Ranges": "bytes", + "Content-Length": "269", + "Content-MD5": "WaHfrrWZTI6RIAay8\u002BmxMg==", + "Content-Type": "application/octet-stream", + "Date": "Fri, 11 Nov 2022 09:21:30 GMT", + "ETag": "\u00220x8DAC087F183D572\u0022", + "Last-Modified": "Mon, 07 Nov 2022 06:18:53 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Vary": "Origin", + "x-ms-access-tier": "Hot", + "x-ms-access-tier-inferred": "true", + "x-ms-blob-type": "BlockBlob", + "x-ms-creation-time": "Mon, 07 Nov 2022 06:18:52 GMT", + "x-ms-lease-state": "available", + "x-ms-lease-status": "unlocked", + "x-ms-meta-name": "fad8da95-e033-46ca-8bbc-b0cfb176a55c", + "x-ms-meta-upload_status": "completed", + "x-ms-meta-version": "23f0116c-2f00-493e-a191-94e7f37bbfbf", + "x-ms-server-encrypted": "true", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://sagvgsoim6nmhbq.blob.core.windows.net/azureml-blobstore-e61cd5e2-512f-475e-9842-5e2a973993b8/az-ml-artifacts/00000000000000000000000000000000/valid/MLTable", + "RequestMethod": "HEAD", + "RequestHeaders": { + "Accept": "application/xml", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azsdk-python-storage-blob/12.13.1 Python/3.9.13 (Windows-10-10.0.22621-SP0)", + "x-ms-date": "Fri, 11 Nov 2022 09:21:30 GMT", + "x-ms-version": "2021-08-06" + }, + "RequestBody": null, + "StatusCode": 404, + "ResponseHeaders": { + "Date": "Fri, 11 Nov 2022 09:21:30 GMT", + "Server": [ + "Windows-Azure-Blob/1.0", + "Microsoft-HTTPAPI/2.0" + ], + "Transfer-Encoding": "chunked", + "Vary": "Origin", + "x-ms-error-code": "BlobNotFound", + "x-ms-version": "2021-08-06" + }, + "ResponseBody": null + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "PUT", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "1706", + "Content-Type": "application/json", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": { + "properties": { + "properties": {}, + "tags": {}, + "displayName": "train_with_automl_in_pipeline", + "experimentName": "azure-ai-ml", + "isArchived": false, + "jobType": "Pipeline", + "inputs": { + "image_instance_segmentation_train_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "jobInputType": "mltable" + }, + "image_instance_segmentation_valid_data": { + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "jobInputType": "mltable" + } + }, + "jobs": { + "image_instance_segmentation_node": { + "name": "image_instance_segmentation_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.image_instance_segmentation_train_data}}", + "limits": { + "max_concurrent_trials": 2, + "max_trials": 10, + "timeout_minutes": 60 + }, + "sweep": { + "sampling_algorithm": "random", + "early_termination": { + "evaluation_interval": 2, + "delay_evaluation": 6, + "type": "bandit", + "slack_factor": 0.2, + "slack_amount": 0.0 + } + }, + "target_column_name": "label", + "validation_data": "${{parent.inputs.image_instance_segmentation_valid_data}}", + "task": "image_instance_segmentation", + "primary_metric": "mean_average_precision", + "training_parameters": { + "nms_iou_threshold": 0.7 + }, + "search_space": [ + { + "learning_rate": "uniform(0.0001,0.001)", + "optimizer": "choice(\u0027sgd\u0027,\u0027adam\u0027,\u0027adamw\u0027)", + "min_size": "choice(600,800)", + "model_name": "choice(\u0027maskrcnn_resnet50_fpn\u0027)" + } + ] + } + }, + "outputs": {}, + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + } + } + }, + "StatusCode": 201, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4113", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:21:38 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-51d71e0dde62486e6c82129d86aafc03-95e160db58a6c50f-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "7bd5774b-f3ce-4476-97ce-d9e01c9cb3c6", + "x-ms-ratelimit-remaining-subscription-writes": "1199", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T092139Z:7bd5774b-f3ce-4476-97ce-d9e01c9cb3c6", + "x-request-time": "3.651" + }, + "ResponseBody": { + "id": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000", + "name": "000000000000000000000", + "type": "Microsoft.MachineLearningServices/workspaces/jobs", + "properties": { + "description": null, + "tags": {}, + "properties": { + "azureml.DevPlatv2": "true", + "azureml.runsource": "azureml.PipelineRun", + "runSource": "MFE", + "runType": "HTTP", + "azureml.parameters": "{}", + "azureml.continue_on_step_failure": "False", + "azureml.continue_on_failed_optional_input": "True", + "azureml.defaultComputeName": "gpu-cluster", + "azureml.defaultDataStoreName": "workspaceblobstore", + "azureml.pipelineComponent": "pipelinerun" + }, + "displayName": "train_with_automl_in_pipeline", + "status": "Preparing", + "experimentName": "azure-ai-ml", + "services": { + "Tracking": { + "jobServiceType": "Tracking", + "port": null, + "endpoint": "azureml://master.api.azureml-test.ms/mlflow/v1.0/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000?", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + }, + "Studio": { + "jobServiceType": "Studio", + "port": null, + "endpoint": "https://ml.azure.com/runs/000000000000000000000?wsid=/subscriptions/00000000-0000-0000-0000-000000000/resourcegroups/00000/workspaces/00000", + "status": null, + "errorMessage": null, + "properties": null, + "nodes": null + } + }, + "computeId": null, + "isArchived": false, + "identity": null, + "componentId": null, + "jobType": "Pipeline", + "settings": { + "default_compute": "/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/computes/gpu-cluster", + "_source": "DSL" + }, + "jobs": { + "image_instance_segmentation_node": { + "name": "image_instance_segmentation_node", + "tags": {}, + "properties": {}, + "type": "automl", + "outputs": {}, + "log_verbosity": "info", + "training_data": "${{parent.inputs.image_instance_segmentation_train_data}}", + "limits": { + "max_concurrent_trials": 2, + "max_trials": 10, + "timeout_minutes": 60 + }, + "sweep": { + "sampling_algorithm": "random", + "early_termination": { + "evaluation_interval": 2, + "delay_evaluation": 6, + "type": "bandit", + "slack_factor": 0.2, + "slack_amount": 0.0 + } + }, + "target_column_name": "label", + "validation_data": "${{parent.inputs.image_instance_segmentation_valid_data}}", + "task": "image_instance_segmentation", + "primary_metric": "mean_average_precision", + "training_parameters": { + "nms_iou_threshold": 0.7 + }, + "search_space": [ + { + "learning_rate": "uniform(0.0001,0.001)", + "optimizer": "choice(\u0027sgd\u0027,\u0027adam\u0027,\u0027adamw\u0027)", + "min_size": "choice(600,800)", + "model_name": "choice(\u0027maskrcnn_resnet50_fpn\u0027)" + } + ] + } + }, + "inputs": { + "image_instance_segmentation_train_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/train", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + }, + "image_instance_segmentation_valid_data": { + "description": null, + "uri": "azureml://datastores/workspaceblobstore/paths/LocalUpload/00000000000000000000000000000000/valid", + "mode": "ReadOnlyMount", + "jobInputType": "mltable" + } + }, + "outputs": {}, + "sourceJobId": null + }, + "systemData": { + "createdAt": "2022-11-11T09:21:38.402192\u002B00:00", + "createdBy": "Zhengfei Wang", + "createdByType": "User" + } + } + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/resourceGroups/00000/providers/Microsoft.MachineLearningServices/workspaces/00000/jobs/000000000000000000000/cancel?api-version=2022-10-01-preview", + "RequestMethod": "POST", + "RequestHeaders": { + "Accept": "application/json", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "Content-Length": "0", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 202, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "4", + "Content-Type": "application/json; charset=utf-8", + "Date": "Fri, 11 Nov 2022 09:21:41 GMT", + "Expires": "-1", + "Location": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-01", + "X-Content-Type-Options": "nosniff", + "x-ms-async-operation-timeout": "PT1H", + "x-ms-correlation-request-id": "cdd31cd4-5849-4503-b343-ae6857bc0559", + "x-ms-ratelimit-remaining-subscription-writes": "1197", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T092142Z:cdd31cd4-5849-4503-b343-ae6857bc0559", + "x-request-time": "0.714" + }, + "ResponseBody": "null" + }, + { + "RequestUri": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000/providers/Microsoft.MachineLearningServices/locations/centraluseuap/mfeOperationResults/jc:e61cd5e2-512f-475e-9842-5e2a973993b8:000000000000000000000?api-version=2022-10-01-preview", + "RequestMethod": "GET", + "RequestHeaders": { + "Accept": "*/*", + "Accept-Encoding": "gzip, deflate", + "Connection": "keep-alive", + "User-Agent": "azure-ai-ml/1.1.0 azsdk-python-mgmt-machinelearningservices/0.1.0 Python/3.9.13 (Windows-10-10.0.22621-SP0)" + }, + "RequestBody": null, + "StatusCode": 200, + "ResponseHeaders": { + "Cache-Control": "no-cache", + "Content-Length": "0", + "Date": "Fri, 11 Nov 2022 09:22:12 GMT", + "Expires": "-1", + "Pragma": "no-cache", + "Request-Context": "appId=cid-v1:512cc15a-13b5-415b-bfd0-dce7accb6bb1", + "Server-Timing": "traceparent;desc=\u002200-591a2f1cb83e31a140f68e1befc82012-61a7d7f48eb15116-00\u0022", + "Strict-Transport-Security": "max-age=31536000; includeSubDomains", + "x-aml-cluster": "vienna-test-westus2-02", + "X-Content-Type-Options": "nosniff", + "x-ms-correlation-request-id": "f92d0996-81d0-448e-9c2d-be362023a443", + "x-ms-ratelimit-remaining-subscription-reads": "11985", + "x-ms-response-type": "standard", + "x-ms-routing-request-id": "JAPANEAST:20221111T092212Z:f92d0996-81d0-448e-9c2d-be362023a443", + "x-request-time": "0.194" + }, + "ResponseBody": null + } + ], + "Variables": {} +} From a49610506618a965d01335a1ff5d2a2a21b732e0 Mon Sep 17 00:00:00 2001 From: Azure SDK Bot <53356347+azure-sdk@users.noreply.github.com> Date: Wed, 16 Nov 2022 22:24:17 -0500 Subject: [PATCH 7/7] code and test (#27488) Co-authored-by: PythonSdkPipelines --- sdk/storage/azure-mgmt-storage/CHANGELOG.md | 18 + sdk/storage/azure-mgmt-storage/MANIFEST.in | 1 + sdk/storage/azure-mgmt-storage/_meta.json | 12 +- .../azure/mgmt/storage/__init__.py | 4 + .../azure/mgmt/storage/_configuration.py | 12 +- .../azure/mgmt/storage/_serialization.py | 2006 ++++ .../storage/_storage_management_client.py | 104 +- .../azure/mgmt/storage/_version.py | 2 +- .../azure/mgmt/storage/aio/_configuration.py | 4 +- .../storage/aio/_storage_management_client.py | 95 +- .../azure/mgmt/storage/models.py | 2 +- .../mgmt/storage/v2015_06_15/__init__.py | 5 +- .../storage/v2015_06_15/_configuration.py | 48 +- .../mgmt/storage/v2015_06_15/_metadata.json | 20 +- .../azure/mgmt/storage/v2015_06_15/_patch.py | 2 +- .../v2015_06_15/_storage_management.py | 23 +- .../azure/mgmt/storage/v2015_06_15/_vendor.py | 6 +- .../mgmt/storage/v2015_06_15/_version.py | 2 +- .../mgmt/storage/v2015_06_15/aio/__init__.py | 5 +- .../storage/v2015_06_15/aio/_configuration.py | 50 +- .../mgmt/storage/v2015_06_15/aio/_patch.py | 2 +- .../v2015_06_15/aio/_storage_management.py | 23 +- .../v2015_06_15/aio/operations/__init__.py | 7 +- .../v2015_06_15/aio/operations/_patch.py | 1 + .../_storage_accounts_operations.py | 774 +- .../aio/operations/_usage_operations.py | 78 +- .../storage/v2015_06_15/models/__init__.py | 54 +- .../storage/v2015_06_15/models/_models_py3.py | 352 +- .../mgmt/storage/v2015_06_15/models/_patch.py | 1 + .../models/_storage_management_enums.py | 10 +- .../v2015_06_15/operations/__init__.py | 7 +- .../storage/v2015_06_15/operations/_patch.py | 1 + .../_storage_accounts_operations.py | 1106 ++- .../operations/_usage_operations.py | 106 +- .../mgmt/storage/v2016_01_01/__init__.py | 5 +- .../storage/v2016_01_01/_configuration.py | 48 +- .../mgmt/storage/v2016_01_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2016_01_01/_patch.py | 2 +- .../v2016_01_01/_storage_management_client.py | 27 +- .../azure/mgmt/storage/v2016_01_01/_vendor.py | 6 +- .../mgmt/storage/v2016_01_01/_version.py | 2 +- .../mgmt/storage/v2016_01_01/aio/__init__.py | 5 +- .../storage/v2016_01_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2016_01_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 27 +- .../v2016_01_01/aio/operations/__init__.py | 7 +- .../v2016_01_01/aio/operations/_patch.py | 1 + .../_storage_accounts_operations.py | 765 +- .../aio/operations/_usage_operations.py | 78 +- .../storage/v2016_01_01/models/__init__.py | 84 +- .../storage/v2016_01_01/models/_models_py3.py | 585 +- .../mgmt/storage/v2016_01_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 38 +- .../v2016_01_01/operations/__init__.py | 7 +- .../storage/v2016_01_01/operations/_patch.py | 1 + .../_storage_accounts_operations.py | 1083 ++- .../operations/_usage_operations.py | 106 +- .../mgmt/storage/v2016_12_01/__init__.py | 5 +- .../storage/v2016_12_01/_configuration.py | 48 +- .../mgmt/storage/v2016_12_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2016_12_01/_patch.py | 2 +- .../v2016_12_01/_storage_management.py | 23 +- .../azure/mgmt/storage/v2016_12_01/_vendor.py | 6 +- .../mgmt/storage/v2016_12_01/_version.py | 2 +- .../mgmt/storage/v2016_12_01/aio/__init__.py | 5 +- .../storage/v2016_12_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2016_12_01/aio/_patch.py | 2 +- .../v2016_12_01/aio/_storage_management.py | 23 +- .../v2016_12_01/aio/operations/__init__.py | 7 +- .../v2016_12_01/aio/operations/_patch.py | 1 + .../_storage_accounts_operations.py | 981 +- .../aio/operations/_usage_operations.py | 78 +- .../storage/v2016_12_01/models/__init__.py | 116 +- .../storage/v2016_12_01/models/_models_py3.py | 764 +- .../mgmt/storage/v2016_12_01/models/_patch.py | 1 + .../models/_storage_management_enums.py | 47 +- .../v2016_12_01/operations/__init__.py | 7 +- .../storage/v2016_12_01/operations/_patch.py | 1 + .../_storage_accounts_operations.py | 1401 +-- .../operations/_usage_operations.py | 106 +- .../mgmt/storage/v2017_06_01/__init__.py | 5 +- .../storage/v2017_06_01/_configuration.py | 48 +- .../mgmt/storage/v2017_06_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2017_06_01/_patch.py | 2 +- .../v2017_06_01/_storage_management.py | 31 +- .../azure/mgmt/storage/v2017_06_01/_vendor.py | 6 +- .../mgmt/storage/v2017_06_01/_version.py | 2 +- .../mgmt/storage/v2017_06_01/aio/__init__.py | 5 +- .../storage/v2017_06_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2017_06_01/aio/_patch.py | 2 +- .../v2017_06_01/aio/_storage_management.py | 31 +- .../v2017_06_01/aio/operations/__init__.py | 11 +- .../v2017_06_01/aio/operations/_operations.py | 76 +- .../v2017_06_01/aio/operations/_patch.py | 1 + .../aio/operations/_skus_operations.py | 79 +- .../_storage_accounts_operations.py | 981 +- .../aio/operations/_usage_operations.py | 78 +- .../storage/v2017_06_01/models/__init__.py | 156 +- .../storage/v2017_06_01/models/_models_py3.py | 1077 +-- .../mgmt/storage/v2017_06_01/models/_patch.py | 1 + .../models/_storage_management_enums.py | 47 +- .../v2017_06_01/operations/__init__.py | 11 +- .../v2017_06_01/operations/_operations.py | 103 +- .../storage/v2017_06_01/operations/_patch.py | 1 + .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 1401 +-- .../operations/_usage_operations.py | 106 +- .../mgmt/storage/v2017_10_01/__init__.py | 5 +- .../storage/v2017_10_01/_configuration.py | 48 +- .../mgmt/storage/v2017_10_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2017_10_01/_patch.py | 2 +- .../v2017_10_01/_storage_management.py | 31 +- .../azure/mgmt/storage/v2017_10_01/_vendor.py | 6 +- .../mgmt/storage/v2017_10_01/_version.py | 2 +- .../mgmt/storage/v2017_10_01/aio/__init__.py | 5 +- .../storage/v2017_10_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2017_10_01/aio/_patch.py | 2 +- .../v2017_10_01/aio/_storage_management.py | 31 +- .../v2017_10_01/aio/operations/__init__.py | 11 +- .../v2017_10_01/aio/operations/_operations.py | 76 +- .../v2017_10_01/aio/operations/_patch.py | 1 + .../aio/operations/_skus_operations.py | 79 +- .../_storage_accounts_operations.py | 981 +- .../aio/operations/_usage_operations.py | 78 +- .../storage/v2017_10_01/models/__init__.py | 156 +- .../storage/v2017_10_01/models/_models_py3.py | 1082 +-- .../mgmt/storage/v2017_10_01/models/_patch.py | 1 + .../models/_storage_management_enums.py | 47 +- .../v2017_10_01/operations/__init__.py | 11 +- .../v2017_10_01/operations/_operations.py | 103 +- .../storage/v2017_10_01/operations/_patch.py | 1 + .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 1401 +-- .../operations/_usage_operations.py | 106 +- .../mgmt/storage/v2018_02_01/__init__.py | 5 +- .../storage/v2018_02_01/_configuration.py | 48 +- .../mgmt/storage/v2018_02_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2018_02_01/_patch.py | 2 +- .../v2018_02_01/_storage_management_client.py | 39 +- .../azure/mgmt/storage/v2018_02_01/_vendor.py | 6 +- .../mgmt/storage/v2018_02_01/_version.py | 2 +- .../mgmt/storage/v2018_02_01/aio/__init__.py | 5 +- .../storage/v2018_02_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2018_02_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 39 +- .../v2018_02_01/aio/operations/__init__.py | 13 +- .../operations/_blob_containers_operations.py | 1248 ++- .../v2018_02_01/aio/operations/_operations.py | 76 +- .../v2018_02_01/aio/operations/_patch.py | 1 + .../aio/operations/_skus_operations.py | 79 +- .../_storage_accounts_operations.py | 981 +- .../aio/operations/_usage_operations.py | 142 +- .../storage/v2018_02_01/models/__init__.py | 212 +- .../storage/v2018_02_01/models/_models_py3.py | 1525 ++-- .../mgmt/storage/v2018_02_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 77 +- .../v2018_02_01/operations/__init__.py | 13 +- .../operations/_blob_containers_operations.py | 1766 ++-- .../v2018_02_01/operations/_operations.py | 103 +- .../storage/v2018_02_01/operations/_patch.py | 1 + .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 1401 +-- .../operations/_usage_operations.py | 205 +- .../storage/v2018_03_01_preview/__init__.py | 5 +- .../v2018_03_01_preview/_configuration.py | 48 +- .../v2018_03_01_preview/_metadata.json | 20 +- .../storage/v2018_03_01_preview/_patch.py | 2 +- .../_storage_management_client.py | 47 +- .../storage/v2018_03_01_preview/_vendor.py | 6 +- .../storage/v2018_03_01_preview/_version.py | 2 +- .../v2018_03_01_preview/aio/__init__.py | 5 +- .../v2018_03_01_preview/aio/_configuration.py | 50 +- .../storage/v2018_03_01_preview/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 47 +- .../aio/operations/__init__.py | 13 +- .../operations/_blob_containers_operations.py | 1288 ++- .../aio/operations/_operations.py | 78 +- .../aio/operations/_patch.py | 1 + .../aio/operations/_skus_operations.py | 80 +- .../_storage_accounts_operations.py | 1218 ++- .../aio/operations/_usages_operations.py | 144 +- .../v2018_03_01_preview/models/__init__.py | 224 +- .../v2018_03_01_preview/models/_models_py3.py | 1614 ++-- .../v2018_03_01_preview/models/_patch.py | 1 + .../_storage_management_client_enums.py | 79 +- .../operations/__init__.py | 13 +- .../operations/_blob_containers_operations.py | 1832 ++-- .../operations/_operations.py | 107 +- .../v2018_03_01_preview/operations/_patch.py | 1 + .../operations/_skus_operations.py | 112 +- .../_storage_accounts_operations.py | 1770 ++-- .../operations/_usages_operations.py | 215 +- .../mgmt/storage/v2018_07_01/__init__.py | 5 +- .../storage/v2018_07_01/_configuration.py | 40 +- .../mgmt/storage/v2018_07_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2018_07_01/_patch.py | 2 +- .../v2018_07_01/_storage_management_client.py | 53 +- .../azure/mgmt/storage/v2018_07_01/_vendor.py | 6 +- .../mgmt/storage/v2018_07_01/_version.py | 2 +- .../mgmt/storage/v2018_07_01/aio/__init__.py | 5 +- .../storage/v2018_07_01/aio/_configuration.py | 42 +- .../mgmt/storage/v2018_07_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 53 +- .../v2018_07_01/aio/operations/__init__.py | 17 +- .../operations/_blob_containers_operations.py | 1287 ++- .../operations/_blob_services_operations.py | 214 +- .../_management_policies_operations.py | 245 +- .../v2018_07_01/aio/operations/_operations.py | 69 +- .../v2018_07_01/aio/operations/_patch.py | 1 + .../aio/operations/_skus_operations.py | 72 +- .../_storage_accounts_operations.py | 1081 ++- .../aio/operations/_usages_operations.py | 77 +- .../storage/v2018_07_01/models/__init__.py | 242 +- .../storage/v2018_07_01/models/_models_py3.py | 1767 ++-- .../mgmt/storage/v2018_07_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 82 +- .../v2018_07_01/operations/__init__.py | 17 +- .../operations/_blob_containers_operations.py | 1805 ++-- .../operations/_blob_services_operations.py | 288 +- .../_management_policies_operations.py | 352 +- .../v2018_07_01/operations/_operations.py | 94 +- .../storage/v2018_07_01/operations/_patch.py | 1 + .../operations/_skus_operations.py | 99 +- .../_storage_accounts_operations.py | 1528 ++-- .../operations/_usages_operations.py | 110 +- .../mgmt/storage/v2018_11_01/__init__.py | 5 +- .../storage/v2018_11_01/_configuration.py | 48 +- .../mgmt/storage/v2018_11_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2018_11_01/_patch.py | 2 +- .../v2018_11_01/_storage_management_client.py | 53 +- .../azure/mgmt/storage/v2018_11_01/_vendor.py | 6 +- .../mgmt/storage/v2018_11_01/_version.py | 2 +- .../mgmt/storage/v2018_11_01/aio/__init__.py | 5 +- .../storage/v2018_11_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2018_11_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 53 +- .../v2018_11_01/aio/operations/__init__.py | 17 +- .../operations/_blob_containers_operations.py | 1250 ++- .../operations/_blob_services_operations.py | 208 +- .../_management_policies_operations.py | 229 +- .../v2018_11_01/aio/operations/_operations.py | 76 +- .../v2018_11_01/aio/operations/_patch.py | 1 + .../aio/operations/_skus_operations.py | 79 +- .../_storage_accounts_operations.py | 1100 ++- .../aio/operations/_usages_operations.py | 84 +- .../storage/v2018_11_01/models/__init__.py | 258 +- .../storage/v2018_11_01/models/_models_py3.py | 1897 ++-- .../mgmt/storage/v2018_11_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 86 +- .../v2018_11_01/operations/__init__.py | 17 +- .../operations/_blob_containers_operations.py | 1768 ++-- .../operations/_blob_services_operations.py | 282 +- .../_management_policies_operations.py | 330 +- .../v2018_11_01/operations/_operations.py | 103 +- .../storage/v2018_11_01/operations/_patch.py | 1 + .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 1575 ++-- .../operations/_usages_operations.py | 119 +- .../mgmt/storage/v2019_04_01/__init__.py | 5 +- .../storage/v2019_04_01/_configuration.py | 48 +- .../mgmt/storage/v2019_04_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2019_04_01/_patch.py | 2 +- .../v2019_04_01/_storage_management_client.py | 63 +- .../azure/mgmt/storage/v2019_04_01/_vendor.py | 6 +- .../mgmt/storage/v2019_04_01/_version.py | 2 +- .../mgmt/storage/v2019_04_01/aio/__init__.py | 5 +- .../storage/v2019_04_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2019_04_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 63 +- .../v2019_04_01/aio/operations/__init__.py | 21 +- .../operations/_blob_containers_operations.py | 1275 ++- .../operations/_blob_services_operations.py | 274 +- .../operations/_file_services_operations.py | 247 +- .../aio/operations/_file_shares_operations.py | 429 +- .../_management_policies_operations.py | 229 +- .../v2019_04_01/aio/operations/_operations.py | 76 +- .../v2019_04_01/aio/operations/_patch.py | 1 + .../aio/operations/_skus_operations.py | 79 +- .../_storage_accounts_operations.py | 1106 ++- .../aio/operations/_usages_operations.py | 84 +- .../storage/v2019_04_01/models/__init__.py | 290 +- .../storage/v2019_04_01/models/_models_py3.py | 2221 ++--- .../mgmt/storage/v2019_04_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 95 +- .../v2019_04_01/operations/__init__.py | 21 +- .../operations/_blob_containers_operations.py | 1794 ++-- .../operations/_blob_services_operations.py | 386 +- .../operations/_file_services_operations.py | 356 +- .../operations/_file_shares_operations.py | 630 +- .../_management_policies_operations.py | 330 +- .../v2019_04_01/operations/_operations.py | 103 +- .../storage/v2019_04_01/operations/_patch.py | 1 + .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 1580 ++-- .../operations/_usages_operations.py | 119 +- .../mgmt/storage/v2019_06_01/__init__.py | 5 +- .../storage/v2019_06_01/_configuration.py | 48 +- .../mgmt/storage/v2019_06_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2019_06_01/_patch.py | 2 +- .../v2019_06_01/_storage_management_client.py | 88 +- .../azure/mgmt/storage/v2019_06_01/_vendor.py | 6 +- .../mgmt/storage/v2019_06_01/_version.py | 2 +- .../mgmt/storage/v2019_06_01/aio/__init__.py | 5 +- .../storage/v2019_06_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2019_06_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 88 +- .../v2019_06_01/aio/operations/__init__.py | 39 +- .../operations/_blob_containers_operations.py | 1279 ++- .../_blob_inventory_policies_operations.py | 295 +- .../operations/_blob_services_operations.py | 274 +- .../_encryption_scopes_operations.py | 397 +- .../operations/_file_services_operations.py | 247 +- .../aio/operations/_file_shares_operations.py | 555 +- .../_management_policies_operations.py | 229 +- ..._object_replication_policies_operations.py | 299 +- .../v2019_06_01/aio/operations/_operations.py | 76 +- .../v2019_06_01/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 300 +- .../_private_link_resources_operations.py | 56 +- .../aio/operations/_queue_operations.py | 428 +- .../operations/_queue_services_operations.py | 248 +- .../aio/operations/_skus_operations.py | 78 +- .../_storage_accounts_operations.py | 1281 ++- .../aio/operations/_table_operations.py | 262 +- .../operations/_table_services_operations.py | 248 +- .../aio/operations/_usages_operations.py | 84 +- .../storage/v2019_06_01/models/__init__.py | 440 +- .../storage/v2019_06_01/models/_models_py3.py | 3361 ++++--- .../mgmt/storage/v2019_06_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 138 +- .../v2019_06_01/operations/__init__.py | 39 +- .../operations/_blob_containers_operations.py | 1800 ++-- .../_blob_inventory_policies_operations.py | 438 +- .../operations/_blob_services_operations.py | 386 +- .../_encryption_scopes_operations.py | 574 +- .../operations/_file_services_operations.py | 356 +- .../operations/_file_shares_operations.py | 801 +- .../_management_policies_operations.py | 330 +- ..._object_replication_policies_operations.py | 460 +- .../v2019_06_01/operations/_operations.py | 103 +- .../storage/v2019_06_01/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 449 +- .../_private_link_resources_operations.py | 94 +- .../operations/_queue_operations.py | 655 +- .../operations/_queue_services_operations.py | 357 +- .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 1799 ++-- .../operations/_table_operations.py | 461 +- .../operations/_table_services_operations.py | 357 +- .../operations/_usages_operations.py | 119 +- .../storage/v2020_08_01_preview/__init__.py | 5 +- .../v2020_08_01_preview/_configuration.py | 48 +- .../v2020_08_01_preview/_metadata.json | 20 +- .../storage/v2020_08_01_preview/_patch.py | 2 +- .../_storage_management_client.py | 89 +- .../storage/v2020_08_01_preview/_vendor.py | 6 +- .../storage/v2020_08_01_preview/_version.py | 2 +- .../v2020_08_01_preview/aio/__init__.py | 5 +- .../v2020_08_01_preview/aio/_configuration.py | 50 +- .../storage/v2020_08_01_preview/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 89 +- .../aio/operations/__init__.py | 41 +- .../operations/_blob_containers_operations.py | 1319 ++- .../_blob_inventory_policies_operations.py | 303 +- .../operations/_blob_services_operations.py | 280 +- .../_deleted_accounts_operations.py | 121 +- .../_encryption_scopes_operations.py | 405 +- .../operations/_file_services_operations.py | 253 +- .../aio/operations/_file_shares_operations.py | 579 +- .../_management_policies_operations.py | 235 +- ..._object_replication_policies_operations.py | 307 +- .../aio/operations/_operations.py | 78 +- .../aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 309 +- .../_private_link_resources_operations.py | 58 +- .../aio/operations/_queue_operations.py | 438 +- .../operations/_queue_services_operations.py | 254 +- .../aio/operations/_skus_operations.py | 80 +- .../_storage_accounts_operations.py | 1322 ++- .../aio/operations/_table_operations.py | 271 +- .../operations/_table_services_operations.py | 254 +- .../aio/operations/_usages_operations.py | 85 +- .../v2020_08_01_preview/models/__init__.py | 464 +- .../v2020_08_01_preview/models/_models_py3.py | 3532 ++++---- .../v2020_08_01_preview/models/_patch.py | 1 + .../_storage_management_client_enums.py | 144 +- .../operations/__init__.py | 41 +- .../operations/_blob_containers_operations.py | 1866 ++-- .../_blob_inventory_policies_operations.py | 454 +- .../operations/_blob_services_operations.py | 397 +- .../_deleted_accounts_operations.py | 196 +- .../_encryption_scopes_operations.py | 589 +- .../operations/_file_services_operations.py | 368 +- .../operations/_file_shares_operations.py | 832 +- .../_management_policies_operations.py | 342 +- ..._object_replication_policies_operations.py | 476 +- .../operations/_operations.py | 107 +- .../v2020_08_01_preview/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 466 +- .../_private_link_resources_operations.py | 98 +- .../operations/_queue_operations.py | 676 +- .../operations/_queue_services_operations.py | 369 +- .../operations/_skus_operations.py | 111 +- .../_storage_accounts_operations.py | 1870 ++-- .../operations/_table_operations.py | 482 +- .../operations/_table_services_operations.py | 369 +- .../operations/_usages_operations.py | 124 +- .../mgmt/storage/v2021_01_01/__init__.py | 5 +- .../storage/v2021_01_01/_configuration.py | 48 +- .../mgmt/storage/v2021_01_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2021_01_01/_patch.py | 2 +- .../v2021_01_01/_storage_management_client.py | 89 +- .../azure/mgmt/storage/v2021_01_01/_vendor.py | 6 +- .../mgmt/storage/v2021_01_01/_version.py | 2 +- .../mgmt/storage/v2021_01_01/aio/__init__.py | 5 +- .../storage/v2021_01_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2021_01_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 89 +- .../v2021_01_01/aio/operations/__init__.py | 41 +- .../operations/_blob_containers_operations.py | 1279 ++- .../_blob_inventory_policies_operations.py | 295 +- .../operations/_blob_services_operations.py | 274 +- .../_deleted_accounts_operations.py | 117 +- .../_encryption_scopes_operations.py | 397 +- .../operations/_file_services_operations.py | 247 +- .../aio/operations/_file_shares_operations.py | 565 +- .../_management_policies_operations.py | 229 +- ..._object_replication_policies_operations.py | 299 +- .../v2021_01_01/aio/operations/_operations.py | 76 +- .../v2021_01_01/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 300 +- .../_private_link_resources_operations.py | 56 +- .../aio/operations/_queue_operations.py | 428 +- .../operations/_queue_services_operations.py | 248 +- .../aio/operations/_skus_operations.py | 78 +- .../_storage_accounts_operations.py | 1281 ++- .../aio/operations/_table_operations.py | 262 +- .../operations/_table_services_operations.py | 248 +- .../aio/operations/_usages_operations.py | 84 +- .../storage/v2021_01_01/models/__init__.py | 476 +- .../storage/v2021_01_01/models/_models_py3.py | 3630 ++++---- .../mgmt/storage/v2021_01_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 150 +- .../v2021_01_01/operations/__init__.py | 41 +- .../operations/_blob_containers_operations.py | 1800 ++-- .../_blob_inventory_policies_operations.py | 438 +- .../operations/_blob_services_operations.py | 386 +- .../_deleted_accounts_operations.py | 189 +- .../_encryption_scopes_operations.py | 574 +- .../operations/_file_services_operations.py | 356 +- .../operations/_file_shares_operations.py | 806 +- .../_management_policies_operations.py | 330 +- ..._object_replication_policies_operations.py | 460 +- .../v2021_01_01/operations/_operations.py | 103 +- .../storage/v2021_01_01/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 449 +- .../_private_link_resources_operations.py | 94 +- .../operations/_queue_operations.py | 655 +- .../operations/_queue_services_operations.py | 357 +- .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 1799 ++-- .../operations/_table_operations.py | 461 +- .../operations/_table_services_operations.py | 357 +- .../operations/_usages_operations.py | 119 +- .../mgmt/storage/v2021_02_01/__init__.py | 5 +- .../storage/v2021_02_01/_configuration.py | 48 +- .../mgmt/storage/v2021_02_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2021_02_01/_patch.py | 2 +- .../v2021_02_01/_storage_management_client.py | 89 +- .../azure/mgmt/storage/v2021_02_01/_vendor.py | 6 +- .../mgmt/storage/v2021_02_01/_version.py | 2 +- .../mgmt/storage/v2021_02_01/aio/__init__.py | 5 +- .../storage/v2021_02_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2021_02_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 89 +- .../v2021_02_01/aio/operations/__init__.py | 41 +- .../operations/_blob_containers_operations.py | 1279 ++- .../_blob_inventory_policies_operations.py | 295 +- .../operations/_blob_services_operations.py | 274 +- .../_deleted_accounts_operations.py | 117 +- .../_encryption_scopes_operations.py | 397 +- .../operations/_file_services_operations.py | 247 +- .../aio/operations/_file_shares_operations.py | 565 +- .../_management_policies_operations.py | 229 +- ..._object_replication_policies_operations.py | 299 +- .../v2021_02_01/aio/operations/_operations.py | 76 +- .../v2021_02_01/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 300 +- .../_private_link_resources_operations.py | 56 +- .../aio/operations/_queue_operations.py | 428 +- .../operations/_queue_services_operations.py | 248 +- .../aio/operations/_skus_operations.py | 78 +- .../_storage_accounts_operations.py | 1281 ++- .../aio/operations/_table_operations.py | 262 +- .../operations/_table_services_operations.py | 248 +- .../aio/operations/_usages_operations.py | 84 +- .../storage/v2021_02_01/models/__init__.py | 486 +- .../storage/v2021_02_01/models/_models_py3.py | 3717 ++++---- .../mgmt/storage/v2021_02_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 154 +- .../v2021_02_01/operations/__init__.py | 41 +- .../operations/_blob_containers_operations.py | 1800 ++-- .../_blob_inventory_policies_operations.py | 438 +- .../operations/_blob_services_operations.py | 386 +- .../_deleted_accounts_operations.py | 189 +- .../_encryption_scopes_operations.py | 574 +- .../operations/_file_services_operations.py | 356 +- .../operations/_file_shares_operations.py | 806 +- .../_management_policies_operations.py | 330 +- ..._object_replication_policies_operations.py | 460 +- .../v2021_02_01/operations/_operations.py | 103 +- .../storage/v2021_02_01/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 449 +- .../_private_link_resources_operations.py | 94 +- .../operations/_queue_operations.py | 655 +- .../operations/_queue_services_operations.py | 357 +- .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 1799 ++-- .../operations/_table_operations.py | 461 +- .../operations/_table_services_operations.py | 357 +- .../operations/_usages_operations.py | 119 +- .../mgmt/storage/v2021_04_01/__init__.py | 5 +- .../storage/v2021_04_01/_configuration.py | 48 +- .../mgmt/storage/v2021_04_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2021_04_01/_patch.py | 2 +- .../v2021_04_01/_storage_management_client.py | 89 +- .../azure/mgmt/storage/v2021_04_01/_vendor.py | 6 +- .../mgmt/storage/v2021_04_01/_version.py | 2 +- .../mgmt/storage/v2021_04_01/aio/__init__.py | 5 +- .../storage/v2021_04_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2021_04_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 89 +- .../v2021_04_01/aio/operations/__init__.py | 41 +- .../operations/_blob_containers_operations.py | 1365 ++- .../_blob_inventory_policies_operations.py | 295 +- .../operations/_blob_services_operations.py | 274 +- .../_deleted_accounts_operations.py | 117 +- .../_encryption_scopes_operations.py | 397 +- .../operations/_file_services_operations.py | 247 +- .../aio/operations/_file_shares_operations.py | 697 +- .../_management_policies_operations.py | 229 +- ..._object_replication_policies_operations.py | 303 +- .../v2021_04_01/aio/operations/_operations.py | 76 +- .../v2021_04_01/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 300 +- .../_private_link_resources_operations.py | 56 +- .../aio/operations/_queue_operations.py | 428 +- .../operations/_queue_services_operations.py | 248 +- .../aio/operations/_skus_operations.py | 78 +- .../_storage_accounts_operations.py | 1281 ++- .../aio/operations/_table_operations.py | 262 +- .../operations/_table_services_operations.py | 248 +- .../aio/operations/_usages_operations.py | 84 +- .../storage/v2021_04_01/models/__init__.py | 516 +- .../storage/v2021_04_01/models/_models_py3.py | 3911 ++++---- .../mgmt/storage/v2021_04_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 170 +- .../v2021_04_01/operations/__init__.py | 41 +- .../operations/_blob_containers_operations.py | 1946 ++-- .../_blob_inventory_policies_operations.py | 438 +- .../operations/_blob_services_operations.py | 386 +- .../_deleted_accounts_operations.py | 189 +- .../_encryption_scopes_operations.py | 574 +- .../operations/_file_services_operations.py | 356 +- .../operations/_file_shares_operations.py | 974 +- .../_management_policies_operations.py | 330 +- ..._object_replication_policies_operations.py | 464 +- .../v2021_04_01/operations/_operations.py | 103 +- .../storage/v2021_04_01/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 449 +- .../_private_link_resources_operations.py | 94 +- .../operations/_queue_operations.py | 655 +- .../operations/_queue_services_operations.py | 357 +- .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 1799 ++-- .../operations/_table_operations.py | 461 +- .../operations/_table_services_operations.py | 357 +- .../operations/_usages_operations.py | 119 +- .../mgmt/storage/v2021_06_01/__init__.py | 5 +- .../storage/v2021_06_01/_configuration.py | 48 +- .../mgmt/storage/v2021_06_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2021_06_01/_patch.py | 2 +- .../v2021_06_01/_storage_management_client.py | 89 +- .../azure/mgmt/storage/v2021_06_01/_vendor.py | 6 +- .../mgmt/storage/v2021_06_01/_version.py | 2 +- .../mgmt/storage/v2021_06_01/aio/__init__.py | 5 +- .../storage/v2021_06_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2021_06_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 89 +- .../v2021_06_01/aio/operations/__init__.py | 41 +- .../operations/_blob_containers_operations.py | 1345 ++- .../_blob_inventory_policies_operations.py | 295 +- .../operations/_blob_services_operations.py | 257 +- .../_deleted_accounts_operations.py | 117 +- .../_encryption_scopes_operations.py | 397 +- .../operations/_file_services_operations.py | 230 +- .../aio/operations/_file_shares_operations.py | 697 +- .../_management_policies_operations.py | 229 +- ..._object_replication_policies_operations.py | 303 +- .../v2021_06_01/aio/operations/_operations.py | 76 +- .../v2021_06_01/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 300 +- .../_private_link_resources_operations.py | 56 +- .../aio/operations/_queue_operations.py | 428 +- .../operations/_queue_services_operations.py | 231 +- .../aio/operations/_skus_operations.py | 78 +- .../_storage_accounts_operations.py | 1457 ++- .../aio/operations/_table_operations.py | 262 +- .../operations/_table_services_operations.py | 231 +- .../aio/operations/_usages_operations.py | 84 +- .../storage/v2021_06_01/models/__init__.py | 528 +- .../storage/v2021_06_01/models/_models_py3.py | 4006 ++++---- .../mgmt/storage/v2021_06_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 166 +- .../v2021_06_01/operations/__init__.py | 41 +- .../operations/_blob_containers_operations.py | 1926 ++-- .../_blob_inventory_policies_operations.py | 438 +- .../operations/_blob_services_operations.py | 379 +- .../_deleted_accounts_operations.py | 189 +- .../_encryption_scopes_operations.py | 574 +- .../operations/_file_services_operations.py | 349 +- .../operations/_file_shares_operations.py | 974 +- .../_management_policies_operations.py | 330 +- ..._object_replication_policies_operations.py | 464 +- .../v2021_06_01/operations/_operations.py | 103 +- .../storage/v2021_06_01/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 449 +- .../_private_link_resources_operations.py | 94 +- .../operations/_queue_operations.py | 655 +- .../operations/_queue_services_operations.py | 350 +- .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 2053 +++-- .../operations/_table_operations.py | 461 +- .../operations/_table_services_operations.py | 350 +- .../operations/_usages_operations.py | 119 +- .../mgmt/storage/v2021_08_01/__init__.py | 5 +- .../storage/v2021_08_01/_configuration.py | 48 +- .../mgmt/storage/v2021_08_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2021_08_01/_patch.py | 2 +- .../v2021_08_01/_storage_management_client.py | 94 +- .../azure/mgmt/storage/v2021_08_01/_vendor.py | 6 +- .../mgmt/storage/v2021_08_01/_version.py | 2 +- .../mgmt/storage/v2021_08_01/aio/__init__.py | 5 +- .../storage/v2021_08_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2021_08_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 94 +- .../v2021_08_01/aio/operations/__init__.py | 43 +- .../operations/_blob_containers_operations.py | 1345 ++- .../_blob_inventory_policies_operations.py | 295 +- .../operations/_blob_services_operations.py | 257 +- .../_deleted_accounts_operations.py | 117 +- .../_encryption_scopes_operations.py | 397 +- .../operations/_file_services_operations.py | 230 +- .../aio/operations/_file_shares_operations.py | 697 +- .../aio/operations/_local_users_operations.py | 386 +- .../_management_policies_operations.py | 229 +- ..._object_replication_policies_operations.py | 303 +- .../v2021_08_01/aio/operations/_operations.py | 76 +- .../v2021_08_01/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 300 +- .../_private_link_resources_operations.py | 56 +- .../aio/operations/_queue_operations.py | 428 +- .../operations/_queue_services_operations.py | 231 +- .../aio/operations/_skus_operations.py | 78 +- .../_storage_accounts_operations.py | 1457 ++- .../aio/operations/_table_operations.py | 262 +- .../operations/_table_services_operations.py | 231 +- .../aio/operations/_usages_operations.py | 84 +- .../storage/v2021_08_01/models/__init__.py | 544 +- .../storage/v2021_08_01/models/_models_py3.py | 4163 ++++----- .../mgmt/storage/v2021_08_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 171 +- .../v2021_08_01/operations/__init__.py | 43 +- .../operations/_blob_containers_operations.py | 1926 ++-- .../_blob_inventory_policies_operations.py | 438 +- .../operations/_blob_services_operations.py | 379 +- .../_deleted_accounts_operations.py | 189 +- .../_encryption_scopes_operations.py | 574 +- .../operations/_file_services_operations.py | 349 +- .../operations/_file_shares_operations.py | 974 +- .../operations/_local_users_operations.py | 613 +- .../_management_policies_operations.py | 330 +- ..._object_replication_policies_operations.py | 464 +- .../v2021_08_01/operations/_operations.py | 103 +- .../storage/v2021_08_01/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 449 +- .../_private_link_resources_operations.py | 94 +- .../operations/_queue_operations.py | 655 +- .../operations/_queue_services_operations.py | 350 +- .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 2053 +++-- .../operations/_table_operations.py | 461 +- .../operations/_table_services_operations.py | 350 +- .../operations/_usages_operations.py | 119 +- .../mgmt/storage/v2021_09_01/__init__.py | 5 +- .../storage/v2021_09_01/_configuration.py | 48 +- .../mgmt/storage/v2021_09_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2021_09_01/_patch.py | 2 +- .../v2021_09_01/_storage_management_client.py | 94 +- .../azure/mgmt/storage/v2021_09_01/_vendor.py | 6 +- .../mgmt/storage/v2021_09_01/_version.py | 2 +- .../mgmt/storage/v2021_09_01/aio/__init__.py | 5 +- .../storage/v2021_09_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2021_09_01/aio/_patch.py | 2 +- .../aio/_storage_management_client.py | 94 +- .../v2021_09_01/aio/operations/__init__.py | 43 +- .../operations/_blob_containers_operations.py | 1345 ++- .../_blob_inventory_policies_operations.py | 295 +- .../operations/_blob_services_operations.py | 257 +- .../_deleted_accounts_operations.py | 117 +- .../_encryption_scopes_operations.py | 397 +- .../operations/_file_services_operations.py | 230 +- .../aio/operations/_file_shares_operations.py | 697 +- .../aio/operations/_local_users_operations.py | 386 +- .../_management_policies_operations.py | 229 +- ..._object_replication_policies_operations.py | 303 +- .../v2021_09_01/aio/operations/_operations.py | 76 +- .../v2021_09_01/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 300 +- .../_private_link_resources_operations.py | 56 +- .../aio/operations/_queue_operations.py | 428 +- .../operations/_queue_services_operations.py | 231 +- .../aio/operations/_skus_operations.py | 78 +- .../_storage_accounts_operations.py | 1457 ++- .../aio/operations/_table_operations.py | 432 +- .../operations/_table_services_operations.py | 231 +- .../aio/operations/_usages_operations.py | 84 +- .../storage/v2021_09_01/models/__init__.py | 558 +- .../storage/v2021_09_01/models/_models_py3.py | 4268 ++++----- .../mgmt/storage/v2021_09_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 173 +- .../v2021_09_01/operations/__init__.py | 43 +- .../operations/_blob_containers_operations.py | 1926 ++-- .../_blob_inventory_policies_operations.py | 438 +- .../operations/_blob_services_operations.py | 379 +- .../_deleted_accounts_operations.py | 189 +- .../_encryption_scopes_operations.py | 574 +- .../operations/_file_services_operations.py | 349 +- .../operations/_file_shares_operations.py | 974 +- .../operations/_local_users_operations.py | 613 +- .../_management_policies_operations.py | 330 +- ..._object_replication_policies_operations.py | 464 +- .../v2021_09_01/operations/_operations.py | 103 +- .../storage/v2021_09_01/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 449 +- .../_private_link_resources_operations.py | 94 +- .../operations/_queue_operations.py | 655 +- .../operations/_queue_services_operations.py | 350 +- .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 2053 +++-- .../operations/_table_operations.py | 645 +- .../operations/_table_services_operations.py | 350 +- .../operations/_usages_operations.py | 119 +- .../mgmt/storage/v2022_05_01/__init__.py | 5 +- .../storage/v2022_05_01/_configuration.py | 48 +- .../mgmt/storage/v2022_05_01/_metadata.json | 20 +- .../azure/mgmt/storage/v2022_05_01/_patch.py | 1 + .../v2022_05_01/_storage_management_client.py | 94 +- .../azure/mgmt/storage/v2022_05_01/_vendor.py | 6 +- .../mgmt/storage/v2022_05_01/_version.py | 2 +- .../mgmt/storage/v2022_05_01/aio/__init__.py | 5 +- .../storage/v2022_05_01/aio/_configuration.py | 50 +- .../mgmt/storage/v2022_05_01/aio/_patch.py | 1 + .../aio/_storage_management_client.py | 94 +- .../v2022_05_01/aio/operations/__init__.py | 43 +- .../operations/_blob_containers_operations.py | 1345 ++- .../_blob_inventory_policies_operations.py | 295 +- .../operations/_blob_services_operations.py | 257 +- .../_deleted_accounts_operations.py | 117 +- .../_encryption_scopes_operations.py | 397 +- .../operations/_file_services_operations.py | 230 +- .../aio/operations/_file_shares_operations.py | 697 +- .../aio/operations/_local_users_operations.py | 386 +- .../_management_policies_operations.py | 229 +- ..._object_replication_policies_operations.py | 303 +- .../v2022_05_01/aio/operations/_operations.py | 76 +- .../v2022_05_01/aio/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 300 +- .../_private_link_resources_operations.py | 56 +- .../aio/operations/_queue_operations.py | 428 +- .../operations/_queue_services_operations.py | 231 +- .../aio/operations/_skus_operations.py | 78 +- .../_storage_accounts_operations.py | 1457 ++- .../aio/operations/_table_operations.py | 432 +- .../operations/_table_services_operations.py | 231 +- .../aio/operations/_usages_operations.py | 84 +- .../storage/v2022_05_01/models/__init__.py | 558 +- .../storage/v2022_05_01/models/_models_py3.py | 4239 ++++----- .../mgmt/storage/v2022_05_01/models/_patch.py | 1 + .../_storage_management_client_enums.py | 173 +- .../v2022_05_01/operations/__init__.py | 43 +- .../operations/_blob_containers_operations.py | 1926 ++-- .../_blob_inventory_policies_operations.py | 438 +- .../operations/_blob_services_operations.py | 379 +- .../_deleted_accounts_operations.py | 189 +- .../_encryption_scopes_operations.py | 574 +- .../operations/_file_services_operations.py | 349 +- .../operations/_file_shares_operations.py | 974 +- .../operations/_local_users_operations.py | 613 +- .../_management_policies_operations.py | 330 +- ..._object_replication_policies_operations.py | 464 +- .../v2022_05_01/operations/_operations.py | 103 +- .../storage/v2022_05_01/operations/_patch.py | 1 + ...private_endpoint_connections_operations.py | 449 +- .../_private_link_resources_operations.py | 94 +- .../operations/_queue_operations.py | 655 +- .../operations/_queue_services_operations.py | 350 +- .../operations/_skus_operations.py | 108 +- .../_storage_accounts_operations.py | 2053 +++-- .../operations/_table_operations.py | 645 +- .../operations/_table_services_operations.py | 350 +- .../operations/_usages_operations.py | 119 +- .../mgmt/storage/v2022_09_01/__init__.py | 26 + .../storage/v2022_09_01/_configuration.py | 75 + .../mgmt/storage/v2022_09_01/_metadata.json | 121 + .../azure/mgmt/storage/v2022_09_01/_patch.py | 20 + .../v2022_09_01/_storage_management_client.py | 194 + .../azure/mgmt/storage/v2022_09_01/_vendor.py | 27 + .../mgmt/storage/v2022_09_01/_version.py | 9 + .../mgmt/storage/v2022_09_01/aio/__init__.py | 23 + .../storage/v2022_09_01/aio/_configuration.py | 72 + .../mgmt/storage/v2022_09_01/aio/_patch.py | 20 + .../aio/_storage_management_client.py | 194 + .../v2022_09_01/aio/operations/__init__.py | 57 + .../operations/_blob_containers_operations.py | 1942 ++++ .../_blob_inventory_policies_operations.py | 457 + .../operations/_blob_services_operations.py | 390 + .../_deleted_accounts_operations.py | 199 + .../_encryption_scopes_operations.py | 588 ++ .../operations/_file_services_operations.py | 355 + .../aio/operations/_file_shares_operations.py | 1042 +++ .../aio/operations/_local_users_operations.py | 581 ++ .../_management_policies_operations.py | 361 + ..._object_replication_policies_operations.py | 460 + .../v2022_09_01/aio/operations/_operations.py | 137 + .../v2022_09_01/aio/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 447 + .../_private_link_resources_operations.py | 119 + .../aio/operations/_queue_operations.py | 631 ++ .../operations/_queue_services_operations.py | 356 + .../aio/operations/_skus_operations.py | 138 + .../_storage_accounts_operations.py | 2058 +++++ .../aio/operations/_table_operations.py | 611 ++ .../operations/_table_services_operations.py | 356 + .../aio/operations/_usages_operations.py | 141 + .../storage/v2022_09_01/models/__init__.py | 443 + .../storage/v2022_09_01/models/_models_py3.py | 8064 +++++++++++++++++ .../mgmt/storage/v2022_09_01/models/_patch.py | 20 + .../_storage_management_client_enums.py | 592 ++ .../v2022_09_01/operations/__init__.py | 57 + .../operations/_blob_containers_operations.py | 2474 +++++ .../_blob_inventory_policies_operations.py | 602 ++ .../operations/_blob_services_operations.py | 492 + .../_deleted_accounts_operations.py | 255 + .../_encryption_scopes_operations.py | 744 ++ .../operations/_file_services_operations.py | 458 + .../operations/_file_shares_operations.py | 1335 +++ .../operations/_local_users_operations.py | 779 ++ .../_management_policies_operations.py | 471 + ..._object_replication_policies_operations.py | 599 ++ .../v2022_09_01/operations/_operations.py | 158 + .../storage/v2022_09_01/operations/_patch.py | 20 + ...private_endpoint_connections_operations.py | 598 ++ .../_private_link_resources_operations.py | 155 + .../operations/_queue_operations.py | 837 ++ .../operations/_queue_services_operations.py | 459 + .../operations/_skus_operations.py | 164 + .../_storage_accounts_operations.py | 2567 ++++++ .../operations/_table_operations.py | 788 ++ .../operations/_table_services_operations.py | 459 + .../operations/_usages_operations.py | 171 + .../azure/mgmt/storage/v2022_09_01/py.typed | 1 + sdk/storage/azure-mgmt-storage/setup.py | 8 +- shared_requirements.txt | 1 + 874 files changed, 201186 insertions(+), 105846 deletions(-) create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_serialization.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/__init__.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_configuration.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_metadata.json create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_storage_management_client.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_vendor.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_version.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/__init__.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_configuration.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_storage_management_client.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/__init__.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_containers_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_inventory_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_deleted_accounts_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_encryption_scopes_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_shares_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_local_users_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_management_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_object_replication_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_link_resources_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_skus_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_storage_accounts_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_usages_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/__init__.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_models_py3.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_storage_management_client_enums.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/__init__.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_containers_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_inventory_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_deleted_accounts_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_encryption_scopes_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_shares_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_local_users_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_management_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_object_replication_policies_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_patch.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_endpoint_connections_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_link_resources_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_skus_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_storage_accounts_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_services_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_usages_operations.py create mode 100644 sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/py.typed diff --git a/sdk/storage/azure-mgmt-storage/CHANGELOG.md b/sdk/storage/azure-mgmt-storage/CHANGELOG.md index 54fbaff7a54f..c030c998a1c1 100644 --- a/sdk/storage/azure-mgmt-storage/CHANGELOG.md +++ b/sdk/storage/azure-mgmt-storage/CHANGELOG.md @@ -1,5 +1,23 @@ # Release History +## 21.0.0 (2022-11-15) + +### Features Added + + - Model ManagementPolicyBaseBlob has a new parameter tier_to_cold + - Model ManagementPolicyBaseBlob has a new parameter tier_to_hot + - Model ManagementPolicySnapShot has a new parameter tier_to_cold + - Model ManagementPolicySnapShot has a new parameter tier_to_hot + - Model ManagementPolicyVersion has a new parameter tier_to_cold + - Model ManagementPolicyVersion has a new parameter tier_to_hot + +### Breaking Changes + + - Operation EncryptionScopesOperations.list has a new parameter filter + - Operation EncryptionScopesOperations.list has a new parameter include + - Operation EncryptionScopesOperations.list has a new parameter maxpagesize + - Operation StorageAccountsOperations.begin_failover has a new parameter failover_type + ## 20.1.0 (2022-08-09) **Features** diff --git a/sdk/storage/azure-mgmt-storage/MANIFEST.in b/sdk/storage/azure-mgmt-storage/MANIFEST.in index ba13e7ff0588..8d61147dea8a 100644 --- a/sdk/storage/azure-mgmt-storage/MANIFEST.in +++ b/sdk/storage/azure-mgmt-storage/MANIFEST.in @@ -1,5 +1,6 @@ include _meta.json recursive-include tests *.py *.json +recursive-include samples *.py *.md include *.md include azure/__init__.py include azure/mgmt/__init__.py diff --git a/sdk/storage/azure-mgmt-storage/_meta.json b/sdk/storage/azure-mgmt-storage/_meta.json index c8ac11333c76..68e232edd5c9 100644 --- a/sdk/storage/azure-mgmt-storage/_meta.json +++ b/sdk/storage/azure-mgmt-storage/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.7.2", + "commit": "8bcf420c12d61a1639dd470d511e6210869f44b6", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest": "3.9.2", "use": [ - "@autorest/python@5.16.0", - "@autorest/modelerfour@4.19.3" + "@autorest/python@6.2.1", + "@autorest/modelerfour@4.24.3" ], - "commit": "1b3b9c1dd4d2c875997ea0b392dc71418fb1f28d", - "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/storage/resource-manager/readme.md --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "autorest_command": "autorest specification/storage/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.2.1 --use=@autorest/modelerfour@4.24.3 --version=3.9.2 --version-tolerant=False", "readme": "specification/storage/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/__init__.py index 75a361344ca2..f6821446dc1a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/__init__.py @@ -14,3 +14,7 @@ patch_sdk() except ImportError: pass + +from ._version import VERSION + +__version__ = VERSION diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_configuration.py index 9fd62cfe9c0c..1ea571a7c68a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_configuration.py @@ -8,7 +8,7 @@ # Changes may cause incorrect behavior and will be lost if the code is # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies @@ -18,8 +18,6 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential class StorageManagementClientConfiguration(Configuration): @@ -28,16 +26,16 @@ class StorageManagementClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, **kwargs # type: Any ): # type: (...) -> None diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_serialization.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_serialization.py new file mode 100644 index 000000000000..240df16c57f3 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_serialization.py @@ -0,0 +1,2006 @@ +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# pylint: skip-file + +from base64 import b64decode, b64encode +import calendar +import datetime +import decimal +import email +from enum import Enum +import json +import logging +import re +import sys +import codecs +try: + from urllib import quote # type: ignore +except ImportError: + from urllib.parse import quote # type: ignore +import xml.etree.ElementTree as ET + +import isodate + +from typing import Dict, Any, cast, TYPE_CHECKING + +from azure.core.exceptions import DeserializationError, SerializationError, raise_with_traceback + +_BOM = codecs.BOM_UTF8.decode(encoding='utf-8') + +if TYPE_CHECKING: + from typing import Optional, Union, AnyStr, IO, Mapping + +class RawDeserializer: + + # Accept "text" because we're open minded people... + JSON_REGEXP = re.compile(r'^(application|text)/([a-z+.]+\+)?json$') + + # Name used in context + CONTEXT_NAME = "deserialized_data" + + @classmethod + def deserialize_from_text(cls, data, content_type=None): + # type: (Optional[Union[AnyStr, IO]], Optional[str]) -> Any + """Decode data according to content-type. + + Accept a stream of data as well, but will be load at once in memory for now. + + If no content-type, will return the string version (not bytes, not stream) + + :param data: Input, could be bytes or stream (will be decoded with UTF8) or text + :type data: str or bytes or IO + :param str content_type: The content type. + """ + if hasattr(data, 'read'): + # Assume a stream + data = cast(IO, data).read() + + if isinstance(data, bytes): + data_as_str = data.decode(encoding='utf-8-sig') + else: + # Explain to mypy the correct type. + data_as_str = cast(str, data) + + # Remove Byte Order Mark if present in string + data_as_str = data_as_str.lstrip(_BOM) + + if content_type is None: + return data + + if cls.JSON_REGEXP.match(content_type): + try: + return json.loads(data_as_str) + except ValueError as err: + raise DeserializationError("JSON is invalid: {}".format(err), err) + elif "xml" in (content_type or []): + try: + + try: + if isinstance(data, unicode): # type: ignore + # If I'm Python 2.7 and unicode XML will scream if I try a "fromstring" on unicode string + data_as_str = data_as_str.encode(encoding="utf-8") # type: ignore + except NameError: + pass + + return ET.fromstring(data_as_str) # nosec + except ET.ParseError: + # 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 + # let's flow the initial exception + def _json_attemp(data): + try: + return True, json.loads(data) + except ValueError: + return False, None # Don't care about this one + success, json_result = _json_attemp(data) + if success: + return json_result + # If i'm here, it's not JSON, it's not XML, let's scream + # and raise the last context in this block (the XML exception) + # 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("Cannot deserialize content-type: {}".format(content_type)) + + @classmethod + def deserialize_from_http_generics(cls, body_bytes, headers): + # type: (Optional[Union[AnyStr, IO]], Mapping) -> Any + """Deserialize from HTTP response. + + Use bytes and headers to NOT use any requests/aiohttp or whatever + specific implementation. + Headers will tested for "content-type" + """ + # Try to use content-type from headers if available + content_type = None + if 'content-type' in headers: + content_type = headers['content-type'].split(";")[0].strip().lower() + # Ouch, this server did not declare what it sent... + # Let's guess it's JSON... + # Also, since Autorest was considering that an empty body was a valid JSON, + # need that test as well.... + else: + content_type = "application/json" + + if body_bytes: + return cls.deserialize_from_text(body_bytes, content_type) + return None + +try: + basestring # type: ignore + unicode_str = unicode # type: ignore +except NameError: + basestring = str # type: ignore + unicode_str = str # type: ignore + +_LOGGER = logging.getLogger(__name__) + +try: + _long_type = long # type: ignore +except NameError: + _long_type = int + +class UTC(datetime.tzinfo): + """Time Zone info for handling UTC""" + + def utcoffset(self, dt): + """UTF offset for UTC is 0.""" + return datetime.timedelta(0) + + def tzname(self, dt): + """Timestamp representation.""" + return "Z" + + def dst(self, dt): + """No daylight saving for UTC.""" + return datetime.timedelta(hours=1) + +try: + from datetime import timezone as _FixedOffset +except ImportError: # Python 2.7 + class _FixedOffset(datetime.tzinfo): # type: ignore + """Fixed offset in minutes east from UTC. + Copy/pasted from Python doc + :param datetime.timedelta offset: offset in timedelta format + """ + + def __init__(self, offset): + self.__offset = offset + + def utcoffset(self, dt): + return self.__offset + + def tzname(self, dt): + return str(self.__offset.total_seconds()/3600) + + def __repr__(self): + return "".format(self.tzname(None)) + + def dst(self, dt): + return datetime.timedelta(0) + + def __getinitargs__(self): + return (self.__offset,) + +try: + from datetime import timezone + TZ_UTC = timezone.utc # type: ignore +except ImportError: + TZ_UTC = UTC() # type: ignore + +_FLATTEN = re.compile(r"(? y, + "minimum": lambda x, y: x < y, + "maximum": lambda x, y: x > y, + "minimum_ex": lambda x, y: x <= y, + "maximum_ex": lambda x, y: x >= y, + "min_items": lambda x, y: len(x) < y, + "max_items": lambda x, y: len(x) > y, + "pattern": lambda x, y: not re.match(y, x, re.UNICODE), + "unique": lambda x, y: len(x) != len(set(x)), + "multiple": lambda x, y: x % y != 0 + } + + def __init__(self, classes=None): + self.serialize_type = { + 'iso-8601': Serializer.serialize_iso, + 'rfc-1123': Serializer.serialize_rfc, + 'unix-time': Serializer.serialize_unix, + 'duration': Serializer.serialize_duration, + 'date': Serializer.serialize_date, + 'time': Serializer.serialize_time, + 'decimal': Serializer.serialize_decimal, + 'long': Serializer.serialize_long, + 'bytearray': Serializer.serialize_bytearray, + 'base64': Serializer.serialize_base64, + 'object': self.serialize_object, + '[]': self.serialize_iter, + '{}': self.serialize_dict + } + self.dependencies = dict(classes) if classes else {} + self.key_transformer = full_restapi_key_transformer + self.client_side_validation = True + + def _serialize(self, target_obj, data_type=None, **kwargs): + """Serialize data into a string according to type. + + :param target_obj: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str, dict + :raises: SerializationError if serialization fails. + """ + key_transformer = kwargs.get("key_transformer", self.key_transformer) + keep_readonly = kwargs.get("keep_readonly", False) + if target_obj is None: + return None + + attr_name = None + class_name = target_obj.__class__.__name__ + + if data_type: + return self.serialize_data( + target_obj, data_type, **kwargs) + + if not hasattr(target_obj, "_attribute_map"): + data_type = type(target_obj).__name__ + if data_type in self.basic_types.values(): + return self.serialize_data( + target_obj, data_type, **kwargs) + + # Force "is_xml" kwargs if we detect a XML model + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + is_xml_model_serialization = kwargs.setdefault("is_xml", target_obj.is_xml_model()) + + serialized = {} + if is_xml_model_serialization: + serialized = target_obj._create_xml_node() + try: + attributes = target_obj._attribute_map + for attr, attr_desc in attributes.items(): + attr_name = attr + if not keep_readonly and target_obj._validation.get(attr_name, {}).get('readonly', False): + continue + + if attr_name == "additional_properties" and attr_desc["key"] == '': + if target_obj.additional_properties is not None: + serialized.update(target_obj.additional_properties) + continue + try: + + orig_attr = getattr(target_obj, attr) + if is_xml_model_serialization: + pass # Don't provide "transformer" for XML for now. Keep "orig_attr" + else: # JSON + keys, orig_attr = key_transformer(attr, attr_desc.copy(), orig_attr) + keys = keys if isinstance(keys, list) else [keys] + + + kwargs["serialization_ctxt"] = attr_desc + new_attr = self.serialize_data(orig_attr, attr_desc['type'], **kwargs) + + + if is_xml_model_serialization: + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + xml_prefix = xml_desc.get('prefix', None) + xml_ns = xml_desc.get('ns', None) + if xml_desc.get("attr", False): + if xml_ns: + ET.register_namespace(xml_prefix, xml_ns) + xml_name = "{}{}".format(xml_ns, xml_name) + serialized.set(xml_name, new_attr) + continue + if xml_desc.get("text", False): + serialized.text = new_attr + continue + if isinstance(new_attr, list): + serialized.extend(new_attr) + elif isinstance(new_attr, ET.Element): + # If the down XML has no XML/Name, we MUST replace the tag with the local tag. But keeping the namespaces. + if 'name' not in getattr(orig_attr, '_xml_map', {}): + splitted_tag = new_attr.tag.split("}") + if len(splitted_tag) == 2: # Namespace + new_attr.tag = "}".join([splitted_tag[0], xml_name]) + else: + new_attr.tag = xml_name + serialized.append(new_attr) + 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) + serialized.append(local_node) + else: # JSON + for k in reversed(keys): + unflattened = {k: new_attr} + new_attr = unflattened + + _new_attr = new_attr + _serialized = serialized + for k in keys: + if k not in _serialized: + _serialized.update(_new_attr) + _new_attr = _new_attr[k] + _serialized = _serialized[k] + except ValueError: + continue + + 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) + else: + return serialized + + def body(self, data, data_type, **kwargs): + """Serialize data intended for a request body. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: dict + :raises: SerializationError if serialization fails. + :raises: ValueError if data is None + """ + + # Just in case this is a dict + internal_data_type = data_type.strip('[]{}') + internal_data_type = self.dependencies.get(internal_data_type, None) + try: + is_xml_model_serialization = kwargs["is_xml"] + except KeyError: + if internal_data_type and issubclass(internal_data_type, Model): + is_xml_model_serialization = kwargs.setdefault("is_xml", internal_data_type.is_xml_model()) + else: + is_xml_model_serialization = False + if internal_data_type and not isinstance(internal_data_type, Enum): + try: + deserializer = Deserializer(self.dependencies) + # Since it's on serialization, it's almost sure that format is not JSON REST + # We're not able to deal with additional properties for now. + deserializer.additional_properties_detection = False + if is_xml_model_serialization: + deserializer.key_extractors = [ + attribute_key_case_insensitive_extractor, + ] + else: + deserializer.key_extractors = [ + rest_key_case_insensitive_extractor, + attribute_key_case_insensitive_extractor, + last_rest_key_case_insensitive_extractor + ] + data = deserializer._deserialize(data_type, data) + except DeserializationError as err: + raise_with_traceback( + SerializationError, "Unable to build a model: "+str(err), err) + + return self._serialize(data, data_type, **kwargs) + + def url(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL path. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return output + + def query(self, name, data, data_type, **kwargs): + """Serialize data intended for a URL query. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + # Treat the list aside, since we don't want to encode the div separator + if data_type.startswith("["): + internal_data_type = data_type[1:-1] + data = [ + self.serialize_data(d, internal_data_type, **kwargs) if d is not None else "" + for d + in data + ] + if not kwargs.get('skip_quote', False): + data = [ + quote(str(d), safe='') + for d + in data + ] + return str(self.serialize_iter(data, internal_data_type, **kwargs)) + + # Not a list, regular serialization + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + if kwargs.get('skip_quote') is True: + output = str(output) + else: + output = quote(str(output), safe='') + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def header(self, name, data, data_type, **kwargs): + """Serialize data intended for a request header. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :rtype: str + :raises: TypeError if serialization fails. + :raises: ValueError if data is None + """ + try: + if data_type in ['[str]']: + data = ["" if d is None else d for d in data] + + output = self.serialize_data(data, data_type, **kwargs) + if data_type == 'bool': + output = json.dumps(output) + except SerializationError: + raise TypeError("{} must be type {}.".format(name, data_type)) + else: + return str(output) + + def serialize_data(self, data, data_type, **kwargs): + """Serialize generic data according to supplied data type. + + :param data: The data to be serialized. + :param str data_type: The type to be serialized from. + :param bool required: Whether it's essential that the data not be + empty or None + :raises: AttributeError if required data is None. + :raises: ValueError if data is None + :raises: SerializationError if serialization fails. + """ + if data is None: + raise ValueError("No value for given attribute") + + try: + if data_type in self.basic_types.values(): + return self.serialize_basic(data, data_type, **kwargs) + + elif data_type in self.serialize_type: + return self.serialize_type[data_type](data, **kwargs) + + # If dependencies is empty, try with current data class + # It has to be a subclass of Enum anyway + enum_type = self.dependencies.get(data_type, data.__class__) + if issubclass(enum_type, Enum): + return Serializer.serialize_enum(data, enum_obj=enum_type) + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.serialize_type: + return self.serialize_type[iter_type]( + data, data_type[1:-1], **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) + else: + return self._serialize(data, **kwargs) + + @classmethod + def _get_custom_serializers(cls, data_type, **kwargs): + custom_serializer = kwargs.get("basic_types_serializers", {}).get(data_type) + if custom_serializer: + return custom_serializer + if kwargs.get("is_xml", False): + return cls._xml_basic_types_serializers.get(data_type) + + @classmethod + def serialize_basic(cls, data, data_type, **kwargs): + """Serialize basic builting data type. + Serializes objects to str, int, float or bool. + + Possible kwargs: + - basic_types_serializers dict[str, callable] : If set, use the callable as serializer + - is_xml bool : If set, use xml_basic_types_serializers + + :param data: Object to be serialized. + :param str data_type: Type of object in the iterable. + """ + custom_serializer = cls._get_custom_serializers(data_type, **kwargs) + if custom_serializer: + return custom_serializer(data) + if data_type == 'str': + return cls.serialize_unicode(data) + return eval(data_type)(data) # nosec + + @classmethod + def serialize_unicode(cls, data): + """Special handling for serializing unicode strings in Py2. + Encode to UTF-8 if unicode, otherwise handle as a str. + + :param data: Object to be serialized. + :rtype: str + """ + try: # If I received an enum, return its value + return data.value + except AttributeError: + pass + + try: + if isinstance(data, unicode): + # Don't change it, JSON and XML ElementTree are totally able + # to serialize correctly u'' strings + return data + except NameError: + return str(data) + else: + return str(data) + + def serialize_iter(self, data, iter_type, div=None, **kwargs): + """Serialize iterable. + + Supported kwargs: + - serialization_ctxt dict : The current entry of _attribute_map, or same format. + serialization_ctxt['type'] should be same as data_type. + - is_xml bool : If set, serialize as XML + + :param list attr: Object to be serialized. + :param str iter_type: Type of object in the iterable. + :param bool required: Whether the objects in the iterable must + not be None or empty. + :param str div: If set, this str will be used to combine the elements + in the iterable into a combined string. Default is 'None'. + :rtype: list, str + """ + if isinstance(data, str): + raise SerializationError("Refuse str type as a valid iter type.") + + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + is_xml = kwargs.get("is_xml", False) + + serialized = [] + for d in data: + try: + serialized.append(self.serialize_data(d, iter_type, **kwargs)) + except ValueError: + serialized.append(None) + + if div: + serialized = ['' if s is None else str(s) for s in serialized] + serialized = div.join(serialized) + + if 'xml' in serialization_ctxt or is_xml: + # XML serialization is more complicated + xml_desc = serialization_ctxt.get('xml', {}) + xml_name = xml_desc.get('name') + if not xml_name: + xml_name = serialization_ctxt['key'] + + # Create a wrap node if necessary (use the fact that Element and list have "append") + is_wrapped = xml_desc.get("wrapped", False) + node_name = xml_desc.get("itemsName", xml_name) + if is_wrapped: + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + else: + final_result = [] + # All list elements to "local_node" + for el in serialized: + if isinstance(el, ET.Element): + el_node = el + else: + el_node = _create_xml_node( + node_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + if el is not None: # Otherwise it writes "None" :-p + el_node.text = str(el) + final_result.append(el_node) + return final_result + return serialized + + def serialize_dict(self, attr, dict_type, **kwargs): + """Serialize a dictionary of objects. + + :param dict attr: Object to be serialized. + :param str dict_type: Type of object in the dictionary. + :param bool required: Whether the objects in the dictionary must + not be None or empty. + :rtype: dict + """ + serialization_ctxt = kwargs.get("serialization_ctxt", {}) + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_data( + value, dict_type, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + + if 'xml' in serialization_ctxt: + # XML serialization is more complicated + xml_desc = serialization_ctxt['xml'] + xml_name = xml_desc['name'] + + final_result = _create_xml_node( + xml_name, + xml_desc.get('prefix', None), + xml_desc.get('ns', None) + ) + for key, value in serialized.items(): + ET.SubElement(final_result, key).text = value + return final_result + + return serialized + + def serialize_object(self, attr, **kwargs): + """Serialize a generic object. + This will be handled as a dictionary. If object passed in is not + a basic type (str, int, float, dict, list) it will simply be + cast to str. + + :param dict attr: Object to be serialized. + :rtype: dict or str + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + return attr + obj_type = type(attr) + if obj_type in self.basic_types: + 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: + return self.serialize_unicode(attr) + if obj_type is datetime.datetime: + return self.serialize_iso(attr) + if obj_type is datetime.date: + return self.serialize_date(attr) + if obj_type is datetime.time: + return self.serialize_time(attr) + if obj_type is datetime.timedelta: + return self.serialize_duration(attr) + if obj_type is decimal.Decimal: + return self.serialize_decimal(attr) + + # If it's a model or I know this dependency, serialize as a Model + elif obj_type in self.dependencies.values() or isinstance(attr, Model): + return self._serialize(attr) + + if obj_type == dict: + serialized = {} + for key, value in attr.items(): + try: + serialized[self.serialize_unicode(key)] = self.serialize_object( + value, **kwargs) + except ValueError: + serialized[self.serialize_unicode(key)] = None + return serialized + + if obj_type == list: + serialized = [] + for obj in attr: + try: + serialized.append(self.serialize_object( + obj, **kwargs)) + except ValueError: + pass + return serialized + return str(attr) + + @staticmethod + def serialize_enum(attr, enum_obj=None): + try: + result = attr.value + except AttributeError: + result = attr + try: + enum_obj(result) + return result + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(attr).lower(): + return enum_value.value + error = "{!r} is not valid value for enum {!r}" + raise SerializationError(error.format(attr, enum_obj)) + + @staticmethod + def serialize_bytearray(attr, **kwargs): + """Serialize bytearray into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + return b64encode(attr).decode() + + @staticmethod + def serialize_base64(attr, **kwargs): + """Serialize str into base-64 string. + + :param attr: Object to be serialized. + :rtype: str + """ + encoded = b64encode(attr).decode('ascii') + return encoded.strip('=').replace('+', '-').replace('/', '_') + + @staticmethod + def serialize_decimal(attr, **kwargs): + """Serialize Decimal object to float. + + :param attr: Object to be serialized. + :rtype: float + """ + return float(attr) + + @staticmethod + def serialize_long(attr, **kwargs): + """Serialize long (Py2) or int (Py3). + + :param attr: Object to be serialized. + :rtype: int/long + """ + return _long_type(attr) + + @staticmethod + def serialize_date(attr, **kwargs): + """Serialize Date object into ISO-8601 formatted string. + + :param Date attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_date(attr) + t = "{:04}-{:02}-{:02}".format(attr.year, attr.month, attr.day) + return t + + @staticmethod + def serialize_time(attr, **kwargs): + """Serialize Time object into ISO-8601 formatted string. + + :param datetime.time attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_time(attr) + t = "{:02}:{:02}:{:02}".format(attr.hour, attr.minute, attr.second) + if attr.microsecond: + t += ".{:02}".format(attr.microsecond) + return t + + @staticmethod + def serialize_duration(attr, **kwargs): + """Serialize TimeDelta object into ISO-8601 formatted string. + + :param TimeDelta attr: Object to be serialized. + :rtype: str + """ + if isinstance(attr, str): + attr = isodate.parse_duration(attr) + return isodate.duration_isoformat(attr) + + @staticmethod + def serialize_rfc(attr, **kwargs): + """Serialize Datetime object into RFC-1123 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: TypeError if format invalid. + """ + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + except AttributeError: + raise TypeError("RFC1123 object must be valid Datetime object.") + + return "{}, {:02} {} {:04} {:02}:{:02}:{:02} GMT".format( + Serializer.days[utc.tm_wday], utc.tm_mday, + Serializer.months[utc.tm_mon], utc.tm_year, + utc.tm_hour, utc.tm_min, utc.tm_sec) + + @staticmethod + def serialize_iso(attr, **kwargs): + """Serialize Datetime object into ISO-8601 formatted string. + + :param Datetime attr: Object to be serialized. + :rtype: str + :raises: SerializationError if format invalid. + """ + if isinstance(attr, str): + attr = isodate.parse_datetime(attr) + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + utc = attr.utctimetuple() + if utc.tm_year > 9999 or utc.tm_year < 1: + raise OverflowError("Hit max or min date") + + microseconds = str(attr.microsecond).rjust(6,'0').rstrip('0').ljust(3, '0') + if microseconds: + microseconds = '.'+microseconds + date = "{:04}-{:02}-{:02}T{:02}:{:02}:{:02}".format( + utc.tm_year, utc.tm_mon, utc.tm_mday, + utc.tm_hour, utc.tm_min, utc.tm_sec) + return date + microseconds + 'Z' + except (ValueError, OverflowError) as err: + msg = "Unable to serialize datetime object." + raise_with_traceback(SerializationError, msg, err) + except AttributeError as err: + msg = "ISO-8601 object must be valid Datetime object." + raise_with_traceback(TypeError, msg, err) + + @staticmethod + def serialize_unix(attr, **kwargs): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param Datetime attr: Object to be serialized. + :rtype: int + :raises: SerializationError if format invalid + """ + if isinstance(attr, int): + return attr + try: + if not attr.tzinfo: + _LOGGER.warning( + "Datetime with no tzinfo will be considered UTC.") + return int(calendar.timegm(attr.utctimetuple())) + except AttributeError: + raise TypeError("Unix time object must be valid Datetime object.") + +def rest_key_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = working_data.get(working_key, 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:]) + + return working_data.get(key) + +def rest_key_case_insensitive_extractor(attr, attr_desc, data): + key = attr_desc['key'] + working_data = data + + while '.' in key: + dict_keys = _FLATTEN.split(key) + if len(dict_keys) == 1: + key = _decode_attribute_map_key(dict_keys[0]) + break + working_key = _decode_attribute_map_key(dict_keys[0]) + working_data = attribute_key_case_insensitive_extractor(working_key, None, working_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:]) + + if working_data: + return attribute_key_case_insensitive_extractor(key, None, working_data) + +def last_rest_key_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_extractor(dict_keys[-1], None, data) + +def last_rest_key_case_insensitive_extractor(attr, attr_desc, data): + """Extract the attribute in "data" based on the last part of the JSON path key. + + This is the case insensitive version of "last_rest_key_extractor" + """ + key = attr_desc['key'] + dict_keys = _FLATTEN.split(key) + return attribute_key_case_insensitive_extractor(dict_keys[-1], None, data) + +def attribute_key_extractor(attr, _, data): + return data.get(attr) + +def attribute_key_case_insensitive_extractor(attr, _, data): + found_key = None + lower_attr = attr.lower() + for key in data: + if lower_attr == key.lower(): + found_key = key + break + + return data.get(found_key) + +def _extract_name_from_internal_type(internal_type): + """Given an internal type XML description, extract correct XML name with namespace. + + :param dict internal_type: An model type + :rtype: tuple + :returns: A tuple XML name + namespace dict + """ + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + xml_name = internal_type_xml_map.get('name', internal_type.__name__) + xml_ns = internal_type_xml_map.get("ns", None) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + return xml_name + + +def xml_key_extractor(attr, attr_desc, data): + if isinstance(data, dict): + return None + + # Test if this model is XML ready first + if not isinstance(data, ET.Element): + return None + + xml_desc = attr_desc.get('xml', {}) + xml_name = xml_desc.get('name', attr_desc['key']) + + # Look for a children + is_iter_type = attr_desc['type'].startswith("[") + is_wrapped = xml_desc.get("wrapped", False) + internal_type = attr_desc.get("internalType", None) + internal_type_xml_map = getattr(internal_type, "_xml_map", {}) + + # Integrate namespace if necessary + xml_ns = xml_desc.get('ns', internal_type_xml_map.get("ns", None)) + if xml_ns: + xml_name = "{}{}".format(xml_ns, xml_name) + + # If it's an attribute, that's simple + if xml_desc.get("attr", False): + return data.get(xml_name) + + # If it's x-ms-text, that's simple too + if xml_desc.get("text", False): + return data.text + + # Scenario where I take the local name: + # - Wrapped node + # - Internal type is an enum (considered basic types) + # - Internal type has no XML/Name node + if is_wrapped or (internal_type and (issubclass(internal_type, Enum) or 'name' not in internal_type_xml_map)): + children = data.findall(xml_name) + # If internal type has a local name and it's not a list, I use that name + elif not is_iter_type and internal_type and 'name' in internal_type_xml_map: + xml_name = _extract_name_from_internal_type(internal_type) + children = data.findall(xml_name) + # That's an array + else: + if internal_type: # Complex type, ignore itemsName and use the complex type name + items_name = _extract_name_from_internal_type(internal_type) + else: + items_name = xml_desc.get("itemsName", xml_name) + children = data.findall(items_name) + + if len(children) == 0: + if is_iter_type: + if is_wrapped: + return None # is_wrapped no node, we want None + else: + return [] # not wrapped, assume empty list + return None # Assume it's not there, maybe an optional node. + + # If is_iter_type and not wrapped, return all found children + if is_iter_type: + if not is_wrapped: + return children + else: # Iter and wrapped, should have found one node only (the wrap one) + if len(children) != 1: + raise DeserializationError( + "Tried to deserialize an array not wrapped, and found several nodes '{}'. Maybe you should declare this array as wrapped?".format( + xml_name + )) + return list(children[0]) # Might be empty list and that's ok. + + # Here it's not a itertype, we should have found one element only or empty + if len(children) > 1: + raise DeserializationError("Find several XML '{}' where it was not expected".format(xml_name)) + return children[0] + +class Deserializer(object): + """Response object model deserializer. + + :param dict classes: Class type dictionary for deserializing complex types. + :ivar list key_extractors: Ordered list of extractors to be used by this deserializer. + """ + + basic_types = {str: 'str', int: 'int', bool: 'bool', float: 'float'} + + 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=None): + self.deserialize_type = { + 'iso-8601': Deserializer.deserialize_iso, + 'rfc-1123': Deserializer.deserialize_rfc, + 'unix-time': Deserializer.deserialize_unix, + 'duration': Deserializer.deserialize_duration, + 'date': Deserializer.deserialize_date, + 'time': Deserializer.deserialize_time, + 'decimal': Deserializer.deserialize_decimal, + 'long': Deserializer.deserialize_long, + 'bytearray': Deserializer.deserialize_bytearray, + 'base64': Deserializer.deserialize_base64, + 'object': self.deserialize_object, + '[]': self.deserialize_iter, + '{}': self.deserialize_dict + } + self.deserialize_expected_types = { + 'duration': (isodate.Duration, datetime.timedelta), + 'iso-8601': (datetime.datetime) + } + self.dependencies = 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 + # complicated, with no real scenario for now. + # So adding a flag to disable additional properties detection. This flag should be + # used if your expect the deserialization to NOT come from a JSON REST syntax. + # Otherwise, result are unexpected + self.additional_properties_detection = True + + def __call__(self, target_obj, response_data, content_type=None): + """Call the deserializer to process a REST response. + + :param str target_obj: Target data type to deserialize to. + :param requests.Response response_data: REST response object. + :param str content_type: Swagger "produces" if available. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + data = self._unpack_content(response_data, content_type) + return self._deserialize(target_obj, data) + + def _deserialize(self, target_obj, data): + """Call the deserializer on a model. + + Data needs to be already deserialized as JSON or XML ElementTree + + :param str target_obj: Target data type to deserialize to. + :param object data: Object to deserialize. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + # This is already a model, go recursive just in case + if hasattr(data, "_attribute_map"): + constants = [name for name, config in getattr(data, '_validation', {}).items() + if config.get('constant')] + try: + for attr, mapconfig in data._attribute_map.items(): + if attr in constants: + continue + value = getattr(data, attr) + if value is None: + continue + local_type = mapconfig['type'] + internal_data_type = local_type.strip('[]{}') + if internal_data_type not in self.dependencies or isinstance(internal_data_type, Enum): + continue + setattr( + data, + attr, + self._deserialize(local_type, value) + ) + return data + except AttributeError: + return + + response, class_name = self._classify_target(target_obj, data) + + if isinstance(response, basestring): + return self.deserialize_data(data, response) + elif isinstance(response, type) and issubclass(response, Enum): + return self.deserialize_enum(data, response) + + if data is None: + return data + try: + attributes = response._attribute_map + d_attrs = {} + for attr, attr_desc in attributes.items(): + # Check empty string. If it's not empty, someone has a real "additionalProperties"... + if attr == "additional_properties" and attr_desc["key"] == '': + continue + raw_value = None + # Enhance attr_desc with some dynamic data + attr_desc = attr_desc.copy() # Do a copy, do not change the real one + internal_data_type = attr_desc["type"].strip('[]{}') + if internal_data_type in self.dependencies: + attr_desc["internalType"] = self.dependencies[internal_data_type] + + for key_extractor in self.key_extractors: + found_value = key_extractor(attr, attr_desc, data) + if found_value is not None: + if raw_value is not None and raw_value != found_value: + msg = ("Ignoring extracted value '%s' from %s for key '%s'" + " (duplicate extraction, follow extractors order)" ) + _LOGGER.warning( + msg, + found_value, + key_extractor, + attr + ) + continue + raw_value = found_value + + value = self.deserialize_data(raw_value, attr_desc['type']) + d_attrs[attr] = value + except (AttributeError, TypeError, KeyError) as err: + msg = "Unable to deserialize to object: " + class_name + raise_with_traceback(DeserializationError, msg, err) + else: + additional_properties = self._build_additional_properties(attributes, data) + return self._instantiate_model(response, d_attrs, additional_properties) + + def _build_additional_properties(self, attribute_map, data): + if not self.additional_properties_detection: + return None + if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': + # Check empty string. If it's not empty, someone has a real "additionalProperties" + return None + if isinstance(data, ET.Element): + data = {el.tag: el.text for el in data} + + known_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} + present_keys = set(data.keys()) + missing_keys = present_keys - known_keys + return {key: data[key] for key in missing_keys} + + def _classify_target(self, target, data): + """Check to see whether the deserialization target object can + be classified into a subclass. + Once classification has been determined, initialize object. + + :param str target: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + """ + if target is None: + return None, None + + if isinstance(target, basestring): + try: + target = self.dependencies[target] + except KeyError: + return target, target + + try: + target = target._classify(data, self.dependencies) + except AttributeError: + pass # Target is not a Model, no classify + return target, target.__class__.__name__ + + def failsafe_deserialize(self, target_obj, data, content_type=None): + """Ignores any errors encountered in deserialization, + and falls back to not deserializing the object. Recommended + for use in error deserialization, as we want to return the + HttpResponseError to users, and not have them deal with + a deserialization error. + + :param str target_obj: The target object type to deserialize to. + :param str/dict data: The response data to deseralize. + :param str content_type: Swagger "produces" if available. + """ + try: + return self(target_obj, data, content_type=content_type) + except: + _LOGGER.debug( + "Ran into a deserialization error. Ignoring since this is failsafe deserialization", + exc_info=True + ) + return None + + @staticmethod + def _unpack_content(raw_data, content_type=None): + """Extract the correct structure for deserialization. + + If raw_data is a PipelineResponse, try to extract the result of RawDeserializer. + if we can't, raise. Your Pipeline should have a RawDeserializer. + + If not a pipeline response and raw_data is bytes or string, use content-type + to decode it. If no content-type, try JSON. + + If raw_data is something else, bypass all logic and return it directly. + + :param raw_data: Data to be processed. + :param content_type: How to parse if raw_data is a string/bytes. + :raises JSONDecodeError: If JSON is requested and parsing is impossible. + :raises UnicodeDecodeError: If bytes is not UTF8 + """ + # Assume this is enough to detect a Pipeline Response without importing it + context = getattr(raw_data, "context", {}) + if context: + if RawDeserializer.CONTEXT_NAME in context: + return context[RawDeserializer.CONTEXT_NAME] + raise ValueError("This pipeline didn't have the RawDeserializer policy; can't deserialize") + + #Assume this is enough to recognize universal_http.ClientResponse without importing it + if hasattr(raw_data, "body"): + return RawDeserializer.deserialize_from_http_generics( + raw_data.text(), + raw_data.headers + ) + + # Assume this enough to recognize requests.Response without importing it. + 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'): + return RawDeserializer.deserialize_from_text(raw_data, content_type) + return raw_data + + def _instantiate_model(self, response, attrs, additional_properties=None): + """Instantiate a response model passing in deserialized args. + + :param response: The response model class. + :param d_attrs: The deserialized response attributes. + """ + if callable(response): + subtype = getattr(response, '_subtype_map', {}) + try: + readonly = [k for k, v in response._validation.items() + if v.get('readonly')] + const = [k for k, v in response._validation.items() + if v.get('constant')] + kwargs = {k: v for k, v in attrs.items() + if k not in subtype and k not in readonly + const} + response_obj = response(**kwargs) + for attr in readonly: + setattr(response_obj, attr, attrs.get(attr)) + if additional_properties: + response_obj.additional_properties = additional_properties + return response_obj + except TypeError as err: + msg = "Unable to deserialize {} into model {}. ".format( + kwargs, response) + raise DeserializationError(msg + str(err)) + else: + try: + for attr, value in attrs.items(): + setattr(response, attr, value) + return response + except Exception as exp: + msg = "Unable to populate response model. " + msg += "Type: {}, Error: {}".format(type(response), exp) + raise DeserializationError(msg) + + def deserialize_data(self, data, data_type): + """Process data for deserialization according to data type. + + :param str data: The response string to be deserialized. + :param str data_type: The type to deserialize to. + :raises: DeserializationError if deserialization fails. + :return: Deserialized object. + """ + if data is None: + return data + + try: + if not data_type: + return data + if data_type in self.basic_types.values(): + return self.deserialize_basic(data, data_type) + if data_type in self.deserialize_type: + if isinstance(data, self.deserialize_expected_types.get(data_type, tuple())): + return data + + is_a_text_parsing_type = lambda x: x not in ["object", "[]", r"{}"] + if isinstance(data, ET.Element) and is_a_text_parsing_type(data_type) and not data.text: + return None + data_val = self.deserialize_type[data_type](data) + return data_val + + iter_type = data_type[0] + data_type[-1] + if iter_type in self.deserialize_type: + return self.deserialize_type[iter_type](data, data_type[1:-1]) + + obj_type = self.dependencies[data_type] + if issubclass(obj_type, Enum): + if isinstance(data, ET.Element): + data = data.text + return self.deserialize_enum(data, obj_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) + else: + return self._deserialize(obj_type, data) + + def deserialize_iter(self, attr, iter_type): + """Deserialize an iterable. + + :param list attr: Iterable to be deserialized. + :param str iter_type: The type of object in the iterable. + :rtype: list + """ + if attr is None: + return None + if isinstance(attr, ET.Element): # If I receive an element here, get the children + attr = list(attr) + if not isinstance(attr, (list, set)): + raise DeserializationError("Cannot deserialize as [{}] an object of type {}".format( + iter_type, + type(attr) + )) + return [self.deserialize_data(a, iter_type) for a in attr] + + def deserialize_dict(self, attr, dict_type): + """Deserialize a dictionary. + + :param dict/list attr: Dictionary to be deserialized. Also accepts + a list of key, value pairs. + :param str dict_type: The object type of the items in the dictionary. + :rtype: dict + """ + if isinstance(attr, list): + return {x['key']: self.deserialize_data(x['value'], dict_type) for x in attr} + + if isinstance(attr, ET.Element): + # Transform value into {"Key": "value"} + attr = {el.tag: el.text for el in attr} + return {k: self.deserialize_data(v, dict_type) for k, v in attr.items()} + + def deserialize_object(self, attr, **kwargs): + """Deserialize a generic object. + This will be handled as a dictionary. + + :param dict attr: Dictionary to be deserialized. + :rtype: dict + :raises: TypeError if non-builtin datatype encountered. + """ + if attr is None: + return None + if isinstance(attr, ET.Element): + # Do no recurse on XML, just return the tree as-is + return attr + if isinstance(attr, basestring): + return self.deserialize_basic(attr, 'str') + obj_type = type(attr) + if obj_type in self.basic_types: + return self.deserialize_basic(attr, self.basic_types[obj_type]) + if obj_type is _long_type: + return self.deserialize_long(attr) + + if obj_type == dict: + deserialized = {} + for key, value in attr.items(): + try: + deserialized[key] = self.deserialize_object( + value, **kwargs) + except ValueError: + deserialized[key] = None + return deserialized + + if obj_type == list: + deserialized = [] + for obj in attr: + try: + deserialized.append(self.deserialize_object( + obj, **kwargs)) + except ValueError: + pass + return deserialized + + else: + error = "Cannot deserialize generic object with type: " + raise TypeError(error + str(obj_type)) + + def deserialize_basic(self, attr, data_type): + """Deserialize basic builtin data type from string. + Will attempt to convert to str, int, float and bool. + This function will also accept '1', '0', 'true' and 'false' as + valid bool values. + + :param str attr: response string to be deserialized. + :param str data_type: deserialization data type. + :rtype: str, int, float or bool + :raises: TypeError if string format is not valid. + """ + # If we're here, data is supposed to be a basic type. + # If it's still an XML node, take the text + if isinstance(attr, ET.Element): + attr = attr.text + if not attr: + if data_type == "str": + # None or '', node is empty string. + return '' + else: + # None or '', node with a strong type is None. + # Don't try to model "empty bool" or "empty int" + return None + + if data_type == 'bool': + if attr in [True, False, 1, 0]: + return bool(attr) + elif isinstance(attr, basestring): + if attr.lower() in ['true', '1']: + return True + elif attr.lower() in ['false', '0']: + return False + raise TypeError("Invalid boolean value: {}".format(attr)) + + if data_type == 'str': + return self.deserialize_unicode(attr) + return eval(data_type)(attr) # nosec + + @staticmethod + def deserialize_unicode(data): + """Preserve unicode objects in Python 2, otherwise return data + as a string. + + :param str data: response string to be deserialized. + :rtype: str or unicode + """ + # We might be here because we have an enum modeled as string, + # and we try to deserialize a partial dict with enum inside + if isinstance(data, Enum): + return data + + # Consider this is real string + try: + if isinstance(data, unicode): + return data + except NameError: + return str(data) + else: + return str(data) + + @staticmethod + def deserialize_enum(data, enum_obj): + """Deserialize string into enum object. + + If the string is not a valid enum value it will be returned as-is + and a warning will be logged. + + :param str data: Response string to be deserialized. If this value is + None or invalid it will be returned as-is. + :param Enum enum_obj: Enum object to deserialize to. + :rtype: Enum + """ + if isinstance(data, enum_obj) or data is None: + return data + if isinstance(data, Enum): + 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: + error = "{!r} is not a valid index for enum {!r}" + raise DeserializationError(error.format(data, enum_obj)) + try: + return enum_obj(str(data)) + except ValueError: + for enum_value in enum_obj: + if enum_value.value.lower() == str(data).lower(): + return enum_value + # We don't fail anymore for unknown value, we deserialize as a string + _LOGGER.warning("Deserializer is not able to find %s as valid enum in %s", data, enum_obj) + return Deserializer.deserialize_unicode(data) + + @staticmethod + def deserialize_bytearray(attr): + """Deserialize string into bytearray. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return bytearray(b64decode(attr)) + + @staticmethod + def deserialize_base64(attr): + """Deserialize base64 encoded string into string. + + :param str attr: response string to be deserialized. + :rtype: bytearray + :raises: TypeError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + padding = '=' * (3 - (len(attr) + 3) % 4) + attr = attr + padding + encoded = attr.replace('-', '+').replace('_', '/') + return b64decode(encoded) + + @staticmethod + def deserialize_decimal(attr): + """Deserialize string into Decimal object. + + :param str attr: response string to be deserialized. + :rtype: Decimal + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + return decimal.Decimal(attr) + except decimal.DecimalException as err: + msg = "Invalid decimal {}".format(attr) + raise_with_traceback(DeserializationError, msg, err) + + @staticmethod + def deserialize_long(attr): + """Deserialize string into long (Py2) or int (Py3). + + :param str attr: response string to be deserialized. + :rtype: long or int + :raises: ValueError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + return _long_type(attr) + + @staticmethod + def deserialize_duration(attr): + """Deserialize ISO-8601 formatted string into TimeDelta object. + + :param str attr: response string to be deserialized. + :rtype: TimeDelta + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + duration = isodate.parse_duration(attr) + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize duration object." + raise_with_traceback(DeserializationError, msg, err) + else: + return duration + + @staticmethod + def deserialize_date(attr): + """Deserialize ISO-8601 formatted string into Date object. + + :param str attr: response string to be deserialized. + :rtype: Date + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + 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) + + @staticmethod + def deserialize_time(attr): + """Deserialize ISO-8601 formatted string into time object. + + :param str attr: response string to be deserialized. + :rtype: datetime.time + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + if re.search(r"[^\W\d_]", attr, re.I + re.U): + raise DeserializationError("Date must have only digits and -. Received: %s" % attr) + return isodate.parse_time(attr) + + @staticmethod + def deserialize_rfc(attr): + """Deserialize RFC-1123 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + parsed_date = email.utils.parsedate_tz(attr) + date_obj = datetime.datetime( + *parsed_date[:6], + tzinfo=_FixedOffset(datetime.timedelta(minutes=(parsed_date[9] or 0)/60)) + ) + if not date_obj.tzinfo: + 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) + else: + return date_obj + + @staticmethod + def deserialize_iso(attr): + """Deserialize ISO-8601 formatted string into Datetime object. + + :param str attr: response string to be deserialized. + :rtype: Datetime + :raises: DeserializationError if string format invalid. + """ + if isinstance(attr, ET.Element): + attr = attr.text + try: + attr = attr.upper() + match = Deserializer.valid_date.match(attr) + if not match: + raise ValueError("Invalid datetime string: " + attr) + + check_decimal = attr.split('.') + if len(check_decimal) > 1: + decimal_str = "" + for digit in check_decimal[1]: + if digit.isdigit(): + decimal_str += digit + else: + break + if len(decimal_str) > 6: + attr = attr.replace(decimal_str, decimal_str[0:6]) + + date_obj = isodate.parse_datetime(attr) + test_utc = date_obj.utctimetuple() + if test_utc.tm_year > 9999 or test_utc.tm_year < 1: + raise OverflowError("Hit max or min date") + except(ValueError, OverflowError, AttributeError) as err: + msg = "Cannot deserialize datetime object." + raise_with_traceback(DeserializationError, msg, err) + else: + return date_obj + + @staticmethod + def deserialize_unix(attr): + """Serialize Datetime object into IntTime format. + This is represented as seconds. + + :param int attr: Object to be serialized. + :rtype: Datetime + :raises: DeserializationError if format invalid + """ + if isinstance(attr, ET.Element): + attr = int(attr.text) + try: + 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) + else: + return date_obj diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py index 3af552133413..ddc94bebb99a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_storage_management_client.py @@ -9,20 +9,17 @@ # regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING - -from msrest import Deserializer, Serializer +from typing import Any, Optional, TYPE_CHECKING from azure.mgmt.core import ARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin from ._configuration import StorageManagementClientConfiguration +from ._serialization import Deserializer, Serializer if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential class _SDKClient(object): @@ -43,9 +40,9 @@ class StorageManagementClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -56,7 +53,7 @@ class StorageManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2022-05-01' + DEFAULT_API_VERSION = '2022-09-01' _PROFILE_TAG = "azure.mgmt.storage.StorageManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -68,10 +65,10 @@ class StorageManagementClient(MultiApiClientMixin, _SDKClient): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str + credential: "TokenCredential", + subscription_id: str, api_version=None, # type: Optional[str] - base_url="https://management.azure.com", # type: str + base_url: str = "https://management.azure.com", profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): @@ -109,6 +106,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-08-01: :mod:`v2021_08_01.models` * 2021-09-01: :mod:`v2021_09_01.models` * 2022-05-01: :mod:`v2022_05_01.models` + * 2022-09-01: :mod:`v2022_09_01.models` """ if api_version == '2015-06-15': from .v2015_06_15 import models @@ -167,6 +165,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-05-01': from .v2022_05_01 import models return models + elif api_version == '2022-09-01': + from .v2022_09_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -187,6 +188,7 @@ def blob_containers(self): * 2021-08-01: :class:`BlobContainersOperations` * 2021-09-01: :class:`BlobContainersOperations` * 2022-05-01: :class:`BlobContainersOperations` + * 2022-09-01: :class:`BlobContainersOperations` """ api_version = self._get_api_version('blob_containers') if api_version == '2018-02-01': @@ -217,8 +219,11 @@ def blob_containers(self): from .v2021_09_01.operations import BlobContainersOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import BlobContainersOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import BlobContainersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_containers'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -234,6 +239,7 @@ def blob_inventory_policies(self): * 2021-08-01: :class:`BlobInventoryPoliciesOperations` * 2021-09-01: :class:`BlobInventoryPoliciesOperations` * 2022-05-01: :class:`BlobInventoryPoliciesOperations` + * 2022-09-01: :class:`BlobInventoryPoliciesOperations` """ api_version = self._get_api_version('blob_inventory_policies') if api_version == '2019-06-01': @@ -254,8 +260,11 @@ def blob_inventory_policies(self): from .v2021_09_01.operations import BlobInventoryPoliciesOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import BlobInventoryPoliciesOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import BlobInventoryPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_inventory_policies'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -274,6 +283,7 @@ def blob_services(self): * 2021-08-01: :class:`BlobServicesOperations` * 2021-09-01: :class:`BlobServicesOperations` * 2022-05-01: :class:`BlobServicesOperations` + * 2022-09-01: :class:`BlobServicesOperations` """ api_version = self._get_api_version('blob_services') if api_version == '2018-07-01': @@ -300,8 +310,11 @@ def blob_services(self): from .v2021_09_01.operations import BlobServicesOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import BlobServicesOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import BlobServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -316,6 +329,7 @@ def deleted_accounts(self): * 2021-08-01: :class:`DeletedAccountsOperations` * 2021-09-01: :class:`DeletedAccountsOperations` * 2022-05-01: :class:`DeletedAccountsOperations` + * 2022-09-01: :class:`DeletedAccountsOperations` """ api_version = self._get_api_version('deleted_accounts') if api_version == '2020-08-01-preview': @@ -334,8 +348,11 @@ def deleted_accounts(self): from .v2021_09_01.operations import DeletedAccountsOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import DeletedAccountsOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import DeletedAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deleted_accounts'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -351,6 +368,7 @@ def encryption_scopes(self): * 2021-08-01: :class:`EncryptionScopesOperations` * 2021-09-01: :class:`EncryptionScopesOperations` * 2022-05-01: :class:`EncryptionScopesOperations` + * 2022-09-01: :class:`EncryptionScopesOperations` """ api_version = self._get_api_version('encryption_scopes') if api_version == '2019-06-01': @@ -371,8 +389,11 @@ def encryption_scopes(self): from .v2021_09_01.operations import EncryptionScopesOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import EncryptionScopesOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import EncryptionScopesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'encryption_scopes'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -389,6 +410,7 @@ def file_services(self): * 2021-08-01: :class:`FileServicesOperations` * 2021-09-01: :class:`FileServicesOperations` * 2022-05-01: :class:`FileServicesOperations` + * 2022-09-01: :class:`FileServicesOperations` """ api_version = self._get_api_version('file_services') if api_version == '2019-04-01': @@ -411,8 +433,11 @@ def file_services(self): from .v2021_09_01.operations import FileServicesOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import FileServicesOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import FileServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -429,6 +454,7 @@ def file_shares(self): * 2021-08-01: :class:`FileSharesOperations` * 2021-09-01: :class:`FileSharesOperations` * 2022-05-01: :class:`FileSharesOperations` + * 2022-09-01: :class:`FileSharesOperations` """ api_version = self._get_api_version('file_shares') if api_version == '2019-04-01': @@ -451,8 +477,11 @@ def file_shares(self): from .v2021_09_01.operations import FileSharesOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import FileSharesOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import FileSharesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_shares'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -462,6 +491,7 @@ def local_users(self): * 2021-08-01: :class:`LocalUsersOperations` * 2021-09-01: :class:`LocalUsersOperations` * 2022-05-01: :class:`LocalUsersOperations` + * 2022-09-01: :class:`LocalUsersOperations` """ api_version = self._get_api_version('local_users') if api_version == '2021-08-01': @@ -470,8 +500,11 @@ def local_users(self): from .v2021_09_01.operations import LocalUsersOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import LocalUsersOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import LocalUsersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'local_users'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -490,6 +523,7 @@ def management_policies(self): * 2021-08-01: :class:`ManagementPoliciesOperations` * 2021-09-01: :class:`ManagementPoliciesOperations` * 2022-05-01: :class:`ManagementPoliciesOperations` + * 2022-09-01: :class:`ManagementPoliciesOperations` """ api_version = self._get_api_version('management_policies') if api_version == '2018-07-01': @@ -516,8 +550,11 @@ def management_policies(self): from .v2021_09_01.operations import ManagementPoliciesOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import ManagementPoliciesOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import ManagementPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'management_policies'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -533,6 +570,7 @@ def object_replication_policies(self): * 2021-08-01: :class:`ObjectReplicationPoliciesOperations` * 2021-09-01: :class:`ObjectReplicationPoliciesOperations` * 2022-05-01: :class:`ObjectReplicationPoliciesOperations` + * 2022-09-01: :class:`ObjectReplicationPoliciesOperations` """ api_version = self._get_api_version('object_replication_policies') if api_version == '2019-06-01': @@ -553,8 +591,11 @@ def object_replication_policies(self): from .v2021_09_01.operations import ObjectReplicationPoliciesOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import ObjectReplicationPoliciesOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import ObjectReplicationPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'object_replication_policies'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -577,6 +618,7 @@ def operations(self): * 2021-08-01: :class:`Operations` * 2021-09-01: :class:`Operations` * 2022-05-01: :class:`Operations` + * 2022-09-01: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-06-01': @@ -611,8 +653,11 @@ def operations(self): from .v2021_09_01.operations import Operations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import Operations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -628,6 +673,7 @@ def private_endpoint_connections(self): * 2021-08-01: :class:`PrivateEndpointConnectionsOperations` * 2021-09-01: :class:`PrivateEndpointConnectionsOperations` * 2022-05-01: :class:`PrivateEndpointConnectionsOperations` + * 2022-09-01: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2019-06-01': @@ -648,8 +694,11 @@ def private_endpoint_connections(self): from .v2021_09_01.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -665,6 +714,7 @@ def private_link_resources(self): * 2021-08-01: :class:`PrivateLinkResourcesOperations` * 2021-09-01: :class:`PrivateLinkResourcesOperations` * 2022-05-01: :class:`PrivateLinkResourcesOperations` + * 2022-09-01: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2019-06-01': @@ -685,8 +735,11 @@ def private_link_resources(self): from .v2021_09_01.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -702,6 +755,7 @@ def queue(self): * 2021-08-01: :class:`QueueOperations` * 2021-09-01: :class:`QueueOperations` * 2022-05-01: :class:`QueueOperations` + * 2022-09-01: :class:`QueueOperations` """ api_version = self._get_api_version('queue') if api_version == '2019-06-01': @@ -722,8 +776,11 @@ def queue(self): from .v2021_09_01.operations import QueueOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import QueueOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import QueueOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -739,6 +796,7 @@ def queue_services(self): * 2021-08-01: :class:`QueueServicesOperations` * 2021-09-01: :class:`QueueServicesOperations` * 2022-05-01: :class:`QueueServicesOperations` + * 2022-09-01: :class:`QueueServicesOperations` """ api_version = self._get_api_version('queue_services') if api_version == '2019-06-01': @@ -759,8 +817,11 @@ def queue_services(self): from .v2021_09_01.operations import QueueServicesOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import QueueServicesOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import QueueServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue_services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -783,6 +844,7 @@ def skus(self): * 2021-08-01: :class:`SkusOperations` * 2021-09-01: :class:`SkusOperations` * 2022-05-01: :class:`SkusOperations` + * 2022-09-01: :class:`SkusOperations` """ api_version = self._get_api_version('skus') if api_version == '2017-06-01': @@ -817,8 +879,11 @@ def skus(self): from .v2021_09_01.operations import SkusOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import SkusOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import SkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'skus'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -844,6 +909,7 @@ def storage_accounts(self): * 2021-08-01: :class:`StorageAccountsOperations` * 2021-09-01: :class:`StorageAccountsOperations` * 2022-05-01: :class:`StorageAccountsOperations` + * 2022-09-01: :class:`StorageAccountsOperations` """ api_version = self._get_api_version('storage_accounts') if api_version == '2015-06-15': @@ -884,8 +950,11 @@ def storage_accounts(self): from .v2021_09_01.operations import StorageAccountsOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import StorageAccountsOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import StorageAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storage_accounts'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -901,6 +970,7 @@ def table(self): * 2021-08-01: :class:`TableOperations` * 2021-09-01: :class:`TableOperations` * 2022-05-01: :class:`TableOperations` + * 2022-09-01: :class:`TableOperations` """ api_version = self._get_api_version('table') if api_version == '2019-06-01': @@ -921,8 +991,11 @@ def table(self): from .v2021_09_01.operations import TableOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import TableOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import TableOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -938,6 +1011,7 @@ def table_services(self): * 2021-08-01: :class:`TableServicesOperations` * 2021-09-01: :class:`TableServicesOperations` * 2022-05-01: :class:`TableServicesOperations` + * 2022-09-01: :class:`TableServicesOperations` """ api_version = self._get_api_version('table_services') if api_version == '2019-06-01': @@ -958,8 +1032,11 @@ def table_services(self): from .v2021_09_01.operations import TableServicesOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import TableServicesOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import TableServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table_services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -988,6 +1065,7 @@ def usage(self): from .v2018_02_01.operations import UsageOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'usage'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -1007,6 +1085,7 @@ def usages(self): * 2021-08-01: :class:`UsagesOperations` * 2021-09-01: :class:`UsagesOperations` * 2022-05-01: :class:`UsagesOperations` + * 2022-09-01: :class:`UsagesOperations` """ api_version = self._get_api_version('usages') if api_version == '2018-03-01-preview': @@ -1035,8 +1114,11 @@ def usages(self): from .v2021_09_01.operations import UsagesOperations as OperationClass elif api_version == '2022-05-01': from .v2022_05_01.operations import UsagesOperations as OperationClass + elif api_version == '2022-09-01': + from .v2022_09_01.operations import UsagesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'usages'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) def close(self): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py index 4bd561a0e67d..0ac27bb117d3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/_version.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_configuration.py index 3ee0c9646eb4..2f2359246409 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_configuration.py @@ -26,9 +26,9 @@ class StorageManagementClientConfiguration(Configuration): Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py index c2b5fb27c697..4515f8f6bc74 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/aio/_storage_management_client.py @@ -11,17 +11,15 @@ from typing import Any, Optional, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -42,9 +40,9 @@ class StorageManagementClient(MultiApiClientMixin, _SDKClient): The api-version parameter sets the default API version if the operation group is not described in the profile. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param api_version: API version to use if no profile is provided, or if missing in profile. :type api_version: str @@ -55,7 +53,7 @@ class StorageManagementClient(MultiApiClientMixin, _SDKClient): :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. """ - DEFAULT_API_VERSION = '2022-05-01' + DEFAULT_API_VERSION = '2022-09-01' _PROFILE_TAG = "azure.mgmt.storage.StorageManagementClient" LATEST_PROFILE = ProfileDefinition({ _PROFILE_TAG: { @@ -108,6 +106,7 @@ def models(cls, api_version=DEFAULT_API_VERSION): * 2021-08-01: :mod:`v2021_08_01.models` * 2021-09-01: :mod:`v2021_09_01.models` * 2022-05-01: :mod:`v2022_05_01.models` + * 2022-09-01: :mod:`v2022_09_01.models` """ if api_version == '2015-06-15': from ..v2015_06_15 import models @@ -166,6 +165,9 @@ def models(cls, api_version=DEFAULT_API_VERSION): elif api_version == '2022-05-01': from ..v2022_05_01 import models return models + elif api_version == '2022-09-01': + from ..v2022_09_01 import models + return models raise ValueError("API version {} is not available".format(api_version)) @property @@ -186,6 +188,7 @@ def blob_containers(self): * 2021-08-01: :class:`BlobContainersOperations` * 2021-09-01: :class:`BlobContainersOperations` * 2022-05-01: :class:`BlobContainersOperations` + * 2022-09-01: :class:`BlobContainersOperations` """ api_version = self._get_api_version('blob_containers') if api_version == '2018-02-01': @@ -216,8 +219,11 @@ def blob_containers(self): from ..v2021_09_01.aio.operations import BlobContainersOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import BlobContainersOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import BlobContainersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_containers'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -233,6 +239,7 @@ def blob_inventory_policies(self): * 2021-08-01: :class:`BlobInventoryPoliciesOperations` * 2021-09-01: :class:`BlobInventoryPoliciesOperations` * 2022-05-01: :class:`BlobInventoryPoliciesOperations` + * 2022-09-01: :class:`BlobInventoryPoliciesOperations` """ api_version = self._get_api_version('blob_inventory_policies') if api_version == '2019-06-01': @@ -253,8 +260,11 @@ def blob_inventory_policies(self): from ..v2021_09_01.aio.operations import BlobInventoryPoliciesOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import BlobInventoryPoliciesOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import BlobInventoryPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_inventory_policies'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -273,6 +283,7 @@ def blob_services(self): * 2021-08-01: :class:`BlobServicesOperations` * 2021-09-01: :class:`BlobServicesOperations` * 2022-05-01: :class:`BlobServicesOperations` + * 2022-09-01: :class:`BlobServicesOperations` """ api_version = self._get_api_version('blob_services') if api_version == '2018-07-01': @@ -299,8 +310,11 @@ def blob_services(self): from ..v2021_09_01.aio.operations import BlobServicesOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import BlobServicesOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import BlobServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'blob_services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -315,6 +329,7 @@ def deleted_accounts(self): * 2021-08-01: :class:`DeletedAccountsOperations` * 2021-09-01: :class:`DeletedAccountsOperations` * 2022-05-01: :class:`DeletedAccountsOperations` + * 2022-09-01: :class:`DeletedAccountsOperations` """ api_version = self._get_api_version('deleted_accounts') if api_version == '2020-08-01-preview': @@ -333,8 +348,11 @@ def deleted_accounts(self): from ..v2021_09_01.aio.operations import DeletedAccountsOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import DeletedAccountsOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import DeletedAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'deleted_accounts'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -350,6 +368,7 @@ def encryption_scopes(self): * 2021-08-01: :class:`EncryptionScopesOperations` * 2021-09-01: :class:`EncryptionScopesOperations` * 2022-05-01: :class:`EncryptionScopesOperations` + * 2022-09-01: :class:`EncryptionScopesOperations` """ api_version = self._get_api_version('encryption_scopes') if api_version == '2019-06-01': @@ -370,8 +389,11 @@ def encryption_scopes(self): from ..v2021_09_01.aio.operations import EncryptionScopesOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import EncryptionScopesOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import EncryptionScopesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'encryption_scopes'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -388,6 +410,7 @@ def file_services(self): * 2021-08-01: :class:`FileServicesOperations` * 2021-09-01: :class:`FileServicesOperations` * 2022-05-01: :class:`FileServicesOperations` + * 2022-09-01: :class:`FileServicesOperations` """ api_version = self._get_api_version('file_services') if api_version == '2019-04-01': @@ -410,8 +433,11 @@ def file_services(self): from ..v2021_09_01.aio.operations import FileServicesOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import FileServicesOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import FileServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -428,6 +454,7 @@ def file_shares(self): * 2021-08-01: :class:`FileSharesOperations` * 2021-09-01: :class:`FileSharesOperations` * 2022-05-01: :class:`FileSharesOperations` + * 2022-09-01: :class:`FileSharesOperations` """ api_version = self._get_api_version('file_shares') if api_version == '2019-04-01': @@ -450,8 +477,11 @@ def file_shares(self): from ..v2021_09_01.aio.operations import FileSharesOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import FileSharesOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import FileSharesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'file_shares'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -461,6 +491,7 @@ def local_users(self): * 2021-08-01: :class:`LocalUsersOperations` * 2021-09-01: :class:`LocalUsersOperations` * 2022-05-01: :class:`LocalUsersOperations` + * 2022-09-01: :class:`LocalUsersOperations` """ api_version = self._get_api_version('local_users') if api_version == '2021-08-01': @@ -469,8 +500,11 @@ def local_users(self): from ..v2021_09_01.aio.operations import LocalUsersOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import LocalUsersOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import LocalUsersOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'local_users'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -489,6 +523,7 @@ def management_policies(self): * 2021-08-01: :class:`ManagementPoliciesOperations` * 2021-09-01: :class:`ManagementPoliciesOperations` * 2022-05-01: :class:`ManagementPoliciesOperations` + * 2022-09-01: :class:`ManagementPoliciesOperations` """ api_version = self._get_api_version('management_policies') if api_version == '2018-07-01': @@ -515,8 +550,11 @@ def management_policies(self): from ..v2021_09_01.aio.operations import ManagementPoliciesOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import ManagementPoliciesOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import ManagementPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'management_policies'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -532,6 +570,7 @@ def object_replication_policies(self): * 2021-08-01: :class:`ObjectReplicationPoliciesOperations` * 2021-09-01: :class:`ObjectReplicationPoliciesOperations` * 2022-05-01: :class:`ObjectReplicationPoliciesOperations` + * 2022-09-01: :class:`ObjectReplicationPoliciesOperations` """ api_version = self._get_api_version('object_replication_policies') if api_version == '2019-06-01': @@ -552,8 +591,11 @@ def object_replication_policies(self): from ..v2021_09_01.aio.operations import ObjectReplicationPoliciesOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import ObjectReplicationPoliciesOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import ObjectReplicationPoliciesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'object_replication_policies'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -576,6 +618,7 @@ def operations(self): * 2021-08-01: :class:`Operations` * 2021-09-01: :class:`Operations` * 2022-05-01: :class:`Operations` + * 2022-09-01: :class:`Operations` """ api_version = self._get_api_version('operations') if api_version == '2017-06-01': @@ -610,8 +653,11 @@ def operations(self): from ..v2021_09_01.aio.operations import Operations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import Operations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import Operations as OperationClass else: raise ValueError("API version {} does not have operation group 'operations'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -627,6 +673,7 @@ def private_endpoint_connections(self): * 2021-08-01: :class:`PrivateEndpointConnectionsOperations` * 2021-09-01: :class:`PrivateEndpointConnectionsOperations` * 2022-05-01: :class:`PrivateEndpointConnectionsOperations` + * 2022-09-01: :class:`PrivateEndpointConnectionsOperations` """ api_version = self._get_api_version('private_endpoint_connections') if api_version == '2019-06-01': @@ -647,8 +694,11 @@ def private_endpoint_connections(self): from ..v2021_09_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import PrivateEndpointConnectionsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_endpoint_connections'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -664,6 +714,7 @@ def private_link_resources(self): * 2021-08-01: :class:`PrivateLinkResourcesOperations` * 2021-09-01: :class:`PrivateLinkResourcesOperations` * 2022-05-01: :class:`PrivateLinkResourcesOperations` + * 2022-09-01: :class:`PrivateLinkResourcesOperations` """ api_version = self._get_api_version('private_link_resources') if api_version == '2019-06-01': @@ -684,8 +735,11 @@ def private_link_resources(self): from ..v2021_09_01.aio.operations import PrivateLinkResourcesOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import PrivateLinkResourcesOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import PrivateLinkResourcesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'private_link_resources'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -701,6 +755,7 @@ def queue(self): * 2021-08-01: :class:`QueueOperations` * 2021-09-01: :class:`QueueOperations` * 2022-05-01: :class:`QueueOperations` + * 2022-09-01: :class:`QueueOperations` """ api_version = self._get_api_version('queue') if api_version == '2019-06-01': @@ -721,8 +776,11 @@ def queue(self): from ..v2021_09_01.aio.operations import QueueOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import QueueOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import QueueOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -738,6 +796,7 @@ def queue_services(self): * 2021-08-01: :class:`QueueServicesOperations` * 2021-09-01: :class:`QueueServicesOperations` * 2022-05-01: :class:`QueueServicesOperations` + * 2022-09-01: :class:`QueueServicesOperations` """ api_version = self._get_api_version('queue_services') if api_version == '2019-06-01': @@ -758,8 +817,11 @@ def queue_services(self): from ..v2021_09_01.aio.operations import QueueServicesOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import QueueServicesOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import QueueServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'queue_services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -782,6 +844,7 @@ def skus(self): * 2021-08-01: :class:`SkusOperations` * 2021-09-01: :class:`SkusOperations` * 2022-05-01: :class:`SkusOperations` + * 2022-09-01: :class:`SkusOperations` """ api_version = self._get_api_version('skus') if api_version == '2017-06-01': @@ -816,8 +879,11 @@ def skus(self): from ..v2021_09_01.aio.operations import SkusOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import SkusOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import SkusOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'skus'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -843,6 +909,7 @@ def storage_accounts(self): * 2021-08-01: :class:`StorageAccountsOperations` * 2021-09-01: :class:`StorageAccountsOperations` * 2022-05-01: :class:`StorageAccountsOperations` + * 2022-09-01: :class:`StorageAccountsOperations` """ api_version = self._get_api_version('storage_accounts') if api_version == '2015-06-15': @@ -883,8 +950,11 @@ def storage_accounts(self): from ..v2021_09_01.aio.operations import StorageAccountsOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import StorageAccountsOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import StorageAccountsOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'storage_accounts'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -900,6 +970,7 @@ def table(self): * 2021-08-01: :class:`TableOperations` * 2021-09-01: :class:`TableOperations` * 2022-05-01: :class:`TableOperations` + * 2022-09-01: :class:`TableOperations` """ api_version = self._get_api_version('table') if api_version == '2019-06-01': @@ -920,8 +991,11 @@ def table(self): from ..v2021_09_01.aio.operations import TableOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import TableOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import TableOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -937,6 +1011,7 @@ def table_services(self): * 2021-08-01: :class:`TableServicesOperations` * 2021-09-01: :class:`TableServicesOperations` * 2022-05-01: :class:`TableServicesOperations` + * 2022-09-01: :class:`TableServicesOperations` """ api_version = self._get_api_version('table_services') if api_version == '2019-06-01': @@ -957,8 +1032,11 @@ def table_services(self): from ..v2021_09_01.aio.operations import TableServicesOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import TableServicesOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import TableServicesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'table_services'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -987,6 +1065,7 @@ def usage(self): from ..v2018_02_01.aio.operations import UsageOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'usage'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) @property @@ -1006,6 +1085,7 @@ def usages(self): * 2021-08-01: :class:`UsagesOperations` * 2021-09-01: :class:`UsagesOperations` * 2022-05-01: :class:`UsagesOperations` + * 2022-09-01: :class:`UsagesOperations` """ api_version = self._get_api_version('usages') if api_version == '2018-03-01-preview': @@ -1034,8 +1114,11 @@ def usages(self): from ..v2021_09_01.aio.operations import UsagesOperations as OperationClass elif api_version == '2022-05-01': from ..v2022_05_01.aio.operations import UsagesOperations as OperationClass + elif api_version == '2022-09-01': + from ..v2022_09_01.aio.operations import UsagesOperations as OperationClass else: raise ValueError("API version {} does not have operation group 'usages'".format(api_version)) + self._config.api_version = api_version return OperationClass(self._client, self._config, Serializer(self._models_dict(api_version)), Deserializer(self._models_dict(api_version))) async def close(self): diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py index d447da56e626..5f27ea656079 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/models.py @@ -5,4 +5,4 @@ # license information. # -------------------------------------------------------------------------- from .v2018_02_01.models import * -from .v2022_05_01.models import * +from .v2022_09_01.models import * diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/__init__.py index 7be55ff4bf05..9499d1280cf7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagement'] + +__all__ = [ + "StorageManagement", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_configuration.py index 28ef888ae349..e74f2776f402 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-06-15". 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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop("api_version", "2015-06-15") # type: Literal["2015-06-15"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json index fbff37b91208..df6d141c7f80 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -100,4 +100,4 @@ "storage_accounts": "StorageAccountsOperations", "usage": "UsageOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py index d7678c956b88..77139c6e8f38 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_storage_management.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementConfiguration from .operations import StorageAccountsOperations, UsageOperations @@ -22,17 +21,18 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagement: + +class StorageManagement: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar storage_accounts: StorageAccountsOperations operations :vartype storage_accounts: azure.mgmt.storage.v2015_06_15.operations.StorageAccountsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.storage.v2015_06_15.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,9 @@ def __init__( self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +71,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/__init__.py index 36895a3e2a36..b0fc6191b769 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagement'] + +__all__ = [ + "StorageManagement", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_configuration.py index 99a9890858e9..eadabe459b75 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2015-06-15". 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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2015-06-15") # type: str + api_version = kwargs.pop("api_version", "2015-06-15") # type: Literal["2015-06-15"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py index 6c47e38bec8f..4e31ff16fc53 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/_storage_management.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementConfiguration from .operations import StorageAccountsOperations, UsageOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagement: + +class StorageManagement: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar storage_accounts: StorageAccountsOperations operations @@ -30,10 +30,10 @@ class StorageManagement: azure.mgmt.storage.v2015_06_15.aio.operations.StorageAccountsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.storage.v2015_06_15.aio.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Subscription credentials which uniquely identify the Microsoft Azure - subscription. The subscription ID forms part of the URI for every service call. + subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -61,16 +61,9 @@ def __init__( self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,7 +72,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/__init__.py index 7df8399a811b..b14eb5626281 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'StorageAccountsOperations', - 'UsageOperations', + "StorageAccountsOperations", + "UsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_operations.py index 82269b233b7e..f574fcbf8465 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,26 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_get_properties_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_regenerate_key_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_get_properties_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_regenerate_key_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,49 +70,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCheckNameAvailabilityParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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.storage.v2015_06_15.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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.storage.v2015_06_15.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCheckNameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -95,56 +169,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, - *, - content_type: Optional[str] = "application/json", + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -152,10 +233,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -164,24 +244,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -190,16 +269,16 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCreateParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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. @@ -213,99 +292,175 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCreateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, - content_type=content_type, api_version=api_version, - cls=lambda x,y,z: x, + content_type=content_type, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -313,10 +468,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -326,50 +480,48 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -377,34 +529,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -417,34 +567,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountUpdateParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -453,7 +686,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -461,58 +695,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -520,13 +752,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -543,10 +779,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -556,49 +790,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -606,14 +839,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -630,10 +866,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -643,51 +877,46 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async - async def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.StorageAccountKeys: + async def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccountKeys: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountKeys, or the result of cls(response) + :return: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountKeys] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -695,68 +924,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountKeys', pipeline_response) + deserialized = self._deserialize("StorageAccountKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountKeys: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountRegenerateKeyParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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: StorageAccountKeys, or the result of cls(response) + :return: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountKeys: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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: StorageAccountKeys or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountKeys: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2015_06_15.models.StorageAccountRegenerateKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: StorageAccountKeys or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountKeys] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -765,7 +1064,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -773,22 +1073,20 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountKeys', pipeline_response) + deserialized = self._deserialize("StorageAccountKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_operations.py index 3119adf4f824..b7e913c8f4c6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/aio/operations/_usage_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usage_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsageOperations: """ .. warning:: @@ -42,37 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Lists the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2015_06_15.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -80,13 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -103,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/__init__.py index 15a5eea909c4..191f2f2df1e8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/__init__.py @@ -21,37 +21,35 @@ from ._models_py3 import UsageListResult from ._models_py3 import UsageName - -from ._storage_management_enums import ( - AccountStatus, - AccountType, - ProvisioningState, - Reason, - UsageUnit, -) +from ._storage_management_enums import AccountStatus +from ._storage_management_enums import AccountType +from ._storage_management_enums import ProvisioningState +from ._storage_management_enums import Reason +from ._storage_management_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'CheckNameAvailabilityResult', - 'CustomDomain', - 'Endpoints', - 'Resource', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountKeys', - 'StorageAccountListResult', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'Usage', - 'UsageListResult', - 'UsageName', - 'AccountStatus', - 'AccountType', - 'ProvisioningState', - 'Reason', - 'UsageUnit', + "CheckNameAvailabilityResult", + "CustomDomain", + "Endpoints", + "Resource", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountKeys", + "StorageAccountListResult", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "Usage", + "UsageListResult", + "UsageName", + "AccountStatus", + "AccountType", + "ProvisioningState", + "Reason", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py index e06471542fbc..8ea96cca8ab6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -9,14 +10,14 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. :ivar name_available: Boolean value that indicates whether the name is available for you to @@ -24,7 +25,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: The reason that a storage account name could not be used. The Reason element is - only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2015_06_15.models.Reason :ivar message: The error message explaining the Reason value in more detail. @@ -32,9 +33,9 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } def __init__( @@ -51,24 +52,24 @@ def __init__( and cannot be used. :paramtype name_available: bool :keyword reason: The reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :paramtype reason: str or ~azure.mgmt.storage.v2015_06_15.models.Reason :keyword message: The error message explaining the Reason value in more detail. :paramtype message: str """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.name_available = name_available self.reason = reason self.message = message -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The custom domain name. Name is the CNAME source. + :ivar name: The custom domain name. Name is the CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -76,34 +77,28 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. The custom domain name. Name is the CNAME source. + :keyword name: The custom domain name. Name is the CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue or table object. :ivar blob: The blob endpoint. @@ -117,10 +112,10 @@ class Endpoints(msrest.serialization.Model): """ _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, } def __init__( @@ -142,14 +137,14 @@ def __init__( :keyword file: The file endpoint. :paramtype file: str """ - super(Endpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.queue = queue self.table = table self.file = file -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Describes a storage resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -162,38 +157,32 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -201,7 +190,7 @@ def __init__( self.tags = tags -class StorageAccount(Resource): +class StorageAccount(Resource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -214,13 +203,13 @@ class StorageAccount(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar provisioning_state: The status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2015_06_15.models.ProvisioningState :ivar account_type: The type of the storage account. Known values are: "Standard_LRS", - "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", "Premium_LRS". + "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", and "Premium_LRS". :vartype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType :ivar primary_endpoints: The URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob endpoint. @@ -228,7 +217,7 @@ class StorageAccount(Resource): :ivar primary_location: The location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: The status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "Available", "Unavailable". + account is available or unavailable. Known values are: "Available" and "Unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2015_06_15.models.AccountStatus :ivar last_geo_failover_time: The timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not returned if @@ -240,7 +229,7 @@ class StorageAccount(Resource): :vartype secondary_location: str :ivar status_of_secondary: The status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "Available", "Unavailable". + Standard_RAGRS. Known values are: "Available" and "Unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2015_06_15.models.AccountStatus :ivar creation_time: The creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -253,28 +242,28 @@ class StorageAccount(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "account_type": {"key": "properties.accountType", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, } def __init__( @@ -298,13 +287,13 @@ def __init__( """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword provisioning_state: The status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :paramtype provisioning_state: str or ~azure.mgmt.storage.v2015_06_15.models.ProvisioningState :keyword account_type: The type of the storage account. Known values are: "Standard_LRS", - "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", "Premium_LRS". + "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", and "Premium_LRS". :paramtype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType :keyword primary_endpoints: The URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -313,7 +302,7 @@ def __init__( :keyword primary_location: The location of the primary data center for the storage account. :paramtype primary_location: str :keyword status_of_primary: The status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "Available", "Unavailable". + account is available or unavailable. Known values are: "Available" and "Unavailable". :paramtype status_of_primary: str or ~azure.mgmt.storage.v2015_06_15.models.AccountStatus :keyword last_geo_failover_time: The timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not returned if @@ -325,7 +314,7 @@ def __init__( :paramtype secondary_location: str :keyword status_of_secondary: The status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "Available", "Unavailable". + Standard_RAGRS. Known values are: "Available" and "Unavailable". :paramtype status_of_secondary: str or ~azure.mgmt.storage.v2015_06_15.models.AccountStatus :keyword creation_time: The creation date and time of the storage account in UTC. :paramtype creation_time: ~datetime.datetime @@ -336,7 +325,7 @@ def __init__( the SKU name is Standard_RAGRS. :paramtype secondary_endpoints: ~azure.mgmt.storage.v2015_06_15.models.Endpoints """ - super(StorageAccount, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.provisioning_state = provisioning_state self.account_type = account_type self.primary_endpoints = primary_endpoints @@ -350,7 +339,7 @@ def __init__( self.secondary_endpoints = secondary_endpoints -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. All required parameters must be populated in order to send to Azure. @@ -362,61 +351,55 @@ class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - *, - name: str, - type: Optional[str] = "Microsoft.Storage/storageAccounts", - **kwargs - ): + def __init__(self, *, name: str, type: str = "Microsoft.Storage/storageAccounts", **kwargs): """ :keyword name: Required. :paramtype name: str :keyword type: :paramtype type: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): """The parameters to provide for the account. All required parameters must be populated in order to send to Azure. - :ivar location: Required. The location of the resource. This will be one of the supported and - registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a - resource cannot be changed once it is created, but if an identical geo region is specified on - update, the request will succeed. + :ivar location: The location of the resource. This will be one of the supported and registered + Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a resource + cannot be changed once it is created, but if an identical geo region is specified on update, + the request will succeed. Required. :vartype location: str - :ivar tags: A set of tags. A list of key value pairs that describe the resource. These tags can - be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags - can be provided for a resource. Each tag must have a key with a length no greater than 128 - characters and a value with a length no greater than 256 characters. + :ivar tags: A list of key value pairs that describe the resource. These tags can be used for + viewing and grouping this resource (across resource groups). A maximum of 15 tags can be + provided for a resource. Each tag must have a key with a length no greater than 128 characters + and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar account_type: The sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", - "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", "Premium_LRS". + "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", and "Premium_LRS". :vartype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType """ _validation = { - 'location': {'required': True}, + "location": {"required": True}, } _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "account_type": {"key": "properties.accountType", "type": "str"}, } def __init__( @@ -428,28 +411,28 @@ def __init__( **kwargs ): """ - :keyword location: Required. The location of the resource. This will be one of the supported - and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region - of a resource cannot be changed once it is created, but if an identical geo region is specified - on update, the request will succeed. + :keyword location: The location of the resource. This will be one of the supported and + registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The geo region of a + resource cannot be changed once it is created, but if an identical geo region is specified on + update, the request will succeed. Required. :paramtype location: str - :keyword tags: A set of tags. A list of key value pairs that describe the resource. These tags - can be used for viewing and grouping this resource (across resource groups). A maximum of 15 - tags can be provided for a resource. Each tag must have a key with a length no greater than 128 - characters and a value with a length no greater than 256 characters. + :keyword tags: A list of key value pairs that describe the resource. These tags can be used for + viewing and grouping this resource (across resource groups). A maximum of 15 tags can be + provided for a resource. Each tag must have a key with a length no greater than 128 characters + and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword account_type: The sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. Known values are: "Standard_LRS", - "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", "Premium_LRS". + "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", and "Premium_LRS". :paramtype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.location = location self.tags = tags self.account_type = account_type -class StorageAccountKeys(msrest.serialization.Model): +class StorageAccountKeys(_serialization.Model): """The access keys for the storage account. :ivar key1: The value of key 1. @@ -459,29 +442,23 @@ class StorageAccountKeys(msrest.serialization.Model): """ _attribute_map = { - 'key1': {'key': 'key1', 'type': 'str'}, - 'key2': {'key': 'key2', 'type': 'str'}, + "key1": {"key": "key1", "type": "str"}, + "key2": {"key": "key2", "type": "str"}, } - def __init__( - self, - *, - key1: Optional[str] = None, - key2: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key1: Optional[str] = None, key2: Optional[str] = None, **kwargs): """ :keyword key1: The value of key 1. :paramtype key1: str :keyword key2: The value of key 2. :paramtype key2: str """ - super(StorageAccountKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.key1 = key1 self.key2 = key2 -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The list storage accounts operation response. :ivar value: The list of storage accounts and their properties. @@ -489,24 +466,19 @@ class StorageAccountListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, + "value": {"key": "value", "type": "[StorageAccount]"}, } - def __init__( - self, - *, - value: Optional[List["_models.StorageAccount"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.StorageAccount"]] = None, **kwargs): """ :keyword value: The list of storage accounts and their properties. :paramtype value: list[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] """ - super(StorageAccountListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. @@ -516,36 +488,31 @@ class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ :keyword key_name: Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): """The parameters to update on the account. - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] :ivar account_type: The account type. Note that StandardZRS and PremiumLRS accounts cannot be changed to other account types, and other account types cannot be changed to StandardZRS or PremiumLRS. Known values are: "Standard_LRS", "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", - "Premium_LRS". + and "Premium_LRS". :vartype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType :ivar custom_domain: User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing @@ -554,9 +521,9 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'account_type': {'key': 'properties.accountType', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, + "tags": {"key": "tags", "type": "{str}"}, + "account_type": {"key": "properties.accountType", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, } def __init__( @@ -568,54 +535,54 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] :keyword account_type: The account type. Note that StandardZRS and PremiumLRS accounts cannot be changed to other account types, and other account types cannot be changed to StandardZRS or PremiumLRS. Known values are: "Standard_LRS", "Standard_ZRS", "Standard_GRS", "Standard_RAGRS", - "Premium_LRS". + and "Premium_LRS". :paramtype account_type: str or ~azure.mgmt.storage.v2015_06_15.models.AccountType :keyword custom_domain: User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing custom domain, use an empty string for the custom domain name property. :paramtype custom_domain: ~azure.mgmt.storage.v2015_06_15.models.CustomDomain """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.account_type = account_type self.custom_domain = custom_domain -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. All required parameters must be populated in order to send to Azure. - :ivar unit: Required. The unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + :ivar unit: The unit of measurement. Required. Known values are: "Count", "Bytes", "Seconds", + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2015_06_15.models.UsageUnit - :ivar current_value: Required. The current count of the allocated resources in the - subscription. + :ivar current_value: The current count of the allocated resources in the subscription. + Required. :vartype current_value: int - :ivar limit: Required. The maximum count of the resources that can be allocated in the - subscription. + :ivar limit: The maximum count of the resources that can be allocated in the subscription. + Required. :vartype limit: int - :ivar name: Required. The name of the type of usage. + :ivar name: The name of the type of usage. Required. :vartype name: ~azure.mgmt.storage.v2015_06_15.models.UsageName """ _validation = { - 'unit': {'required': True}, - 'current_value': {'required': True}, - 'limit': {'required': True}, - 'name': {'required': True}, + "unit": {"required": True}, + "current_value": {"required": True}, + "limit": {"required": True}, + "name": {"required": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } def __init__( @@ -628,26 +595,26 @@ def __init__( **kwargs ): """ - :keyword unit: Required. The unit of measurement. Known values are: "Count", "Bytes", - "Seconds", "Percent", "CountsPerSecond", "BytesPerSecond". + :keyword unit: The unit of measurement. Required. Known values are: "Count", "Bytes", + "Seconds", "Percent", "CountsPerSecond", and "BytesPerSecond". :paramtype unit: str or ~azure.mgmt.storage.v2015_06_15.models.UsageUnit - :keyword current_value: Required. The current count of the allocated resources in the - subscription. + :keyword current_value: The current count of the allocated resources in the subscription. + Required. :paramtype current_value: int - :keyword limit: Required. The maximum count of the resources that can be allocated in the - subscription. + :keyword limit: The maximum count of the resources that can be allocated in the subscription. + Required. :paramtype limit: int - :keyword name: Required. The name of the type of usage. + :keyword name: The name of the type of usage. Required. :paramtype name: ~azure.mgmt.storage.v2015_06_15.models.UsageName """ - super(Usage, self).__init__(**kwargs) + super().__init__(**kwargs) self.unit = unit self.current_value = current_value self.limit = limit self.name = name -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The List Usages operation response. :ivar value: The list Storage Resource Usages. @@ -655,24 +622,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: The list Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2015_06_15.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The Usage Names. :ivar value: A string describing the resource name. @@ -682,23 +644,17 @@ class UsageName(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - *, - value: Optional[str] = None, - localized_value: Optional[str] = None, - **kwargs - ): + def __init__(self, *, value: Optional[str] = None, localized_value: Optional[str] = None, **kwargs): """ :keyword value: A string describing the resource name. :paramtype value: str :keyword localized_value: A localized string describing the resource name. :paramtype localized_value: str """ - super(UsageName, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value self.localized_value = localized_value diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_storage_management_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_storage_management_enums.py index ad84ffb9fc1d..06e040bd1e6d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_storage_management_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/models/_storage_management_enums.py @@ -18,6 +18,7 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "Available" UNAVAILABLE = "Unavailable" + class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. @@ -29,14 +30,15 @@ class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_RAGRS = "Standard_RAGRS" PREMIUM_LRS = "Premium_LRS" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The status of the storage account at the time the operation was called. - """ + """The status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -45,9 +47,9 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The unit of measurement. - """ + """The unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/__init__.py index 7df8399a811b..b14eb5626281 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'StorageAccountsOperations', - 'UsageOperations', + "StorageAccountsOperations", + "UsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_operations.py index afdb471cc449..3f8323926624 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,359 +29,303 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class StorageAccountsOperations: """ @@ -395,49 +346,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCheckNameAvailabilityParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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.storage.v2015_06_15.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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.storage.v2015_06_15.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCheckNameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -445,56 +445,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, - *, - content_type: Optional[str] = "application/json", + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -502,10 +509,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -514,24 +520,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -540,16 +545,16 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCreateParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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. @@ -562,99 +567,173 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountCreateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, - content_type=content_type, api_version=api_version, - cls=lambda x,y,z: x, + content_type=content_type, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -662,10 +741,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -675,50 +753,46 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.StorageAccount: + def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -726,34 +800,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -766,34 +838,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountUpdateParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -802,7 +957,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -810,58 +966,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -869,13 +1022,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -892,10 +1049,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -905,49 +1060,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -955,14 +1106,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -979,10 +1133,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -992,51 +1144,46 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.StorageAccountKeys: + def list_keys(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccountKeys: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountKeys, or the result of cls(response) + :return: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountKeys] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1044,68 +1191,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountKeys', pipeline_response) + deserialized = self._deserialize("StorageAccountKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountKeys: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountRegenerateKeyParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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: StorageAccountKeys, or the result of cls(response) + :return: StorageAccountKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountKeys: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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: StorageAccountKeys or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountKeys: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2015_06_15.models.StorageAccountRegenerateKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: StorageAccountKeys or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2015_06_15.models.StorageAccountKeys + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountKeys] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1114,7 +1331,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1122,22 +1340,20 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountKeys', pipeline_response) + deserialized = self._deserialize("StorageAccountKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_operations.py index f2ab11f7505c..46420a166e33 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2015_06_15/operations/_usage_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsageOperations: """ @@ -78,36 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Lists the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2015_06_15.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2015-06-15")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2015-06-15")) # type: Literal["2015-06-15"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -115,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -138,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_configuration.py index 0793f89e7467..647a42335049 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-01-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-01-01") # type: str + api_version = kwargs.pop("api_version", "2016-01-01") # type: Literal["2016-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json index afc4507129f0..a88c133957eb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -100,4 +100,4 @@ "storage_accounts": "StorageAccountsOperations", "usage": "UsageOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py index aad574519df6..893404543ff6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_storage_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration from .operations import StorageAccountsOperations, UsageOperations @@ -22,17 +21,18 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword """The Storage Management Client. :ivar storage_accounts: StorageAccountsOperations operations :vartype storage_accounts: azure.mgmt.storage.v2016_01_01.operations.StorageAccountsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.storage.v2016_01_01.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -50,7 +50,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -60,16 +62,9 @@ def __init__( self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +73,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_configuration.py index a2ab4c7735c3..463d0039a42b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-01-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-01-01") # type: str + api_version = kwargs.pop("api_version", "2016-01-01") # type: Literal["2016-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py index 52cd6470accf..e0d59136d086 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/_storage_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration from .operations import StorageAccountsOperations, UsageOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword """The Storage Management Client. :ivar storage_accounts: StorageAccountsOperations operations @@ -30,10 +30,10 @@ class StorageManagementClient: azure.mgmt.storage.v2016_01_01.aio.operations.StorageAccountsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.storage.v2016_01_01.aio.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -51,7 +51,9 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} @@ -61,16 +63,9 @@ def __init__( self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,7 +74,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/__init__.py index 7df8399a811b..b14eb5626281 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'StorageAccountsOperations', - 'UsageOperations', + "StorageAccountsOperations", + "UsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_operations.py index e07812090f1a..3f697ccb49e4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,26 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_get_properties_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_regenerate_key_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_get_properties_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_regenerate_key_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,49 +70,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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.storage.v2016_01_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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.storage.v2016_01_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -95,56 +169,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, - *, - content_type: Optional[str] = "application/json", + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -152,10 +233,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -164,24 +244,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -190,15 +269,16 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCreateParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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. @@ -212,98 +292,175 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCreateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, - content_type=content_type, api_version=api_version, - cls=lambda x,y,z: x, + content_type=content_type, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -311,10 +468,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -324,49 +480,48 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,34 +529,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -414,33 +567,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountUpdateParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -449,7 +686,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -457,58 +695,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -516,13 +752,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -539,10 +779,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -552,48 +790,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. + 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -601,14 +839,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -625,10 +866,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -638,50 +877,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -689,67 +926,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountRegenerateKeyParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2016_01_01.models.StorageAccountRegenerateKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -758,7 +1066,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -766,22 +1075,20 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_operations.py index bc052f8d67cd..9f4fc8603741 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/aio/operations/_usage_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usage_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsageOperations: """ .. warning:: @@ -42,37 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_01_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -80,13 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -103,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/__init__.py index d5c0bb50753c..c69a0112e190 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/__init__.py @@ -26,50 +26,52 @@ from ._models_py3 import UsageListResult from ._models_py3 import UsageName - -from ._storage_management_client_enums import ( - AccessTier, - AccountStatus, - KeyPermission, - Kind, - ProvisioningState, - Reason, - SkuName, - SkuTier, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import EncryptionKeySource +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import StorageAccountCheckNameAvailabilityParametersType +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'CheckNameAvailabilityResult', - 'CustomDomain', - 'Encryption', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'Resource', - 'Sku', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'Usage', - 'UsageListResult', - 'UsageName', - 'AccessTier', - 'AccountStatus', - 'KeyPermission', - 'Kind', - 'ProvisioningState', - 'Reason', - 'SkuName', - 'SkuTier', - 'UsageUnit', + "CheckNameAvailabilityResult", + "CustomDomain", + "Encryption", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "Resource", + "Sku", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "Usage", + "UsageListResult", + "UsageName", + "AccessTier", + "AccountStatus", + "EncryptionKeySource", + "KeyPermission", + "Kind", + "ProvisioningState", + "Reason", + "SkuName", + "SkuTier", + "StorageAccountCheckNameAvailabilityParametersType", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py index 263bff8837ab..af2e97f8493d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -8,14 +9,14 @@ from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -25,7 +26,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2016_01_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -33,36 +34,32 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -70,74 +67,69 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. - Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2016_01_01.models.EncryptionServices :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): - Microsoft.Storage. Has constant value: "Microsoft.Storage". - :vartype key_source: str + Microsoft.Storage. Required. "Microsoft.Storage" + :vartype key_source: str or ~azure.mgmt.storage.v2016_01_01.models.EncryptionKeySource """ _validation = { - 'key_source': {'required': True, 'constant': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, } - key_source = "Microsoft.Storage" - def __init__( self, *, + key_source: Union[str, "_models.EncryptionKeySource"], services: Optional["_models.EncryptionServices"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2016_01_01.models.EncryptionServices + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage. Required. "Microsoft.Storage" + :paramtype key_source: str or ~azure.mgmt.storage.v2016_01_01.models.EncryptionKeySource """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services + self.key_source = key_source -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -152,31 +144,26 @@ class EncryptionService(msrest.serialization.Model): """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is stored. :paramtype enabled: bool """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. :ivar blob: The encryption function of the blob storage service. @@ -184,24 +171,19 @@ class EncryptionServices(msrest.serialization.Model): """ _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, } - def __init__( - self, - *, - blob: Optional["_models.EncryptionService"] = None, - **kwargs - ): + def __init__(self, *, blob: Optional["_models.EncryptionService"] = None, **kwargs): """ :keyword blob: The encryption function of the blob storage service. :paramtype blob: ~azure.mgmt.storage.v2016_01_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, or table object. Variables are only populated by the server, and will be ignored when sending a request. @@ -217,33 +199,29 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Endpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None self.file = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -256,40 +234,34 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping a - resource (across resource groups). + :ivar tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping - a resource (across resource groups). + :keyword tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -297,50 +269,45 @@ def __init__( self.tags = tags -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :ivar name: Gets or sets the sku name. Required for account creation; optional for update. Note + that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2016_01_01.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2016_01_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :keyword name: Gets or sets the sku name. Required for account creation; optional for update. + Note that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2016_01_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class StorageAccount(Resource): +class StorageAccount(Resource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -353,15 +320,15 @@ class StorageAccount(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping a - resource (across resource groups). + :ivar tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :vartype tags: dict[str, str] :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2016_01_01.models.Sku - :ivar kind: Gets the Kind. Known values are: "Storage", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage" and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2016_01_01.models.Kind :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2016_01_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -370,7 +337,7 @@ class StorageAccount(Resource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "Available", "Unavailable". + account is available or unavailable. Known values are: "Available" and "Unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2016_01_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -382,7 +349,7 @@ class StorageAccount(Resource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "Available", "Unavailable". + Standard_RAGRS. Known values are: "Available" and "Unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2016_01_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -396,67 +363,61 @@ class StorageAccount(Resource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_01_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_01_01.models.AccessTier """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - } - - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + } + + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping - a resource (across resource groups). + :keyword tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :paramtype tags: dict[str, str] """ - super(StorageAccount, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = None self.kind = None self.provisioning_state = None @@ -473,64 +434,62 @@ def __init__( self.access_tier = None -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """StorageAccountCheckNameAvailabilityParameters. - Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. :ivar name: Required. :vartype name: str - :ivar type: Has constant value: "Microsoft.Storage/storageAccounts". - :vartype type: str + :ivar type: Required. "Microsoft.Storage/storageAccounts" + :vartype type: str or + ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParametersType """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs + self, *, name: str, type: Union[str, "_models.StorageAccountCheckNameAvailabilityParametersType"], **kwargs ): """ :keyword name: Required. :paramtype name: str + :keyword type: Required. "Microsoft.Storage/storageAccounts" + :paramtype type: str or + ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParametersType """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name + self.type = type -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the sku name. + :ivar sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2016_01_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "BlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage" and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2016_01_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar custom_domain: User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing @@ -540,24 +499,24 @@ class StorageAccountCreateParameters(msrest.serialization.Model): account encryption settings will remain the same. The default setting is unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_01_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_01_01.models.AccessTier """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, } _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, } def __init__( @@ -573,20 +532,20 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the sku name. + :keyword sku: Required. Gets or sets the sku name. Required. :paramtype sku: ~azure.mgmt.storage.v2016_01_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "BlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage" and "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2016_01_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword custom_domain: User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing @@ -596,10 +555,10 @@ def __init__( account encryption settings will remain the same. The default setting is unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2016_01_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2016_01_01.models.AccessTier """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -609,7 +568,7 @@ def __init__( self.access_tier = access_tier -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -619,35 +578,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "READ", "FULL". + "READ" and "FULL". :vartype permissions: str or ~azure.mgmt.storage.v2016_01_01.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -658,24 +613,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -685,24 +636,20 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, + "value": {"key": "value", "type": "[StorageAccount]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """StorageAccountRegenerateKeyParameters. All required parameters must be populated in order to send to Azure. @@ -712,37 +659,32 @@ class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ :keyword key_name: Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2016_01_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -752,16 +694,16 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_01_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_01_01.models.AccessTier """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, } def __init__( @@ -778,10 +720,10 @@ def __init__( :keyword sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2016_01_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -791,10 +733,10 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2016_01_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2016_01_01.models.AccessTier """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.custom_domain = custom_domain @@ -802,13 +744,13 @@ def __init__( self.access_tier = access_tier -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2016_01_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -819,33 +761,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -853,24 +791,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2016_01_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -882,21 +815,17 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_storage_management_client_enums.py index c81e944b487f..073ef3e6a37c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,28 +25,35 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "Available" UNAVAILABLE = "Unavailable" + +class EncryptionKeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage.""" + + MICROSOFT_STORAGE = "Microsoft.Storage" + + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "READ" FULL = "FULL" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required. Indicates the type of storage account. - """ + """Required. Indicates the type of storage account.""" STORAGE = "Storage" BLOB_STORAGE = "BlobStorage" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -55,6 +62,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. @@ -66,16 +74,22 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the sku tier. This is based on the SKU name. - """ + """Gets the sku tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + +class StorageAccountCheckNameAvailabilityParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountCheckNameAvailabilityParametersType.""" + + MICROSOFT_STORAGE_STORAGE_ACCOUNTS = "Microsoft.Storage/storageAccounts" + + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/__init__.py index 7df8399a811b..b14eb5626281 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'StorageAccountsOperations', - 'UsageOperations', + "StorageAccountsOperations", + "UsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_operations.py index b5fba128f4ab..27d56f2ab971 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,359 +29,289 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "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), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class StorageAccountsOperations: """ @@ -395,49 +332,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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.storage.v2016_01_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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.storage.v2016_01_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCheckNameAvailabilityParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -445,56 +431,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, - *, - content_type: Optional[str] = "application/json", + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -502,10 +495,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -514,24 +506,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -540,15 +531,16 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCreateParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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. @@ -561,98 +553,173 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountCreateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, parameters=parameters, - content_type=content_type, api_version=api_version, - cls=lambda x,y,z: x, + content_type=content_type, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -660,10 +727,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -673,49 +739,46 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.StorageAccount: + def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -723,34 +786,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -763,33 +824,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountUpdateParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountUpdateParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -798,7 +943,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -806,58 +952,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -865,13 +1008,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -888,10 +1035,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -901,48 +1046,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. + 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -950,14 +1092,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -974,10 +1119,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -987,50 +1130,48 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1038,67 +1179,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, *, - content_type: Optional[str] = "application/json", + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. + Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountRegenerateKeyParameters - :keyword content_type: Media type of the body sent to the API. Known values are: - "application/json" or "text/json". Default value is "application/json". + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Known values are: 'application/json', 'text/json'. 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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. + Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2016_01_01.models.StorageAccountRegenerateKeyParameters or IO + :keyword content_type: Body Parameter content-type. Known values are: 'application/json', + 'text/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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_01_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1107,7 +1319,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1115,22 +1328,20 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_operations.py index 9e0efa121dab..3906f8e7feb0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_01_01/operations/_usage_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsageOperations: """ @@ -78,36 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_01_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-01-01")) # type: Literal["2016-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -115,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -138,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/__init__.py index 7be55ff4bf05..9499d1280cf7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagement'] + +__all__ = [ + "StorageManagement", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_configuration.py index aaf5119d6e5e..627b373ee61f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-12-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", "2016-12-01") # type: Literal["2016-12-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json index 1f0b375d5542..942915f9bfc7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -100,4 +100,4 @@ "storage_accounts": "StorageAccountsOperations", "usage": "UsageOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py index 8dac5df1322d..912c7bdf5409 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_storage_management.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementConfiguration from .operations import StorageAccountsOperations, UsageOperations @@ -22,17 +21,18 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagement: + +class StorageManagement: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar storage_accounts: StorageAccountsOperations operations :vartype storage_accounts: azure.mgmt.storage.v2016_12_01.operations.StorageAccountsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.storage.v2016_12_01.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,16 +60,9 @@ def __init__( self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -78,7 +71,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/__init__.py index 36895a3e2a36..b0fc6191b769 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagement'] + +__all__ = [ + "StorageManagement", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_configuration.py index aa91ae19fe51..3928b427dc14 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2016-12-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2016-12-01") # type: str + api_version = kwargs.pop("api_version", "2016-12-01") # type: Literal["2016-12-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py index cc2c0d6d2260..0c8c360e17bd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/_storage_management.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementConfiguration from .operations import StorageAccountsOperations, UsageOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagement: + +class StorageManagement: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar storage_accounts: StorageAccountsOperations operations @@ -30,10 +30,10 @@ class StorageManagement: azure.mgmt.storage.v2016_12_01.aio.operations.StorageAccountsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.storage.v2016_12_01.aio.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -61,16 +61,9 @@ def __init__( self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -79,7 +72,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/__init__.py index 7df8399a811b..b14eb5626281 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'StorageAccountsOperations', - 'UsageOperations', + "StorageAccountsOperations", + "UsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_operations.py index 01d94dc2ef19..3e097e79ff6c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,28 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +72,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2016_12_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +171,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +235,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +246,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +271,100 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCreateParameters 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 @@ -203,20 +377,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +395,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +470,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,50 +482,48 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,32 +531,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -406,32 +569,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -440,7 +688,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -448,58 +697,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -507,13 +754,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -530,10 +781,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -543,49 +792,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -593,14 +841,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -617,10 +868,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -630,51 +879,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -682,64 +928,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2016_12_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -748,7 +1068,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -756,63 +1077,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2016_12_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -821,7 +1215,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -829,63 +1224,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2016_12_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -894,7 +1360,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -902,22 +1369,20 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_operations.py index 85a4db0fcfc0..16b161f62fb8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/aio/operations/_usage_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usage_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsageOperations: """ .. warning:: @@ -42,37 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2016_12_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -80,13 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -103,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/__init__.py index 02df7dd5ed2e..0dc0aa12296e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/__init__.py @@ -30,66 +30,68 @@ from ._models_py3 import UsageListResult from ._models_py3 import UsageName - -from ._storage_management_enums import ( - AccessTier, - AccountSasParametersSignedPermission, - AccountSasParametersSignedResourceTypes, - AccountSasParametersSignedServices, - AccountStatus, - HttpProtocol, - KeyPermission, - Kind, - Permissions, - ProvisioningState, - Reason, - SignedResource, - SkuName, - SkuTier, - UsageUnit, -) +from ._storage_management_enums import AccessTier +from ._storage_management_enums import AccountSasParametersSignedPermission +from ._storage_management_enums import AccountSasParametersSignedResourceTypes +from ._storage_management_enums import AccountSasParametersSignedServices +from ._storage_management_enums import AccountStatus +from ._storage_management_enums import EncryptionKeySource +from ._storage_management_enums import HttpProtocol +from ._storage_management_enums import KeyPermission +from ._storage_management_enums import Kind +from ._storage_management_enums import Permissions +from ._storage_management_enums import ProvisioningState +from ._storage_management_enums import Reason +from ._storage_management_enums import SignedResource +from ._storage_management_enums import SkuName +from ._storage_management_enums import SkuTier +from ._storage_management_enums import StorageAccountCheckNameAvailabilityParametersType +from ._storage_management_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'CheckNameAvailabilityResult', - 'CustomDomain', - 'Encryption', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'ListAccountSasResponse', - 'ListServiceSasResponse', - 'Resource', - 'ServiceSasParameters', - 'Sku', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'Usage', - 'UsageListResult', - 'UsageName', - 'AccessTier', - 'AccountSasParametersSignedPermission', - 'AccountSasParametersSignedResourceTypes', - 'AccountSasParametersSignedServices', - 'AccountStatus', - 'HttpProtocol', - 'KeyPermission', - 'Kind', - 'Permissions', - 'ProvisioningState', - 'Reason', - 'SignedResource', - 'SkuName', - 'SkuTier', - 'UsageUnit', + "AccountSasParameters", + "CheckNameAvailabilityResult", + "CustomDomain", + "Encryption", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ListAccountSasResponse", + "ListServiceSasResponse", + "Resource", + "ServiceSasParameters", + "Sku", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "Usage", + "UsageListResult", + "UsageName", + "AccessTier", + "AccountSasParametersSignedPermission", + "AccountSasParametersSignedResourceTypes", + "AccountSasParametersSignedServices", + "AccountStatus", + "EncryptionKeySource", + "HttpProtocol", + "KeyPermission", + "Kind", + "Permissions", + "ProvisioningState", + "Reason", + "SignedResource", + "SkuName", + "SkuTier", + "StorageAccountCheckNameAvailabilityParametersType", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py index 9c5a3946046b..79fff5d8f2ef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -9,64 +10,64 @@ import datetime from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - import __init__ as _models + from .. import models as _models -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedServices - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedPermission :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2016_12_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -83,36 +84,37 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedServices - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2016_12_01.models.AccountSasParametersSignedPermission :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2016_12_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -123,7 +125,7 @@ def __init__( self.key_to_sign = key_to_sign -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -133,7 +135,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2016_12_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -141,36 +143,32 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -178,74 +176,69 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. - Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2016_12_01.models.EncryptionServices :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): - Microsoft.Storage. Has constant value: "Microsoft.Storage". - :vartype key_source: str + Microsoft.Storage. Required. "Microsoft.Storage" + :vartype key_source: str or ~azure.mgmt.storage.v2016_12_01.models.EncryptionKeySource """ _validation = { - 'key_source': {'required': True, 'constant': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, } - key_source = "Microsoft.Storage" - def __init__( self, *, + key_source: Union[str, "_models.EncryptionKeySource"], services: Optional["_models.EncryptionServices"] = None, **kwargs ): """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2016_12_01.models.EncryptionServices + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage. Required. "Microsoft.Storage" + :paramtype key_source: str or ~azure.mgmt.storage.v2016_12_01.models.EncryptionKeySource """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services + self.key_source = key_source -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -260,31 +253,26 @@ class EncryptionService(msrest.serialization.Model): """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is stored. :paramtype enabled: bool """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. Variables are only populated by the server, and will be ignored when sending a request. @@ -300,15 +288,15 @@ class EncryptionServices(msrest.serialization.Model): """ _validation = { - 'table': {'readonly': True}, - 'queue': {'readonly': True}, + "table": {"readonly": True}, + "queue": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -324,14 +312,14 @@ def __init__( :keyword file: The encryption function of the file storage service. :paramtype file: ~azure.mgmt.storage.v2016_12_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = None self.queue = None -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, or table object. Variables are only populated by the server, and will be ignored when sending a request. @@ -347,33 +335,29 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Endpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None self.file = None -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -383,24 +367,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -410,24 +390,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Describes a storage resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -440,40 +416,34 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping a - resource (across resource groups). + :ivar tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping - a resource (across resource groups). + :keyword tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -481,25 +451,26 @@ def __init__( self.tags = tags -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str - :ivar resource: Required. The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + :ivar resource: The signed services accessible with the service SAS. Possible values include: + Blob (b), Container (c), File (f), Share (s). Required. Known values are: "b", "c", "f", and + "s". :vartype resource: str or ~azure.mgmt.storage.v2016_12_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2016_12_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2016_12_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -531,30 +502,30 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, + "canonicalized_resource": {"required": True}, + "resource": {"required": True}, + "identifier": {"max_length": 64}, } _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -581,21 +552,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str - :keyword resource: Required. The signed services accessible with the service SAS. Possible - values include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", - "s". + :keyword resource: The signed services accessible with the service SAS. Possible values + include: Blob (b), Container (c), File (f), Share (s). Required. Known values are: "b", "c", + "f", and "s". :paramtype resource: str or ~azure.mgmt.storage.v2016_12_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2016_12_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2016_12_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -626,7 +597,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -647,50 +618,45 @@ def __init__( self.content_type = content_type -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :ivar name: Gets or sets the sku name. Required for account creation; optional for update. Note + that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2016_12_01.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2016_12_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :keyword name: Gets or sets the sku name. Required for account creation; optional for update. + Note that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2016_12_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class StorageAccount(Resource): +class StorageAccount(Resource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -703,15 +669,15 @@ class StorageAccount(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping a - resource (across resource groups). + :ivar tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :vartype tags: dict[str, str] :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2016_12_01.models.Sku - :ivar kind: Gets the Kind. Known values are: "Storage", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage" and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2016_12_01.models.Kind :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2016_12_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -720,7 +686,7 @@ class StorageAccount(Resource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2016_12_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -732,7 +698,7 @@ class StorageAccount(Resource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2016_12_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -746,53 +712,53 @@ class StorageAccount(Resource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_12_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_12_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, } def __init__( @@ -800,20 +766,20 @@ def __init__( *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, - enable_https_traffic_only: Optional[bool] = False, + enable_https_traffic_only: bool = False, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping - a resource (across resource groups). + :keyword tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :paramtype tags: dict[str, str] :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :paramtype enable_https_traffic_only: bool """ - super(StorageAccount, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = None self.kind = None self.provisioning_state = None @@ -831,64 +797,62 @@ def __init__( self.enable_https_traffic_only = enable_https_traffic_only -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. - Variables are only populated by the server, and will be ignored when sending a request. - All required parameters must be populated in order to send to Azure. :ivar name: Required. :vartype name: str - :ivar type: Has constant value: "Microsoft.Storage/storageAccounts". - :vartype type: str + :ivar type: Required. "Microsoft.Storage/storageAccounts" + :vartype type: str or + ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCheckNameAvailabilityParametersType """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs + self, *, name: str, type: Union[str, "_models.StorageAccountCheckNameAvailabilityParametersType"], **kwargs ): """ :keyword name: Required. :paramtype name: str + :keyword type: Required. "Microsoft.Storage/storageAccounts" + :paramtype type: str or + ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCheckNameAvailabilityParametersType """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name + self.type = type -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the sku name. + :ivar sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2016_12_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "BlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage" and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2016_12_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar custom_domain: User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing @@ -898,27 +862,27 @@ class StorageAccountCreateParameters(msrest.serialization.Model): account encryption settings will remain the same. The default setting is unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_12_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_12_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, } _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, } def __init__( @@ -931,24 +895,24 @@ def __init__( custom_domain: Optional["_models.CustomDomain"] = None, encryption: Optional["_models.Encryption"] = None, access_tier: Optional[Union[str, "_models.AccessTier"]] = None, - enable_https_traffic_only: Optional[bool] = False, + enable_https_traffic_only: bool = False, **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the sku name. + :keyword sku: Required. Gets or sets the sku name. Required. :paramtype sku: ~azure.mgmt.storage.v2016_12_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "BlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage" and "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2016_12_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword custom_domain: User domain assigned to the storage account. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear the existing @@ -958,13 +922,13 @@ def __init__( account encryption settings will remain the same. The default setting is unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2016_12_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2016_12_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :paramtype enable_https_traffic_only: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -975,7 +939,7 @@ def __init__( self.enable_https_traffic_only = enable_https_traffic_only -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -985,35 +949,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2016_12_01.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1024,24 +984,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1051,24 +1007,20 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, + "value": {"key": "value", "type": "[StorageAccount]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. @@ -1078,37 +1030,32 @@ class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ :keyword key_name: Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2016_12_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -1118,19 +1065,19 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2016_12_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2016_12_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, } def __init__( @@ -1141,17 +1088,17 @@ def __init__( custom_domain: Optional["_models.CustomDomain"] = None, encryption: Optional["_models.Encryption"] = None, access_tier: Optional[Union[str, "_models.AccessTier"]] = None, - enable_https_traffic_only: Optional[bool] = False, + enable_https_traffic_only: bool = False, **kwargs ): """ :keyword sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2016_12_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -1161,13 +1108,13 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2016_12_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2016_12_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :paramtype enable_https_traffic_only: bool """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.custom_domain = custom_domain @@ -1176,13 +1123,13 @@ def __init__( self.enable_https_traffic_only = enable_https_traffic_only -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2016_12_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -1193,33 +1140,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -1227,24 +1170,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2016_12_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -1256,21 +1194,17 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_storage_management_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_storage_management_enums.py index 985e7c71ea53..1d9ad12f3d7f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_storage_management_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/models/_storage_management_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountSasParametersSignedPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -31,6 +31,7 @@ class AccountSasParametersSignedPermission(str, Enum, metaclass=CaseInsensitiveE U = "u" P = "p" + class AccountSasParametersSignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -41,6 +42,7 @@ class AccountSasParametersSignedResourceTypes(str, Enum, metaclass=CaseInsensiti C = "c" O = "o" + class AccountSasParametersSignedServices(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -51,6 +53,7 @@ class AccountSasParametersSignedServices(str, Enum, metaclass=CaseInsensitiveEnu T = "t" F = "f" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -59,27 +62,34 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + +class EncryptionKeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage.""" + + MICROSOFT_STORAGE = "Microsoft.Storage" + + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required. Indicates the type of storage account. - """ + """Required. Indicates the type of storage account.""" STORAGE = "Storage" BLOB_STORAGE = "BlobStorage" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -94,14 +104,15 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -110,6 +121,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -120,6 +132,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. @@ -131,16 +144,22 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the sku tier. This is based on the SKU name. - """ + """Gets the sku tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + +class StorageAccountCheckNameAvailabilityParametersType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountCheckNameAvailabilityParametersType.""" + + MICROSOFT_STORAGE_STORAGE_ACCOUNTS = "Microsoft.Storage/storageAccounts" + + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/__init__.py index 7df8399a811b..b14eb5626281 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/__init__.py @@ -12,9 +12,10 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'StorageAccountsOperations', - 'UsageOperations', + "StorageAccountsOperations", + "UsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_operations.py index f41259e529b6..285d1d3d054d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,449 +29,375 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class StorageAccountsOperations: """ @@ -485,45 +418,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2016_12_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -531,55 +517,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -587,10 +581,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -599,22 +592,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -623,14 +617,58 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 @@ -642,20 +680,57 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -663,79 +738,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -743,10 +813,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -756,50 +825,46 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.StorageAccount: + def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -807,32 +872,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -845,32 +910,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -879,7 +1029,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -887,58 +1038,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -946,13 +1094,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -969,10 +1121,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -982,49 +1132,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1032,14 +1178,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1056,10 +1205,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1069,51 +1216,48 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1121,64 +1265,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2016_12_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1187,7 +1405,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1195,63 +1414,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2016_12_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1260,7 +1552,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1268,63 +1561,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2016_12_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2016_12_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2016_12_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1333,7 +1697,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1341,22 +1706,20 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_operations.py index d8c69bf2f28f..dd775457bea1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2016_12_01/operations/_usage_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsageOperations: """ @@ -78,36 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2016_12_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2016-12-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2016-12-01")) # type: Literal["2016-12-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -115,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -138,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/__init__.py index 7be55ff4bf05..9499d1280cf7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagement'] + +__all__ = [ + "StorageManagement", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_configuration.py index 6501569a624a..2f9b3c3abcfd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-06-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-06-01") # type: str + api_version = kwargs.pop("api_version", "2017-06-01") # type: Literal["2017-06-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json index e071ed4ba882..f7bb82bcc662 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -102,4 +102,4 @@ "storage_accounts": "StorageAccountsOperations", "usage": "UsageOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py index 4fdfa964c3a5..67585f85dce0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_storage_management.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementConfiguration from .operations import Operations, SkusOperations, StorageAccountsOperations, UsageOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagement: + +class StorageManagement: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar operations: Operations operations @@ -33,10 +33,10 @@ class StorageManagement: :vartype storage_accounts: azure.mgmt.storage.v2017_06_01.operations.StorageAccountsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.storage.v2017_06_01.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -61,25 +61,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -88,7 +77,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/__init__.py index 36895a3e2a36..b0fc6191b769 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagement'] + +__all__ = [ + "StorageManagement", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_configuration.py index cbccdf1a8846..ad81865895da 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-06-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-06-01") # type: str + api_version = kwargs.pop("api_version", "2017-06-01") # type: Literal["2017-06-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py index 9b9c92763004..154a40b37f84 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/_storage_management.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementConfiguration from .operations import Operations, SkusOperations, StorageAccountsOperations, UsageOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagement: + +class StorageManagement: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar operations: Operations operations @@ -34,10 +34,10 @@ class StorageManagement: azure.mgmt.storage.v2017_06_01.aio.operations.StorageAccountsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.storage.v2017_06_01.aio.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,25 +62,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -89,7 +78,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/__init__.py index de141c45187e..9a65d7054c93 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/__init__.py @@ -14,11 +14,12 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsageOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_operations.py index 059e14f909eb..df2531a29a7f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_operations.py index 256fc3d160f2..497658f5f3eb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_operations.py index 75c9c2cd1ff4..ae03a101de12 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,28 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +72,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2017_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +171,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +235,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +246,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +271,100 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCreateParameters 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 @@ -203,20 +377,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +395,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +470,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,50 +482,48 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,32 +531,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -406,32 +569,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -440,7 +688,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -448,58 +697,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -507,13 +754,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -530,10 +781,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -543,49 +792,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -593,14 +841,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -617,10 +868,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -630,51 +879,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -682,64 +928,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2017_06_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -748,7 +1068,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -756,63 +1077,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2017_06_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -821,7 +1215,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -829,63 +1224,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2017_06_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -894,7 +1360,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -902,22 +1369,20 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_operations.py index 824f2dc3e117..ca7093f4103b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/aio/operations/_usage_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usage_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsageOperations: """ .. warning:: @@ -42,37 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_06_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -80,13 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -103,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/__init__.py index 4ee274c194c7..f21f0e27511a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/__init__.py @@ -44,88 +44,86 @@ from ._models_py3 import UsageName from ._models_py3 import VirtualNetworkRule - -from ._storage_management_enums import ( - AccessTier, - AccountStatus, - Bypass, - DefaultAction, - HttpProtocol, - KeyPermission, - KeySource, - Kind, - Permissions, - ProvisioningState, - Reason, - ReasonCode, - Services, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - UsageUnit, -) +from ._storage_management_enums import AccessTier +from ._storage_management_enums import AccountStatus +from ._storage_management_enums import Bypass +from ._storage_management_enums import DefaultAction +from ._storage_management_enums import HttpProtocol +from ._storage_management_enums import KeyPermission +from ._storage_management_enums import KeySource +from ._storage_management_enums import Kind +from ._storage_management_enums import Permissions +from ._storage_management_enums import ProvisioningState +from ._storage_management_enums import Reason +from ._storage_management_enums import ReasonCode +from ._storage_management_enums import Services +from ._storage_management_enums import SignedResource +from ._storage_management_enums import SignedResourceTypes +from ._storage_management_enums import SkuName +from ._storage_management_enums import SkuTier +from ._storage_management_enums import State +from ._storage_management_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'CheckNameAvailabilityResult', - 'CustomDomain', - 'Dimension', - 'Encryption', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'IPRule', - 'Identity', - 'KeyVaultProperties', - 'ListAccountSasResponse', - 'ListServiceSasResponse', - 'MetricSpecification', - 'NetworkRuleSet', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Resource', - 'Restriction', - 'SKUCapability', - 'ServiceSasParameters', - 'ServiceSpecification', - 'Sku', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageSkuListResult', - 'Usage', - 'UsageListResult', - 'UsageName', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'Bypass', - 'DefaultAction', - 'HttpProtocol', - 'KeyPermission', - 'KeySource', - 'Kind', - 'Permissions', - 'ProvisioningState', - 'Reason', - 'ReasonCode', - 'Services', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'UsageUnit', + "AccountSasParameters", + "CheckNameAvailabilityResult", + "CustomDomain", + "Dimension", + "Encryption", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "IPRule", + "Identity", + "KeyVaultProperties", + "ListAccountSasResponse", + "ListServiceSasResponse", + "MetricSpecification", + "NetworkRuleSet", + "Operation", + "OperationDisplay", + "OperationListResult", + "Resource", + "Restriction", + "SKUCapability", + "ServiceSasParameters", + "ServiceSpecification", + "Sku", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageSkuListResult", + "Usage", + "UsageListResult", + "UsageName", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "Bypass", + "DefaultAction", + "HttpProtocol", + "KeyPermission", + "KeySource", + "Kind", + "Permissions", + "ProvisioningState", + "Reason", + "ReasonCode", + "Services", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py index 6c028a46d5b9..c58e2448503e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,63 +8,69 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2017_06_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2017_06_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2017_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2017_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -80,33 +87,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2017_06_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2017_06_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2017_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2017_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -117,7 +125,7 @@ def __init__( self.key_to_sign = key_to_sign -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -127,7 +135,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2017_06_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -135,36 +143,32 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -172,35 +176,29 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -210,51 +208,45 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2017_06_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2017_06_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. :vartype key_vault_properties: ~azure.mgmt.storage.v2017_06_01.models.KeyVaultProperties """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, } def __init__( @@ -268,20 +260,20 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2017_06_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2017_06_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. :paramtype key_vault_properties: ~azure.mgmt.storage.v2017_06_01.models.KeyVaultProperties """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.key_vault_properties = key_vault_properties -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -296,31 +288,26 @@ class EncryptionService(msrest.serialization.Model): """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is stored. :paramtype enabled: bool """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. Variables are only populated by the server, and will be ignored when sending a request. @@ -336,15 +323,15 @@ class EncryptionServices(msrest.serialization.Model): """ _validation = { - 'table': {'readonly': True}, - 'queue': {'readonly': True}, + "table": {"readonly": True}, + "queue": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -360,14 +347,14 @@ def __init__( :keyword file: The encryption function of the file storage service. :paramtype file: ~azure.mgmt.storage.v2017_06_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = None self.queue = None -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, or table object. Variables are only populated by the server, and will be ignored when sending a request. @@ -383,33 +370,29 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Endpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None self.file = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -420,78 +403,66 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Has constant value: "SystemAssigned". + :ivar type: The identity type. Required. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True, 'constant': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "SystemAssigned" - def __init__( - self, - **kwargs - ): - """ - """ - super(Identity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. :ivar key_name: The name of KeyVault key. @@ -503,9 +474,9 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, } def __init__( @@ -524,13 +495,13 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -540,24 +511,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -567,24 +534,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -608,15 +571,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -653,7 +616,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -665,41 +628,41 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2017_06_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2017_06_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2017_06_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2017_06_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs @@ -708,25 +671,25 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2017_06_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: list[~azure.mgmt.storage.v2017_06_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2017_06_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2017_06_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules self.default_action = default_action -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -740,10 +703,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -765,14 +728,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2017_06_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -784,9 +747,9 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } def __init__( @@ -805,13 +768,13 @@ def __init__( :keyword operation: Type of operation: get, read, delete, etc. :paramtype operation: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -819,24 +782,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2017_06_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Describes a storage resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -849,40 +807,34 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping a - resource (across resource groups). + :ivar tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping - a resource (across resource groups). + :keyword tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -890,7 +842,7 @@ def __init__( self.tags = tags -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -903,59 +855,55 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2017_06_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2017_06_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str - :ivar resource: Required. The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + :ivar resource: The signed services accessible with the service SAS. Possible values include: + Blob (b), Container (c), File (f), Share (s). Required. Known values are: "b", "c", "f", and + "s". :vartype resource: str or ~azure.mgmt.storage.v2017_06_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2017_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2017_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -987,30 +935,30 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, + "canonicalized_resource": {"required": True}, + "resource": {"required": True}, + "identifier": {"max_length": 64}, } _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -1037,21 +985,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str - :keyword resource: Required. The signed services accessible with the service SAS. Possible - values include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", - "s". + :keyword resource: The signed services accessible with the service SAS. Possible values + include: Blob (b), Container (c), File (f), Share (s). Required. Known values are: "b", "c", + "f", and "s". :paramtype resource: str or ~azure.mgmt.storage.v2017_06_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2017_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2017_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -1082,7 +1030,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -1103,7 +1051,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -1112,41 +1060,37 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2017_06_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :ivar name: Gets or sets the sku name. Required for account creation; optional for update. Note + that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2017_06_01.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2017_06_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str - :ivar kind: Indicates the type of storage account. Known values are: "Storage", "BlobStorage". + :ivar kind: Indicates the type of storage account. Known values are: "Storage" and + "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_06_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -1160,22 +1104,22 @@ class Sku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -1186,15 +1130,15 @@ def __init__( **kwargs ): """ - :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :keyword name: Gets or sets the sku name. Required for account creation; optional for update. + Note that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2017_06_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2017_06_01.models.Restriction] """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -1204,7 +1148,7 @@ def __init__( self.restrictions = restrictions -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified sku, including file encryption, network acls, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -1217,27 +1161,23 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class StorageAccount(Resource): +class StorageAccount(Resource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -1250,17 +1190,17 @@ class StorageAccount(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping a - resource (across resource groups). + :ivar tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :vartype tags: dict[str, str] :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2017_06_01.models.Sku - :ivar kind: Gets the Kind. Known values are: "Storage", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage" and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_06_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2017_06_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2017_06_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -1269,7 +1209,7 @@ class StorageAccount(Resource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2017_06_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -1281,7 +1221,7 @@ class StorageAccount(Resource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2017_06_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -1295,7 +1235,7 @@ class StorageAccount(Resource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2017_06_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_06_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1304,49 +1244,49 @@ class StorageAccount(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, } def __init__( @@ -1355,14 +1295,14 @@ def __init__( location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, identity: Optional["_models.Identity"] = None, - enable_https_traffic_only: Optional[bool] = False, + enable_https_traffic_only: bool = False, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping - a resource (across resource groups). + :keyword tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2017_06_01.models.Identity @@ -1370,7 +1310,7 @@ def __init__( true. :paramtype enable_https_traffic_only: bool """ - super(StorageAccount, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -1390,65 +1330,60 @@ def __init__( self.network_rule_set = None -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the sku name. + :ivar sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2017_06_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "BlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage" and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_06_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2017_06_01.models.Identity @@ -1462,29 +1397,29 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2017_06_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_06_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, } _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, } def __init__( @@ -1499,24 +1434,24 @@ def __init__( encryption: Optional["_models.Encryption"] = None, network_rule_set: Optional["_models.NetworkRuleSet"] = None, access_tier: Optional[Union[str, "_models.AccessTier"]] = None, - enable_https_traffic_only: Optional[bool] = False, + enable_https_traffic_only: bool = False, **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the sku name. + :keyword sku: Required. Gets or sets the sku name. Required. :paramtype sku: ~azure.mgmt.storage.v2017_06_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "BlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage" and "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2017_06_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2017_06_01.models.Identity @@ -1530,13 +1465,13 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2017_06_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2017_06_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :paramtype enable_https_traffic_only: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -1549,7 +1484,7 @@ def __init__( self.enable_https_traffic_only = enable_https_traffic_only -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -1559,35 +1494,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2017_06_01.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1598,24 +1529,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1625,66 +1552,57 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, + "value": {"key": "value", "type": "[StorageAccount]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2017_06_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2017_06_01.models.Identity @@ -1696,7 +1614,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2017_06_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_06_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1705,14 +1623,14 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, } def __init__( @@ -1724,7 +1642,7 @@ def __init__( custom_domain: Optional["_models.CustomDomain"] = None, encryption: Optional["_models.Encryption"] = None, access_tier: Optional[Union[str, "_models.AccessTier"]] = None, - enable_https_traffic_only: Optional[bool] = False, + enable_https_traffic_only: bool = False, network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): @@ -1732,10 +1650,10 @@ def __init__( :keyword sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2017_06_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2017_06_01.models.Identity @@ -1747,7 +1665,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2017_06_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2017_06_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -1755,7 +1673,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2017_06_01.models.NetworkRuleSet """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -1766,7 +1684,7 @@ def __init__( self.network_rule_set = network_rule_set -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1776,30 +1694,26 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Sku]'}, + "value": {"key": "value", "type": "[Sku]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2017_06_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -1810,33 +1724,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -1844,24 +1754,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2017_06_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -1873,72 +1778,68 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2017_06_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2017_06_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_storage_management_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_storage_management_enums.py index 5802979735e7..c72c36f87543 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_storage_management_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/models/_storage_management_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,6 +25,7 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -36,42 +37,44 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" BLOB_STORAGE = "BlobStorage" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -86,14 +89,15 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -102,6 +106,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -112,6 +117,7 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -122,6 +128,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -132,6 +139,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -142,6 +150,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. @@ -153,16 +162,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the sku tier. This is based on the SKU name. - """ + """Gets the sku tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "provisioning" DEPROVISIONING = "deprovisioning" @@ -170,9 +179,9 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/__init__.py index de141c45187e..9a65d7054c93 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/__init__.py @@ -14,11 +14,12 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsageOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_operations.py index 2c251647d8f0..1fb2dece387f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_operations.py index 69e3e3e96457..d57bcedf999c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_operations.py index da931aac0f06..817b210cf2ff 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,449 +29,375 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class StorageAccountsOperations: """ @@ -485,45 +418,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2017_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -531,55 +517,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -587,10 +581,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -599,22 +592,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -623,14 +617,58 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 @@ -642,20 +680,57 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -663,79 +738,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -743,10 +813,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -756,50 +825,46 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.StorageAccount: + def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -807,32 +872,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -845,32 +910,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -879,7 +1029,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -887,58 +1038,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -946,13 +1094,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -969,10 +1121,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -982,49 +1132,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1032,14 +1178,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1056,10 +1205,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1069,51 +1216,48 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1121,64 +1265,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2017_06_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1187,7 +1405,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1195,63 +1414,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2017_06_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1260,7 +1552,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1268,63 +1561,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2017_06_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_06_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1333,7 +1697,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1341,22 +1706,20 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_operations.py index f39c8ad5e632..ad941a8ba3e1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_06_01/operations/_usage_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsageOperations: """ @@ -78,36 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_06_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-06-01")) # type: Literal["2017-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -115,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -138,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/__init__.py index 7be55ff4bf05..9499d1280cf7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagement'] + +__all__ = [ + "StorageManagement", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_configuration.py index f3081e971947..0842d8a0e4e0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,24 +31,19 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-10-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + api_version = kwargs.pop("api_version", "2017-10-01") # type: Literal["2017-10-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,23 +53,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json index 3fb6ec0f3b28..d7f869a97ca7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "signature": "subscription_id: str,", + "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", + "description": "Gets subscription credentials which uniquely identify the Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -102,4 +102,4 @@ "storage_accounts": "StorageAccountsOperations", "usage": "UsageOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py index 77054fa8a229..cde788a595bc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_storage_management.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementConfiguration from .operations import Operations, SkusOperations, StorageAccountsOperations, UsageOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagement: + +class StorageManagement: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar operations: Operations operations @@ -33,10 +33,10 @@ class StorageManagement: :vartype storage_accounts: azure.mgmt.storage.v2017_10_01.operations.StorageAccountsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.storage.v2017_10_01.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -61,25 +61,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -88,7 +77,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/__init__.py index 36895a3e2a36..b0fc6191b769 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagement'] + +__all__ = [ + "StorageManagement", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_configuration.py index d381be1f70ce..8a102cdbf360 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,24 +31,19 @@ class StorageManagementConfiguration(Configuration): # pylint: disable=too-many Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2017-10-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2017-10-01") # type: str + api_version = kwargs.pop("api_version", "2017-10-01") # type: Literal["2017-10-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -52,22 +53,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py index 2e9d63a3022f..52d5baed2149 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/_storage_management.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementConfiguration from .operations import Operations, SkusOperations, StorageAccountsOperations, UsageOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagement: + +class StorageManagement: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar operations: Operations operations @@ -34,10 +34,10 @@ class StorageManagement: azure.mgmt.storage.v2017_10_01.aio.operations.StorageAccountsOperations :ivar usage: UsageOperations operations :vartype usage: azure.mgmt.storage.v2017_10_01.aio.operations.UsageOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: Gets subscription credentials which uniquely identify the Microsoft - Azure subscription. The subscription ID forms part of the URI for every service call. + Azure subscription. The subscription ID forms part of the URI for every service call. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,25 +62,14 @@ def __init__( self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -89,7 +78,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/__init__.py index de141c45187e..9a65d7054c93 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/__init__.py @@ -14,11 +14,12 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsageOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_operations.py index 349fa83224c5..008634941c00 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_operations.py index 62fd02ac34c6..959987ecc202 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_operations.py index e68a6145f16b..35664f0b672e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,28 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +72,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2017_10_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +171,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +235,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +246,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +271,100 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCreateParameters 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 @@ -203,20 +377,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +395,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +470,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,50 +482,48 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,32 +531,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -406,32 +569,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -440,7 +688,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -448,58 +697,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -507,13 +754,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -530,10 +781,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -543,49 +792,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -593,14 +841,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -617,10 +868,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -630,51 +879,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -682,64 +928,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2017_10_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -748,7 +1068,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -756,63 +1077,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2017_10_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -821,7 +1215,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -829,63 +1224,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2017_10_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -894,7 +1360,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -902,22 +1369,20 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_operations.py index 92609f96cbd9..a6623fb4eaad 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/aio/operations/_usage_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usage_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsageOperations: """ .. warning:: @@ -42,37 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2017_10_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -80,13 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -103,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/__init__.py index 4ee274c194c7..f21f0e27511a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/__init__.py @@ -44,88 +44,86 @@ from ._models_py3 import UsageName from ._models_py3 import VirtualNetworkRule - -from ._storage_management_enums import ( - AccessTier, - AccountStatus, - Bypass, - DefaultAction, - HttpProtocol, - KeyPermission, - KeySource, - Kind, - Permissions, - ProvisioningState, - Reason, - ReasonCode, - Services, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - UsageUnit, -) +from ._storage_management_enums import AccessTier +from ._storage_management_enums import AccountStatus +from ._storage_management_enums import Bypass +from ._storage_management_enums import DefaultAction +from ._storage_management_enums import HttpProtocol +from ._storage_management_enums import KeyPermission +from ._storage_management_enums import KeySource +from ._storage_management_enums import Kind +from ._storage_management_enums import Permissions +from ._storage_management_enums import ProvisioningState +from ._storage_management_enums import Reason +from ._storage_management_enums import ReasonCode +from ._storage_management_enums import Services +from ._storage_management_enums import SignedResource +from ._storage_management_enums import SignedResourceTypes +from ._storage_management_enums import SkuName +from ._storage_management_enums import SkuTier +from ._storage_management_enums import State +from ._storage_management_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'CheckNameAvailabilityResult', - 'CustomDomain', - 'Dimension', - 'Encryption', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'IPRule', - 'Identity', - 'KeyVaultProperties', - 'ListAccountSasResponse', - 'ListServiceSasResponse', - 'MetricSpecification', - 'NetworkRuleSet', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Resource', - 'Restriction', - 'SKUCapability', - 'ServiceSasParameters', - 'ServiceSpecification', - 'Sku', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageSkuListResult', - 'Usage', - 'UsageListResult', - 'UsageName', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'Bypass', - 'DefaultAction', - 'HttpProtocol', - 'KeyPermission', - 'KeySource', - 'Kind', - 'Permissions', - 'ProvisioningState', - 'Reason', - 'ReasonCode', - 'Services', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'UsageUnit', + "AccountSasParameters", + "CheckNameAvailabilityResult", + "CustomDomain", + "Dimension", + "Encryption", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "IPRule", + "Identity", + "KeyVaultProperties", + "ListAccountSasResponse", + "ListServiceSasResponse", + "MetricSpecification", + "NetworkRuleSet", + "Operation", + "OperationDisplay", + "OperationListResult", + "Resource", + "Restriction", + "SKUCapability", + "ServiceSasParameters", + "ServiceSpecification", + "Sku", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageSkuListResult", + "Usage", + "UsageListResult", + "UsageName", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "Bypass", + "DefaultAction", + "HttpProtocol", + "KeyPermission", + "KeySource", + "Kind", + "Permissions", + "ProvisioningState", + "Reason", + "ReasonCode", + "Services", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py index 325f86cf7b94..6ec73d78cda3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,63 +8,69 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2017_10_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2017_10_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2017_10_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2017_10_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -80,33 +87,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2017_10_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2017_10_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2017_10_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2017_10_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -117,7 +125,7 @@ def __init__( self.key_to_sign = key_to_sign -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -127,7 +135,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2017_10_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -135,36 +143,32 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -172,35 +176,29 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -210,51 +208,45 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2017_10_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2017_10_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. :vartype key_vault_properties: ~azure.mgmt.storage.v2017_10_01.models.KeyVaultProperties """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, } def __init__( @@ -268,20 +260,20 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2017_10_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2017_10_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. :paramtype key_vault_properties: ~azure.mgmt.storage.v2017_10_01.models.KeyVaultProperties """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.key_vault_properties = key_vault_properties -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -296,31 +288,26 @@ class EncryptionService(msrest.serialization.Model): """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is stored. :paramtype enabled: bool """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. Variables are only populated by the server, and will be ignored when sending a request. @@ -336,15 +323,15 @@ class EncryptionServices(msrest.serialization.Model): """ _validation = { - 'table': {'readonly': True}, - 'queue': {'readonly': True}, + "table": {"readonly": True}, + "queue": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -360,14 +347,14 @@ def __init__( :keyword file: The encryption function of the file storage service. :paramtype file: ~azure.mgmt.storage.v2017_10_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = None self.queue = None -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, or table object. Variables are only populated by the server, and will be ignored when sending a request. @@ -383,33 +370,29 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Endpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None self.file = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -420,78 +403,66 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Has constant value: "SystemAssigned". + :ivar type: The identity type. Required. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True, 'constant': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "SystemAssigned" - def __init__( - self, - **kwargs - ): - """ - """ - super(Identity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. :ivar key_name: The name of KeyVault key. @@ -503,9 +474,9 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, } def __init__( @@ -524,13 +495,13 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -540,24 +511,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -567,24 +534,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -608,15 +571,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -653,7 +616,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -665,41 +628,41 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2017_10_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2017_10_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2017_10_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2017_10_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs @@ -708,25 +671,25 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2017_10_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: list[~azure.mgmt.storage.v2017_10_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2017_10_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2017_10_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules self.default_action = default_action -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -740,10 +703,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -765,14 +728,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2017_10_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -784,9 +747,9 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, } def __init__( @@ -805,13 +768,13 @@ def __init__( :keyword operation: Type of operation: get, read, delete, etc. :paramtype operation: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -819,24 +782,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2017_10_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Resource(msrest.serialization.Model): +class Resource(_serialization.Model): """Describes a storage resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -849,40 +807,34 @@ class Resource(msrest.serialization.Model): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping a - resource (across resource groups). + :ivar tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :vartype tags: dict[str, str] """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, } - def __init__( - self, - *, - location: Optional[str] = None, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, **kwargs): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping - a resource (across resource groups). + :keyword tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :paramtype tags: dict[str, str] """ - super(Resource, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -890,7 +842,7 @@ def __init__( self.tags = tags -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -903,59 +855,55 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2017_10_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2017_10_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str - :ivar resource: Required. The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + :ivar resource: The signed services accessible with the service SAS. Possible values include: + Blob (b), Container (c), File (f), Share (s). Required. Known values are: "b", "c", "f", and + "s". :vartype resource: str or ~azure.mgmt.storage.v2017_10_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2017_10_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2017_10_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -987,30 +935,30 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, + "canonicalized_resource": {"required": True}, + "resource": {"required": True}, + "identifier": {"max_length": 64}, } _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -1037,21 +985,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str - :keyword resource: Required. The signed services accessible with the service SAS. Possible - values include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", - "s". + :keyword resource: The signed services accessible with the service SAS. Possible values + include: Blob (b), Container (c), File (f), Share (s). Required. Known values are: "b", "c", + "f", and "s". :paramtype resource: str or ~azure.mgmt.storage.v2017_10_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2017_10_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2017_10_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -1082,7 +1030,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -1103,7 +1051,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -1112,42 +1060,37 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2017_10_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :ivar name: Gets or sets the sku name. Required for account creation; optional for update. Note + that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2017_10_01.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2017_10_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage". + and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -1161,22 +1104,22 @@ class Sku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -1187,15 +1130,15 @@ def __init__( **kwargs ): """ - :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :keyword name: Gets or sets the sku name. Required for account creation; optional for update. + Note that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2017_10_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2017_10_01.models.Restriction] """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -1205,7 +1148,7 @@ def __init__( self.restrictions = restrictions -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified sku, including file encryption, network acls, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -1218,27 +1161,23 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class StorageAccount(Resource): +class StorageAccount(Resource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -1251,17 +1190,17 @@ class StorageAccount(Resource): :vartype type: str :ivar location: Resource location. :vartype location: str - :ivar tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping a - resource (across resource groups). + :ivar tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :vartype tags: dict[str, str] :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2017_10_01.models.Sku - :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2017_10_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2017_10_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -1270,7 +1209,7 @@ class StorageAccount(Resource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2017_10_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -1282,7 +1221,7 @@ class StorageAccount(Resource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2017_10_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -1296,7 +1235,7 @@ class StorageAccount(Resource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2017_10_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_10_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1305,49 +1244,49 @@ class StorageAccount(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, } def __init__( @@ -1356,14 +1295,14 @@ def __init__( location: Optional[str] = None, tags: Optional[Dict[str, str]] = None, identity: Optional["_models.Identity"] = None, - enable_https_traffic_only: Optional[bool] = False, + enable_https_traffic_only: bool = False, **kwargs ): """ :keyword location: Resource location. :paramtype location: str - :keyword tags: A set of tags. Tags assigned to a resource; can be used for viewing and grouping - a resource (across resource groups). + :keyword tags: Tags assigned to a resource; can be used for viewing and grouping a resource + (across resource groups). :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2017_10_01.models.Identity @@ -1371,7 +1310,7 @@ def __init__( true. :paramtype enable_https_traffic_only: bool """ - super(StorageAccount, self).__init__(location=location, tags=tags, **kwargs) + super().__init__(location=location, tags=tags, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -1391,65 +1330,60 @@ def __init__( self.network_rule_set = None -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the sku name. + :ivar sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2017_10_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2017_10_01.models.Identity @@ -1463,29 +1397,29 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2017_10_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_10_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, } _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, } def __init__( @@ -1500,24 +1434,24 @@ def __init__( encryption: Optional["_models.Encryption"] = None, network_rule_set: Optional["_models.NetworkRuleSet"] = None, access_tier: Optional[Union[str, "_models.AccessTier"]] = None, - enable_https_traffic_only: Optional[bool] = False, + enable_https_traffic_only: bool = False, **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the sku name. + :keyword sku: Required. Gets or sets the sku name. Required. :paramtype sku: ~azure.mgmt.storage.v2017_10_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", and "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2017_10_01.models.Identity @@ -1531,13 +1465,13 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2017_10_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2017_10_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :paramtype enable_https_traffic_only: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -1550,7 +1484,7 @@ def __init__( self.enable_https_traffic_only = enable_https_traffic_only -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -1560,35 +1494,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2017_10_01.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1599,24 +1529,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1626,71 +1552,62 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, + "value": {"key": "value", "type": "[StorageAccount]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2017_10_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2017_10_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -1700,7 +1617,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2017_10_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2017_10_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1709,15 +1626,15 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, } def __init__( @@ -1730,7 +1647,7 @@ def __init__( custom_domain: Optional["_models.CustomDomain"] = None, encryption: Optional["_models.Encryption"] = None, access_tier: Optional[Union[str, "_models.AccessTier"]] = None, - enable_https_traffic_only: Optional[bool] = False, + enable_https_traffic_only: bool = False, network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): @@ -1738,15 +1655,15 @@ def __init__( :keyword sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2017_10_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2017_10_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", and "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2017_10_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -1756,7 +1673,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2017_10_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2017_10_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -1764,7 +1681,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2017_10_01.models.NetworkRuleSet """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -1776,7 +1693,7 @@ def __init__( self.network_rule_set = network_rule_set -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1786,30 +1703,26 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Sku]'}, + "value": {"key": "value", "type": "[Sku]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2017_10_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -1820,33 +1733,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -1854,24 +1763,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2017_10_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -1883,72 +1787,68 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2017_10_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2017_10_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_storage_management_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_storage_management_enums.py index 3ecb508b75bd..e71618c003a3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_storage_management_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/models/_storage_management_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,6 +25,7 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -36,43 +37,45 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" BLOB_STORAGE = "BlobStorage" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -87,14 +90,15 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -103,6 +107,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -113,6 +118,7 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -123,6 +129,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -133,6 +140,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -143,6 +151,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. @@ -154,16 +163,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the sku tier. This is based on the SKU name. - """ + """Gets the sku tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "provisioning" DEPROVISIONING = "deprovisioning" @@ -171,9 +180,9 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/__init__.py index de141c45187e..9a65d7054c93 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/__init__.py @@ -14,11 +14,12 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsageOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsageOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_operations.py index e75845cd0f52..3687fc076a42 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_operations.py index 0ce92d5f7aed..c7af10780284 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_operations.py index 162ad06e0faa..eb56d4d84eb7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,449 +29,375 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class StorageAccountsOperations: """ @@ -485,45 +418,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2017_10_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -531,55 +517,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -587,10 +581,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -599,22 +592,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -623,14 +617,58 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 @@ -642,20 +680,57 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -663,79 +738,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -743,10 +813,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -756,50 +825,46 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.StorageAccount: + def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -807,32 +872,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -845,32 +910,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -879,7 +1029,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -887,58 +1038,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -946,13 +1094,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -969,10 +1121,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -982,49 +1132,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1032,14 +1178,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1056,10 +1205,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1069,51 +1216,48 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1121,64 +1265,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2017_10_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1187,7 +1405,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1195,63 +1414,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2017_10_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1260,7 +1552,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1268,63 +1561,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2017_10_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2017_10_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2017_10_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1333,7 +1697,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1341,22 +1706,20 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_operations.py index a3c5b39f680b..edd91c6c9aea 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2017_10_01/operations/_usage_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - accept = _headers.pop('Accept', "application/json, text/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + accept = _headers.pop("Accept", "application/json, text/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsageOperations: """ @@ -78,36 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2017_10_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2017-10-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2017-10-01")) # type: Literal["2017-10-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -115,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -138,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_configuration.py index 8db7df8cecb7..8aca545cae22 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-02-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", "2018-02-01") # type: Literal["2018-02-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json index 3aecb678b570..053ff7f6022c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -103,4 +103,4 @@ "usage": "UsageOperations", "blob_containers": "BlobContainersOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py index dc101a7829a4..8d5008d797e9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_storage_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration from .operations import BlobContainersOperations, Operations, SkusOperations, StorageAccountsOperations, UsageOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar operations: Operations operations @@ -35,9 +35,9 @@ class StorageManagementClient: :vartype usage: azure.mgmt.storage.v2018_02_01.operations.UsageOperations :ivar blob_containers: BlobContainersOperations operations :vartype blob_containers: azure.mgmt.storage.v2018_02_01.operations.BlobContainersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -55,35 +55,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -92,7 +81,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_configuration.py index 46882474b47d..0ce085ef7553 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-02-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-02-01") # type: str + api_version = kwargs.pop("api_version", "2018-02-01") # type: Literal["2018-02-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py index 3848c2fac697..91c887939ce0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/_storage_management_client.py @@ -9,12 +9,11 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration from .operations import BlobContainersOperations, Operations, SkusOperations, StorageAccountsOperations, UsageOperations @@ -22,7 +21,8 @@ # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar operations: Operations operations @@ -37,9 +37,9 @@ class StorageManagementClient: :ivar blob_containers: BlobContainersOperations operations :vartype blob_containers: azure.mgmt.storage.v2018_02_01.aio.operations.BlobContainersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,35 +57,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usage = UsageOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usage = UsageOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -94,7 +83,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/__init__.py index 09b0517d9606..09e3ff5ad13c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/__init__.py @@ -15,12 +15,13 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsageOperations', - 'BlobContainersOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsageOperations", + "BlobContainersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_operations.py index 3ad451cd79fd..238d6ffab85a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_blob_containers_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -41,47 +69,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListContainerItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContainerItems, or the result of cls(response) + :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListContainerItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -89,33 +113,33 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListContainerItems', pipeline_response) + deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -123,37 +147,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -163,7 +274,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -171,70 +283,155 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -244,7 +441,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -252,72 +450,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -325,72 +519,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -398,10 +588,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -411,16 +600,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -428,37 +618,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -468,7 +745,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -476,70 +754,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -549,7 +912,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -557,51 +921,55 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum12], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_02_01.models.Enum12 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -609,44 +977,144 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum12], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_02_01.models.Enum12 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum12], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_02_01.models.Enum12 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -654,10 +1122,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -665,17 +1132,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -683,6 +1149,7 @@ async def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum12], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -690,52 +1157,52 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_02_01.models.Enum12 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -743,10 +1210,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -754,17 +1220,16 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -772,6 +1237,7 @@ async def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum12], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -781,52 +1247,52 @@ async def delete_immutability_policy( container after deleting all blobs inside the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_02_01.models.Enum12 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -834,10 +1300,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -845,71 +1310,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -917,10 +1378,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -928,19 +1388,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -948,6 +1407,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -955,56 +1416,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1012,10 +1572,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1023,65 +1582,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1091,7 +1736,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1099,22 +1745,20 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_operations.py index efacb94f6e84..d28a11a690e0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_operations.py index ec6a79836e0a..2c2e7f0dbb8b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_operations.py index 7925bc1115ea..5f7620ad933d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,28 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +72,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2018_02_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +171,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +235,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +246,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +271,100 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCreateParameters 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 @@ -203,20 +377,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +395,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +470,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,50 +482,48 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,32 +531,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -406,32 +569,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -440,7 +688,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -448,58 +697,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -507,13 +754,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -530,10 +781,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -543,49 +792,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -593,14 +841,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -617,10 +868,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -630,51 +879,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -682,64 +928,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2018_02_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -748,7 +1068,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -756,63 +1077,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -821,7 +1215,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -829,63 +1224,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -894,7 +1360,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -902,22 +1369,20 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_operations.py index 934beff80326..e0705c4aaa0d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/aio/operations/_usage_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usage_operations import build_list_by_location_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsageOperations: """ .. warning:: @@ -42,37 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -80,13 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -103,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,47 +132,44 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_02_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -164,14 +177,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -188,10 +204,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -201,8 +215,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py index f38b411ec76d..3a28fdccc02a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/__init__.py @@ -57,115 +57,115 @@ from ._models_py3 import UsageName from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountStatus, - Bypass, - DefaultAction, - HttpProtocol, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - KeyPermission, - KeySource, - Kind, - LeaseContainerRequestAction, - LeaseDuration, - LeaseState, - LeaseStatus, - Permissions, - ProvisioningState, - PublicAccess, - Reason, - ReasonCode, - Services, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import Enum12 +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'AzureEntityResource', - 'BlobContainer', - 'CheckNameAvailabilityResult', - 'CustomDomain', - 'Dimension', - 'Encryption', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'KeyVaultProperties', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListContainerItem', - 'ListContainerItems', - 'ListServiceSasResponse', - 'MetricSpecification', - 'NetworkRuleSet', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Resource', - 'Restriction', - 'SKUCapability', - 'ServiceSasParameters', - 'ServiceSpecification', - 'Sku', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageSkuListResult', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'Bypass', - 'DefaultAction', - 'HttpProtocol', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'KeyPermission', - 'KeySource', - 'Kind', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseState', - 'LeaseStatus', - 'Permissions', - 'ProvisioningState', - 'PublicAccess', - 'Reason', - 'ReasonCode', - 'Services', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'UsageUnit', + "AccountSasParameters", + "AzureEntityResource", + "BlobContainer", + "CheckNameAvailabilityResult", + "CustomDomain", + "Dimension", + "Encryption", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "KeyVaultProperties", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListContainerItem", + "ListContainerItems", + "ListServiceSasResponse", + "MetricSpecification", + "NetworkRuleSet", + "Operation", + "OperationDisplay", + "OperationListResult", + "Resource", + "Restriction", + "SKUCapability", + "ServiceSasParameters", + "ServiceSpecification", + "Sku", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageSkuListResult", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "Bypass", + "DefaultAction", + "Enum12", + "HttpProtocol", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "KeyPermission", + "KeySource", + "Kind", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseState", + "LeaseStatus", + "Permissions", + "ProvisioningState", + "PublicAccess", + "Reason", + "ReasonCode", + "Services", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py index 8b3f6431b892..3ebeeddc88cb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,63 +8,69 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2018_02_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2018_02_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_02_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_02_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -80,33 +87,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2018_02_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2018_02_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_02_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_02_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -117,7 +125,7 @@ def __init__( self.key_to_sign = key_to_sign -class Resource(msrest.serialization.Model): +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. @@ -133,24 +141,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -174,30 +178,26 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -213,17 +213,18 @@ class BlobContainer(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_02_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -244,35 +245,35 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -284,12 +285,12 @@ def __init__( ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_02_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_access = public_access self.last_modified_time = None self.lease_status = None @@ -302,7 +303,7 @@ def __init__( self.has_immutability_policy = None -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -312,7 +313,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2018_02_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -320,36 +321,32 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -357,35 +354,29 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -395,51 +386,45 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_02_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2018_02_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. :vartype key_vault_properties: ~azure.mgmt.storage.v2018_02_01.models.KeyVaultProperties """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, } def __init__( @@ -453,20 +438,20 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2018_02_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2018_02_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. :paramtype key_vault_properties: ~azure.mgmt.storage.v2018_02_01.models.KeyVaultProperties """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.key_vault_properties = key_vault_properties -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -481,31 +466,26 @@ class EncryptionService(msrest.serialization.Model): """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is stored. :paramtype enabled: bool """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. Variables are only populated by the server, and will be ignored when sending a request. @@ -521,15 +501,15 @@ class EncryptionServices(msrest.serialization.Model): """ _validation = { - 'table': {'readonly': True}, - 'queue': {'readonly': True}, + "table": {"readonly": True}, + "queue": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -545,14 +525,14 @@ def __init__( :keyword file: The encryption function of the file storage service. :paramtype file: ~azure.mgmt.storage.v2018_02_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = None self.queue = None -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -572,30 +552,26 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Endpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -604,7 +580,7 @@ def __init__( self.dfs = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -615,31 +591,27 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Has constant value: "SystemAssigned". + :ivar type: The identity type. Required. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True, 'constant': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "SystemAssigned" - def __init__( - self, - **kwargs - ): - """ - """ - super(Identity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -661,49 +633,47 @@ class ImmutabilityPolicy(AzureEntityResource): :vartype type: str :ivar etag: Resource Etag. :vartype etag: str - :ivar immutability_period_since_creation_in_days: Required. The immutability period for the - blobs in the container since the policy creation, in days. + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. Required. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicyState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'required': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "immutability_period_since_creation_in_days": {"required": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, } - def __init__( - self, - *, - immutability_period_since_creation_in_days: int, - **kwargs - ): + def __init__(self, *, immutability_period_since_creation_in_days: int, **kwargs): """ - :keyword immutability_period_since_creation_in_days: Required. The immutability period for the - blobs in the container since the policy creation, in days. + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. Required. :paramtype immutability_period_since_creation_in_days: int """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -716,84 +686,74 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicyState """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, } - def __init__( - self, - *, - immutability_period_since_creation_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, immutability_period_since_creation_in_days: Optional[int] = None, **kwargs): """ :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. :paramtype immutability_period_since_creation_in_days: int """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. :ivar key_name: The name of KeyVault key. @@ -805,9 +765,9 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, } def __init__( @@ -826,19 +786,19 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -854,15 +814,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -876,8 +836,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -891,7 +851,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -899,7 +859,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -910,17 +870,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -928,12 +882,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -945,38 +899,33 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, } - def __init__( - self, - *, - tags: List[str], - **kwargs - ): + def __init__(self, *, tags: List[str], **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -986,35 +935,30 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2018_02_01.models.TagProperty] """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, } - def __init__( - self, - *, - tags: Optional[List["_models.TagProperty"]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[List["_models.TagProperty"]] = None, **kwargs): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2018_02_01.models.TagProperty] """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1024,24 +968,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -1057,17 +997,18 @@ class ListContainerItem(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_02_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_02_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -1088,35 +1029,35 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -1128,12 +1069,12 @@ def __init__( ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_02_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_access = public_access self.last_modified_time = None self.lease_status = None @@ -1146,7 +1087,7 @@ def __init__( self.has_immutability_policy = None -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """The list of blob containers. :ivar value: The list of blob containers. @@ -1154,24 +1095,19 @@ class ListContainerItems(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ListContainerItem"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ListContainerItem"]] = None, **kwargs): """ :keyword value: The list of blob containers. :paramtype value: list[~azure.mgmt.storage.v2018_02_01.models.ListContainerItem] """ - super(ListContainerItems, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1181,24 +1117,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -1222,15 +1154,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -1267,7 +1199,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1279,41 +1211,41 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2018_02_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2018_02_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2018_02_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2018_02_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs @@ -1322,25 +1254,25 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2018_02_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: list[~azure.mgmt.storage.v2018_02_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2018_02_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2018_02_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules self.default_action = default_action -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1354,10 +1286,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -1379,14 +1311,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2018_02_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -1400,10 +1332,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1425,14 +1357,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -1440,24 +1372,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2018_02_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -1470,59 +1397,54 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2018_02_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2018_02_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2018_02_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_02_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_02_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -1554,29 +1476,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, } _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -1603,20 +1525,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2018_02_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_02_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_02_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -1647,7 +1570,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -1668,7 +1591,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -1677,42 +1600,37 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2018_02_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :ivar name: Gets or sets the sku name. Required for account creation; optional for update. Note + that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2018_02_01.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2018_02_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage". + and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -1726,22 +1644,22 @@ class Sku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -1752,15 +1670,15 @@ def __init__( **kwargs ): """ - :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :keyword name: Gets or sets the sku name. Required for account creation; optional for update. + Note that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2018_02_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2018_02_01.models.Restriction] """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -1770,7 +1688,7 @@ def __init__( self.restrictions = restrictions -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified sku, including file encryption, network acls, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -1783,22 +1701,18 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None @@ -1818,46 +1732,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -1872,18 +1780,18 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2018_02_01.models.Sku - :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_02_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2018_02_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -1892,7 +1800,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2018_02_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -1904,7 +1812,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2018_02_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -1918,7 +1826,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_02_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_02_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1929,51 +1837,51 @@ class StorageAccount(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, } def __init__( @@ -1982,14 +1890,14 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, identity: Optional["_models.Identity"] = None, - enable_https_traffic_only: Optional[bool] = False, - is_hns_enabled: Optional[bool] = False, + enable_https_traffic_only: bool = False, + is_hns_enabled: bool = False, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_02_01.models.Identity @@ -1999,7 +1907,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -2020,65 +1928,60 @@ def __init__( self.is_hns_enabled = is_hns_enabled -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the sku name. + :ivar sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2018_02_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_02_01.models.Identity @@ -2092,7 +1995,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2018_02_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_02_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -2101,23 +2004,23 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, } _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, } def __init__( @@ -2132,25 +2035,25 @@ def __init__( encryption: Optional["_models.Encryption"] = None, network_rule_set: Optional["_models.NetworkRuleSet"] = None, access_tier: Optional[Union[str, "_models.AccessTier"]] = None, - enable_https_traffic_only: Optional[bool] = False, - is_hns_enabled: Optional[bool] = False, + enable_https_traffic_only: bool = False, + is_hns_enabled: bool = False, **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the sku name. + :keyword sku: Required. Gets or sets the sku name. Required. :paramtype sku: ~azure.mgmt.storage.v2018_02_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", and "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_02_01.models.Identity @@ -2164,7 +2067,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_02_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_02_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -2172,7 +2075,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -2186,7 +2089,7 @@ def __init__( self.is_hns_enabled = is_hns_enabled -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2196,35 +2099,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2018_02_01.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2235,24 +2134,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2262,71 +2157,62 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, + "value": {"key": "value", "type": "[StorageAccount]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2018_02_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_02_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2336,7 +2222,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_02_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_02_01.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -2345,15 +2231,15 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, } def __init__( @@ -2366,7 +2252,7 @@ def __init__( custom_domain: Optional["_models.CustomDomain"] = None, encryption: Optional["_models.Encryption"] = None, access_tier: Optional[Union[str, "_models.AccessTier"]] = None, - enable_https_traffic_only: Optional[bool] = False, + enable_https_traffic_only: bool = False, network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): @@ -2374,15 +2260,15 @@ def __init__( :keyword sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2018_02_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_02_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", and "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_02_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2392,7 +2278,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2018_02_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_02_01.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -2400,7 +2286,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_02_01.models.NetworkRuleSet """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -2412,7 +2298,7 @@ def __init__( self.network_rule_set = network_rule_set -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2422,24 +2308,20 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Sku]'}, + "value": {"key": "value", "type": "[Sku]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2457,28 +2339,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -2486,13 +2364,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -2509,30 +2387,26 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -2541,13 +2415,13 @@ def __init__( self.upn = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2018_02_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -2558,33 +2432,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -2592,24 +2462,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2018_02_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -2621,72 +2486,68 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2018_02_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2018_02_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py index 1f0605f3daa0..452cfa40f4c5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,6 +25,7 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -36,27 +37,34 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + +class Enum12(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum12.""" + + DEFAULT = "default" + + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -66,38 +74,40 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" BLOB_STORAGE = "BlobStorage" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -107,9 +117,9 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -117,13 +127,14 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -138,22 +149,23 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -162,6 +174,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -172,6 +185,7 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -182,6 +196,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -192,6 +207,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -202,6 +218,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. @@ -213,16 +230,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the sku tier. This is based on the SKU name. - """ + """Gets the sku tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "provisioning" DEPROVISIONING = "deprovisioning" @@ -230,9 +247,9 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/__init__.py index 09b0517d9606..09e3ff5ad13c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/__init__.py @@ -15,12 +15,13 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsageOperations', - 'BlobContainersOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsageOperations", + "BlobContainersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_operations.py index 4be56a391c64..331da92e22d7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_blob_containers_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,365 +25,313 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum12], subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum12], subscription_id: str, *, if_match: Optional[str] = None, @@ -386,43 +340,42 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum12], subscription_id: str, *, if_match: str, @@ -431,36 +384,34 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -475,34 +426,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -512,93 +462,79 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class BlobContainersOperations: """ @@ -619,47 +555,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListContainerItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContainerItems, or the result of cls(response) + :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListContainerItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -667,33 +599,33 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListContainerItems', pipeline_response) + deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -701,37 +633,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -741,7 +760,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -749,70 +769,155 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -822,7 +927,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -830,72 +936,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -903,72 +1005,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -976,10 +1074,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -989,16 +1086,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1006,37 +1104,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1046,7 +1231,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1054,70 +1240,155 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_02_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -1127,7 +1398,8 @@ def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1135,51 +1407,55 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum12], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_02_01.models.Enum12 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -1187,44 +1463,144 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum12], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_02_01.models.Enum12 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum12], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_02_01.models.Enum12 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1232,10 +1608,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1243,17 +1618,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1261,6 +1635,7 @@ def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum12], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1268,52 +1643,52 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_02_01.models.Enum12 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1321,10 +1696,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1332,17 +1706,16 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( @@ -1350,6 +1723,7 @@ def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum12], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1359,52 +1733,52 @@ def delete_immutability_policy( container after deleting all blobs inside the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_02_01.models.Enum12 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1412,10 +1786,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1423,71 +1796,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1495,10 +1864,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1506,19 +1874,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1526,6 +1893,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1533,56 +1902,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1590,10 +2058,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1601,65 +2068,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1669,7 +2222,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1677,22 +2231,20 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_operations.py index 11955c7fb070..a8895563042d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_operations.py index 9244853ac254..e7134eae68d9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_operations.py index 1f8bb1f6f859..85381d3b6f59 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,449 +29,375 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class StorageAccountsOperations: """ @@ -485,45 +418,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2018_02_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -531,55 +517,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -587,10 +581,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -599,22 +592,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -623,14 +617,58 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 @@ -642,20 +680,57 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -663,79 +738,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -743,10 +813,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -756,50 +825,46 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.StorageAccount: + def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -807,32 +872,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -845,32 +910,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -879,7 +1029,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -887,58 +1038,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -946,13 +1094,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -969,10 +1121,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -982,49 +1132,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1032,14 +1178,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1056,10 +1205,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1069,51 +1216,48 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1121,64 +1265,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2018_02_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1187,7 +1405,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1195,63 +1414,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1260,7 +1552,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1268,63 +1561,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_02_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_02_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1333,7 +1697,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1341,22 +1706,20 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_operations.py index ea7384612a04..0b476c6ac1cf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_02_01/operations/_usage_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,79 +27,70 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsageOperations: """ @@ -113,36 +111,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -150,13 +148,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -173,10 +175,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -186,46 +186,44 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_02_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-02-01")) # type: Literal["2018-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -233,14 +231,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -257,10 +258,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -270,8 +269,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_configuration.py index e29149119f30..1a2c48ed3591 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-03-01-preview". 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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + api_version = kwargs.pop("api_version", "2018-03-01-preview") # type: Literal["2018-03-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json index 345767c11ce0..647eb88c4158 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -103,4 +103,4 @@ "usages": "UsagesOperations", "blob_containers": "BlobContainersOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py index 8c60ecab1678..c60dd4dc33d1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_storage_management_client.py @@ -9,20 +9,26 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, Operations, SkusOperations, StorageAccountsOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + Operations, + SkusOperations, + StorageAccountsOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar operations: Operations operations @@ -37,9 +43,9 @@ class StorageManagementClient: :ivar blob_containers: BlobContainersOperations operations :vartype blob_containers: azure.mgmt.storage.v2018_03_01_preview.operations.BlobContainersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,35 +63,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -94,7 +89,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_configuration.py index 5844901bbbb9..d5888d2b7382 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-03-01-preview". 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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-03-01-preview") # type: str + api_version = kwargs.pop("api_version", "2018-03-01-preview") # type: Literal["2018-03-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py index 597da0bd98cf..2504bf3d621e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/_storage_management_client.py @@ -9,20 +9,26 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, Operations, SkusOperations, StorageAccountsOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + Operations, + SkusOperations, + StorageAccountsOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword """The Azure Storage Management API. :ivar operations: Operations operations @@ -37,9 +43,9 @@ class StorageManagementClient: :ivar blob_containers: BlobContainersOperations operations :vartype blob_containers: azure.mgmt.storage.v2018_03_01_preview.aio.operations.BlobContainersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,35 +63,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -94,7 +89,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/__init__.py index 1582bc5faffe..0aa226eb2f61 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/__init__.py @@ -15,12 +15,13 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsagesOperations', - 'BlobContainersOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsagesOperations", + "BlobContainersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_operations.py index fe00ccde9cc4..45bcaae47fc8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_blob_containers_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -41,47 +69,45 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListContainerItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContainerItems, or the result of cls(response) + :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListContainerItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -89,33 +115,33 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListContainerItems', pipeline_response) + deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -123,37 +149,126 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] - - _json = self._serialize.body(blob_container, 'BlobContainer') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -163,7 +278,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -171,70 +287,157 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] - - _json = self._serialize.body(blob_container, 'BlobContainer') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -244,7 +447,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -252,72 +456,70 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -325,72 +527,70 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -398,10 +598,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -411,16 +610,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -428,37 +628,126 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - - _json = self._serialize.body(legal_hold, 'LegalHold') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -468,7 +757,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -476,70 +766,157 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - - _json = self._serialize.body(legal_hold, 'LegalHold') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -549,7 +926,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -557,51 +935,55 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum13], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Enum13 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -609,44 +991,146 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum13], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Enum13 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum13], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Enum13 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] - - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -654,10 +1138,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -665,17 +1148,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -683,6 +1165,7 @@ async def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum13], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -690,52 +1173,54 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Enum13 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -743,10 +1228,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -754,17 +1238,16 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -772,6 +1255,7 @@ async def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum13], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -781,52 +1265,54 @@ async def delete_immutability_policy( container after deleting all blobs inside the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Enum13 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -834,10 +1320,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -845,71 +1330,69 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -917,10 +1400,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -928,19 +1410,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -948,6 +1429,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -955,56 +1438,157 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] - - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1012,10 +1596,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1023,65 +1606,153 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] - - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1091,7 +1762,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1099,22 +1771,20 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_operations.py index 0e884daa8e95..723730675b23 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,38 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +96,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +134,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_operations.py index fde73fd4d189..caa19ccaf975 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,39 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) + :return: An iterator like instance of either Sku or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +97,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +124,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +135,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_operations.py index d1d235cb5328..9b7928d8703d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,31 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_or_update_management_policies_request, build_create_request_initial, build_delete_management_policies_request, build_delete_request, build_get_management_policies_request, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_or_update_management_policies_request, + build_create_request, + build_delete_management_policies_request, + build_delete_request, + build_get_management_policies_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +75,101 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCheckNameAvailabilityParameters 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 - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +177,65 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] - - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') - - request = build_create_request_initial( + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +243,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +254,105 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +361,19 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCreateParameters + 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 @@ -203,20 +386,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +406,76 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +483,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,50 +495,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,32 +546,104 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountUpdateParameters, + parameters: Union[_models.StorageAccountUpdateParameters, IO], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -406,32 +656,48 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountUpdateParameters + 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -440,7 +706,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -448,58 +715,58 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -507,13 +774,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -530,10 +801,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -543,49 +812,50 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -593,14 +863,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -617,10 +890,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -630,51 +901,50 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -682,64 +952,140 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -748,7 +1094,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -756,63 +1103,138 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -821,7 +1243,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -829,63 +1252,136 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ServiceSasParameters + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -894,7 +1390,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -902,71 +1399,73 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore @distributed_trace_async async def get_management_policies( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Gets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountManagementPolicies, or the result of cls(response) + :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountManagementPolicies] - request = build_get_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_management_policies.metadata['url'], + template_url=self.get_management_policies.metadata["url"], headers=_headers, params=_params, ) @@ -974,79 +1473,164 @@ async def get_management_policies( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountManagementPolicies', pipeline_response) + deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get_management_policies.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_management_policies( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPoliciesRulesSetParameter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName - :param properties: The data policy rules to set to a storage account. + :param properties: The data policy rules to set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter + :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: StorageAccountManagementPolicies, or the result of cls(response) + :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_management_policies( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountManagementPolicies: + """Sets the data policy rules associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName + :param properties: The data policy rules to set to a storage account. Required. + :type properties: IO + :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: StorageAccountManagementPolicies or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_management_policies( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPoliciesRulesSetParameter, IO], + **kwargs: Any + ) -> _models.StorageAccountManagementPolicies: + """Sets the data policy rules associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName + :param properties: The data policy rules to set to a storage account. Is either a model type or + a IO type. Required. + :type properties: + ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter 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 + :return: StorageAccountManagementPolicies or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountManagementPolicies] - _json = self._serialize.body(properties, 'ManagementPoliciesRulesSetParameter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPoliciesRulesSetParameter") request = build_create_or_update_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_management_policies.metadata['url'], + content=_content, + template_url=self.create_or_update_management_policies.metadata["url"], headers=_headers, params=_params, ) @@ -1054,71 +1638,73 @@ async def create_or_update_management_policies( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountManagementPolicies', pipeline_response) + deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update_management_policies.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete_management_policies( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_management_policies.metadata['url'], + template_url=self.delete_management_policies.metadata["url"], headers=_headers, params=_params, ) @@ -1126,10 +1712,9 @@ async def delete_management_policies( # pylint: disable=inconsistent-return-sta request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1139,5 +1724,4 @@ async def delete_management_policies( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - delete_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete_management_policies.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_operations.py index 2c1a5b114ea1..8059a658836b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,37 +57,39 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) + :return: An iterator like instance of either Usage or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -80,13 +97,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -103,10 +124,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -116,47 +135,47 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) + :return: An iterator like instance of either Usage or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -164,14 +183,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -188,10 +210,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -201,8 +221,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py index dadf5bc3167b..7c1a2fefb905 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/__init__.py @@ -61,121 +61,121 @@ from ._models_py3 import UsageName from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountStatus, - Bypass, - DefaultAction, - HttpProtocol, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - KeyPermission, - KeySource, - Kind, - LeaseContainerRequestAction, - LeaseDuration, - LeaseState, - LeaseStatus, - ManagementPolicyName, - Permissions, - ProvisioningState, - PublicAccess, - Reason, - ReasonCode, - Services, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import Enum13 +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'AzureEntityResource', - 'BlobContainer', - 'CheckNameAvailabilityResult', - 'CustomDomain', - 'Dimension', - 'Encryption', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'KeyVaultProperties', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListContainerItem', - 'ListContainerItems', - 'ListServiceSasResponse', - 'ManagementPoliciesRules', - 'ManagementPoliciesRulesSetParameter', - 'MetricSpecification', - 'NetworkRuleSet', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Resource', - 'Restriction', - 'SKUCapability', - 'ServiceSasParameters', - 'ServiceSpecification', - 'Sku', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountManagementPolicies', - 'StorageAccountManagementPoliciesRulesProperty', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageSkuListResult', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'Bypass', - 'DefaultAction', - 'HttpProtocol', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'KeyPermission', - 'KeySource', - 'Kind', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseState', - 'LeaseStatus', - 'ManagementPolicyName', - 'Permissions', - 'ProvisioningState', - 'PublicAccess', - 'Reason', - 'ReasonCode', - 'Services', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'UsageUnit', + "AccountSasParameters", + "AzureEntityResource", + "BlobContainer", + "CheckNameAvailabilityResult", + "CustomDomain", + "Dimension", + "Encryption", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "KeyVaultProperties", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListContainerItem", + "ListContainerItems", + "ListServiceSasResponse", + "ManagementPoliciesRules", + "ManagementPoliciesRulesSetParameter", + "MetricSpecification", + "NetworkRuleSet", + "Operation", + "OperationDisplay", + "OperationListResult", + "Resource", + "Restriction", + "SKUCapability", + "ServiceSasParameters", + "ServiceSpecification", + "Sku", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountManagementPolicies", + "StorageAccountManagementPoliciesRulesProperty", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageSkuListResult", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "Bypass", + "DefaultAction", + "Enum13", + "HttpProtocol", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "KeyPermission", + "KeySource", + "Kind", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseState", + "LeaseStatus", + "ManagementPolicyName", + "Permissions", + "ProvisioningState", + "PublicAccess", + "Reason", + "ReasonCode", + "Services", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py index be44fce7600d..3c41c662451c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,64 +8,75 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization + +if sys.version_info >= (3, 9): + 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 - import __init__ as _models + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_03_01_preview.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -81,34 +93,35 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_03_01_preview.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -119,7 +132,7 @@ def __init__( self.key_to_sign = key_to_sign -class Resource(msrest.serialization.Model): +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. @@ -135,24 +148,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -176,30 +185,26 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -215,17 +220,18 @@ class BlobContainer(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_03_01_preview.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -246,35 +252,35 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -286,12 +292,12 @@ def __init__( ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_03_01_preview.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_access = public_access self.last_modified_time = None self.lease_status = None @@ -304,7 +310,7 @@ def __init__( self.has_immutability_policy = None -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -314,7 +320,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -322,36 +328,32 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -359,35 +361,29 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -397,38 +393,32 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_03_01_preview.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2018_03_01_preview.models.KeySource :ivar key_vault_properties: Properties provided by key vault. :vartype key_vault_properties: @@ -436,13 +426,13 @@ class Encryption(msrest.serialization.Model): """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, } def __init__( @@ -456,21 +446,21 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2018_03_01_preview.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2018_03_01_preview.models.KeySource :keyword key_vault_properties: Properties provided by key vault. :paramtype key_vault_properties: ~azure.mgmt.storage.v2018_03_01_preview.models.KeyVaultProperties """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.key_vault_properties = key_vault_properties -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -485,31 +475,26 @@ class EncryptionService(msrest.serialization.Model): """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is stored. :paramtype enabled: bool """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. Variables are only populated by the server, and will be ignored when sending a request. @@ -525,15 +510,15 @@ class EncryptionServices(msrest.serialization.Model): """ _validation = { - 'table': {'readonly': True}, - 'queue': {'readonly': True}, + "table": {"readonly": True}, + "queue": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -549,14 +534,14 @@ def __init__( :keyword file: The encryption function of the file storage service. :paramtype file: ~azure.mgmt.storage.v2018_03_01_preview.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = None self.queue = None -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -576,30 +561,26 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Endpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -608,7 +589,7 @@ def __init__( self.dfs = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -619,31 +600,27 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Has constant value: "SystemAssigned". + :ivar type: The identity type. Required. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True, 'constant': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "SystemAssigned" - def __init__( - self, - **kwargs - ): - """ - """ - super(Identity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -665,49 +642,47 @@ class ImmutabilityPolicy(AzureEntityResource): :vartype type: str :ivar etag: Resource Etag. :vartype etag: str - :ivar immutability_period_since_creation_in_days: Required. The immutability period for the - blobs in the container since the policy creation, in days. + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. Required. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicyState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'required': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "immutability_period_since_creation_in_days": {"required": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, } - def __init__( - self, - *, - immutability_period_since_creation_in_days: int, - **kwargs - ): + def __init__(self, *, immutability_period_since_creation_in_days: int, **kwargs): """ - :keyword immutability_period_since_creation_in_days: Required. The immutability period for the - blobs in the container since the policy creation, in days. + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. Required. :paramtype immutability_period_since_creation_in_days: int """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -721,84 +696,74 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicyState """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, } - def __init__( - self, - *, - immutability_period_since_creation_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, immutability_period_since_creation_in_days: Optional[int] = None, **kwargs): """ :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. :paramtype immutability_period_since_creation_in_days: int """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. :ivar key_name: The name of KeyVault key. @@ -810,9 +775,9 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, } def __init__( @@ -831,19 +796,19 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -860,15 +825,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -882,8 +847,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -898,7 +863,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -906,7 +871,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -917,17 +882,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -935,12 +894,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -952,38 +911,33 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, } - def __init__( - self, - *, - tags: List[str], - **kwargs - ): + def __init__(self, *, tags: List[str], **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -993,35 +947,30 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2018_03_01_preview.models.TagProperty] """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, } - def __init__( - self, - *, - tags: Optional[List["_models.TagProperty"]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[List["_models.TagProperty"]] = None, **kwargs): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2018_03_01_preview.models.TagProperty] """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1031,24 +980,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -1064,17 +1009,18 @@ class ListContainerItem(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_03_01_preview.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -1095,35 +1041,35 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -1135,12 +1081,12 @@ def __init__( ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_03_01_preview.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_access = public_access self.last_modified_time = None self.lease_status = None @@ -1153,7 +1099,7 @@ def __init__( self.has_immutability_policy = None -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """The list of blob containers. :ivar value: The list of blob containers. @@ -1161,24 +1107,19 @@ class ListContainerItems(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ListContainerItem"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ListContainerItem"]] = None, **kwargs): """ :keyword value: The list of blob containers. :paramtype value: list[~azure.mgmt.storage.v2018_03_01_preview.models.ListContainerItem] """ - super(ListContainerItems, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1188,78 +1129,64 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class ManagementPoliciesRules(msrest.serialization.Model): +class ManagementPoliciesRules(_serialization.Model): """The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :ivar policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :vartype policy: any + :vartype policy: JSON """ _attribute_map = { - 'policy': {'key': 'policy', 'type': 'object'}, + "policy": {"key": "policy", "type": "object"}, } - def __init__( - self, - *, - policy: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy: Optional[JSON] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :paramtype policy: any + :paramtype policy: JSON """ - super(ManagementPoliciesRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy = policy -class ManagementPoliciesRulesSetParameter(msrest.serialization.Model): +class ManagementPoliciesRulesSetParameter(_serialization.Model): """The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :ivar policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :vartype policy: any + :vartype policy: JSON """ _attribute_map = { - 'policy': {'key': 'properties.policy', 'type': 'object'}, + "policy": {"key": "properties.policy", "type": "object"}, } - def __init__( - self, - *, - policy: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy: Optional[JSON] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :paramtype policy: any + :paramtype policy: JSON """ - super(ManagementPoliciesRulesSetParameter, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy = policy -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -1283,15 +1210,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -1328,7 +1255,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1340,42 +1267,42 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2018_03_01_preview.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2018_03_01_preview.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs @@ -1384,25 +1311,25 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: list[~azure.mgmt.storage.v2018_03_01_preview.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2018_03_01_preview.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2018_03_01_preview.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules self.default_action = default_action -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1417,10 +1344,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -1443,14 +1370,14 @@ def __init__( :paramtype service_specification: ~azure.mgmt.storage.v2018_03_01_preview.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -1464,10 +1391,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1489,14 +1416,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -1504,24 +1431,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2018_03_01_preview.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -1534,59 +1456,54 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_03_01_preview.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -1618,29 +1535,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, } _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -1667,20 +1584,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_03_01_preview.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -1711,7 +1629,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -1732,7 +1650,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -1741,42 +1659,37 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2018_03_01_preview.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :ivar name: Gets or sets the sku name. Required for account creation; optional for update. Note + that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :vartype name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SkuName - :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: Gets the sku tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage". + and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -1790,22 +1703,22 @@ class Sku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -1816,15 +1729,15 @@ def __init__( **kwargs ): """ - :keyword name: Required. Gets or sets the sku name. Required for account creation; optional for - update. Note that in older versions, sku name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS". + :keyword name: Gets or sets the sku name. Required for account creation; optional for update. + Note that in older versions, sku name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", and "Premium_LRS". :paramtype name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2018_03_01_preview.models.Restriction] """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -1834,7 +1747,7 @@ def __init__( self.restrictions = restrictions -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified sku, including file encryption, network acls, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -1847,22 +1760,18 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None @@ -1882,46 +1791,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -1936,18 +1839,18 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2018_03_01_preview.models.Sku - :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage". + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_03_01_preview.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, @@ -1957,7 +1860,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -1969,7 +1872,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. @@ -1984,7 +1887,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_03_01_preview.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -1995,51 +1898,51 @@ class StorageAccount(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, } def __init__( @@ -2048,14 +1951,14 @@ def __init__( location: str, tags: Optional[Dict[str, str]] = None, identity: Optional["_models.Identity"] = None, - enable_https_traffic_only: Optional[bool] = False, - is_hns_enabled: Optional[bool] = False, + enable_https_traffic_only: bool = False, + is_hns_enabled: bool = False, **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_03_01_preview.models.Identity @@ -2065,7 +1968,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -2086,65 +1989,60 @@ def __init__( self.is_hns_enabled = is_hns_enabled -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the sku name. + :ivar sku: Required. Gets or sets the sku name. Required. :vartype sku: ~azure.mgmt.storage.v2018_03_01_preview.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_03_01_preview.models.Identity @@ -2158,7 +2056,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2018_03_01_preview.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -2167,23 +2065,23 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, } _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, } def __init__( @@ -2198,25 +2096,25 @@ def __init__( encryption: Optional["_models.Encryption"] = None, network_rule_set: Optional["_models.NetworkRuleSet"] = None, access_tier: Optional[Union[str, "_models.AccessTier"]] = None, - enable_https_traffic_only: Optional[bool] = False, - is_hns_enabled: Optional[bool] = False, + enable_https_traffic_only: bool = False, + is_hns_enabled: bool = False, **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the sku name. + :keyword sku: Required. Gets or sets the sku name. Required. :paramtype sku: ~azure.mgmt.storage.v2018_03_01_preview.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", and "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_03_01_preview.models.Identity @@ -2230,7 +2128,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_03_01_preview.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -2238,7 +2136,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -2252,7 +2150,7 @@ def __init__( self.is_hns_enabled = is_hns_enabled -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2262,35 +2160,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2018_03_01_preview.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2301,24 +2195,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2328,20 +2218,16 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, + "value": {"key": "value", "type": "[StorageAccount]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -2360,38 +2246,33 @@ class StorageAccountManagementPolicies(Resource): :vartype type: str :ivar policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :vartype policy: any + :vartype policy: JSON :ivar last_modified_time: Returns the date and time the ManagementPolicies was last modified. :vartype last_modified_time: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy': {'key': 'properties.policy', 'type': 'object'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy": {"key": "properties.policy", "type": "object"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, } - def __init__( - self, - *, - policy: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy: Optional[JSON] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :paramtype policy: any + :paramtype policy: JSON """ - super(StorageAccountManagementPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy = policy self.last_modified_time = None @@ -2403,83 +2284,73 @@ class StorageAccountManagementPoliciesRulesProperty(ManagementPoliciesRules): :ivar policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :vartype policy: any + :vartype policy: JSON :ivar last_modified_time: Returns the date and time the ManagementPolicies was last modified. :vartype last_modified_time: ~datetime.datetime """ _validation = { - 'last_modified_time': {'readonly': True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'policy': {'key': 'policy', 'type': 'object'}, - 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, + "policy": {"key": "policy", "type": "object"}, + "last_modified_time": {"key": "lastModifiedTime", "type": "iso-8601"}, } - def __init__( - self, - *, - policy: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy: Optional[JSON] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :paramtype policy: any + :paramtype policy: JSON """ - super(StorageAccountManagementPoliciesRulesProperty, self).__init__(policy=policy, **kwargs) + super().__init__(policy=policy, **kwargs) self.last_modified_time = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2018_03_01_preview.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_03_01_preview.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", and "BlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2489,7 +2360,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_03_01_preview.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccessTier :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. :vartype enable_https_traffic_only: bool @@ -2498,15 +2369,15 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, } def __init__( @@ -2519,7 +2390,7 @@ def __init__( custom_domain: Optional["_models.CustomDomain"] = None, encryption: Optional["_models.Encryption"] = None, access_tier: Optional[Union[str, "_models.AccessTier"]] = None, - enable_https_traffic_only: Optional[bool] = False, + enable_https_traffic_only: bool = False, network_rule_set: Optional["_models.NetworkRuleSet"] = None, **kwargs ): @@ -2527,15 +2398,15 @@ def __init__( :keyword sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS or Premium_LRS, nor can accounts of those sku names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2018_03_01_preview.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_03_01_preview.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value - supported by server. Known values are: "Storage", "StorageV2", "BlobStorage". + supported by server. Known values are: "Storage", "StorageV2", and "BlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2545,7 +2416,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2018_03_01_preview.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_03_01_preview.models.AccessTier :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to true. @@ -2553,7 +2424,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_03_01_preview.models.NetworkRuleSet """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -2565,7 +2436,7 @@ def __init__( self.network_rule_set = network_rule_set -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2575,24 +2446,20 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Sku]'}, + "value": {"key": "value", "type": "[Sku]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2610,28 +2477,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -2639,13 +2502,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the @@ -2663,30 +2526,26 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -2695,13 +2554,13 @@ def __init__( self.upn = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2018_03_01_preview.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -2712,33 +2571,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -2746,24 +2601,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2018_03_01_preview.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -2775,72 +2625,68 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2018_03_01_preview.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py index 49d670df3480..0c6ca9b78d3b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,6 +25,7 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -36,27 +37,34 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + +class Enum13(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum13.""" + + DEFAULT = "default" + + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -66,38 +74,40 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" BLOB_STORAGE = "BlobStorage" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -107,9 +117,9 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -117,17 +127,20 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -142,22 +155,23 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -166,6 +180,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -176,6 +191,7 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -186,6 +202,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -196,6 +213,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -206,6 +224,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the sku name. Required for account creation; optional for update. Note that in older versions, sku name was called accountType. @@ -217,16 +236,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_ZRS = "Standard_ZRS" PREMIUM_LRS = "Premium_LRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the sku tier. This is based on the SKU name. - """ + """Gets the sku tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "provisioning" DEPROVISIONING = "deprovisioning" @@ -234,9 +253,9 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/__init__.py index 1582bc5faffe..0aa226eb2f61 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/__init__.py @@ -15,12 +15,13 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsagesOperations', - 'BlobContainersOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsagesOperations", + "BlobContainersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_operations.py index c0b47a549ee9..4887e7617c61 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_blob_containers_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,365 +25,329 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum13], subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum13], subscription_id: str, *, if_match: Optional[str] = None, @@ -386,43 +356,44 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum13], subscription_id: str, *, if_match: str, @@ -431,36 +402,36 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -475,34 +446,35 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -512,93 +484,83 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class BlobContainersOperations: """ @@ -619,47 +581,45 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListContainerItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContainerItems, or the result of cls(response) + :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListContainerItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -667,33 +627,33 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListContainerItems', pipeline_response) + deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -701,37 +661,126 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] - - _json = self._serialize.body(blob_container, 'BlobContainer') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -741,7 +790,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -749,70 +799,157 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] - - _json = self._serialize.body(blob_container, 'BlobContainer') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -822,7 +959,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -830,72 +968,70 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -903,72 +1039,70 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -976,10 +1110,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -989,16 +1122,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1006,37 +1140,126 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - - _json = self._serialize.body(legal_hold, 'LegalHold') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1046,7 +1269,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1054,70 +1278,157 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - - _json = self._serialize.body(legal_hold, 'LegalHold') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -1127,7 +1438,8 @@ def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1135,51 +1447,55 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum13], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Enum13 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -1187,44 +1503,146 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum13], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Enum13 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum13], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Enum13 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] - - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1232,10 +1650,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1243,17 +1660,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1261,6 +1677,7 @@ def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum13], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1268,52 +1685,54 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Enum13 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1321,10 +1740,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1332,17 +1750,16 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( @@ -1350,6 +1767,7 @@ def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum13], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1359,52 +1777,54 @@ def delete_immutability_policy( container after deleting all blobs inside the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.Enum13 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1412,10 +1832,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1423,71 +1842,69 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1495,10 +1912,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1506,19 +1922,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1526,6 +1941,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1533,56 +1950,157 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] - - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1590,10 +2108,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1601,65 +2118,153 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequest + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] - - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1669,7 +2274,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1677,22 +2283,20 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_operations.py index 2a815c15da8c..d6174f188a75 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,40 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +81,37 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +119,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +146,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +157,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_operations.py index cf7ceb4cfe41..0dee215f7409 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,45 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +86,38 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +125,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +152,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +163,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_operations.py index dd23bb54a4a9..d84ef371c52f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,567 +29,514 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_get_management_policies_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_management_policies_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPoliciesRulesSetParameter] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_management_policies_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: """ @@ -603,45 +557,101 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -649,55 +659,65 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] - - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') - - request = build_create_request_initial( + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -705,10 +725,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -717,22 +736,105 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -741,14 +843,19 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountCreateParameters + 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 @@ -761,20 +868,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -782,79 +888,76 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -862,10 +965,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -875,50 +977,48 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def get_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.StorageAccount: + def get_properties(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU name, location, and account status. The ListKeys operation should be used to retrieve storage keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_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_properties.metadata['url'], + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -926,32 +1026,104 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountUpdateParameters, + parameters: Union[_models.StorageAccountUpdateParameters, IO], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -964,32 +1136,48 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountUpdateParameters + 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -998,7 +1186,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1006,58 +1195,58 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1065,13 +1254,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1088,10 +1281,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1101,49 +1292,48 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1151,14 +1341,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1175,10 +1368,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1188,51 +1379,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1240,64 +1430,140 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1306,7 +1572,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1314,63 +1581,138 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.AccountSasParameters 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 - :return: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1379,7 +1721,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1387,63 +1730,136 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ServiceSasParameters + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_03_01_preview.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1452,7 +1868,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1460,71 +1877,73 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore @distributed_trace def get_management_policies( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Gets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountManagementPolicies, or the result of cls(response) + :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountManagementPolicies] - request = build_get_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get_management_policies.metadata['url'], + template_url=self.get_management_policies.metadata["url"], headers=_headers, params=_params, ) @@ -1532,79 +1951,164 @@ def get_management_policies( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountManagementPolicies', pipeline_response) + deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get_management_policies.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update_management_policies( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPoliciesRulesSetParameter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName - :param properties: The data policy rules to set to a storage account. + :param properties: The data policy rules to set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter + :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: StorageAccountManagementPolicies or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_management_policies( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountManagementPolicies: + """Sets the data policy rules associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName + :param properties: The data policy rules to set to a storage account. Required. + :type properties: IO + :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: StorageAccountManagementPolicies, or the result of cls(response) + :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_management_policies( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPoliciesRulesSetParameter, IO], + **kwargs: Any + ) -> _models.StorageAccountManagementPolicies: + """Sets the data policy rules associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName + :param properties: The data policy rules to set to a storage account. Is either a model type or + a IO type. Required. + :type properties: + ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPoliciesRulesSetParameter 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 + :return: StorageAccountManagementPolicies or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_03_01_preview.models.StorageAccountManagementPolicies + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountManagementPolicies] - _json = self._serialize.body(properties, 'ManagementPoliciesRulesSetParameter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPoliciesRulesSetParameter") request = build_create_or_update_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update_management_policies.metadata['url'], + content=_content, + template_url=self.create_or_update_management_policies.metadata["url"], headers=_headers, params=_params, ) @@ -1612,71 +2116,73 @@ def create_or_update_management_policies( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountManagementPolicies', pipeline_response) + deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update_management_policies.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete_management_policies( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_03_01_preview.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_management_policies_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete_management_policies.metadata['url'], + template_url=self.delete_management_policies.metadata["url"], headers=_headers, params=_params, ) @@ -1684,10 +2190,9 @@ def delete_management_policies( # pylint: disable=inconsistent-return-statement request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1697,5 +2202,4 @@ def delete_management_policies( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - delete_management_policies.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete_management_policies.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_operations.py index e65dc0e15e85..6c851c29a921 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_03_01_preview/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,79 +27,74 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -113,37 +115,38 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -151,13 +154,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -174,10 +181,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -187,47 +192,46 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/usages"} # type: ignore @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_03_01_preview.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -235,14 +239,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -259,10 +266,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -272,8 +277,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_configuration.py index 32d3d6129224..14ccc6699679 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_configuration.py @@ -25,18 +25,13 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "TokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,23 +40,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json index 050d16caa43a..ee9d7d22aa35 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -105,4 +105,4 @@ "blob_containers": "BlobContainersOperations", "management_policies": "ManagementPoliciesOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py index 4596edc047a1..36908053d20a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_storage_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobServicesOperations, ManagementPoliciesOperations, Operations, SkusOperations, StorageAccountsOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobServicesOperations, + ManagementPoliciesOperations, + Operations, + SkusOperations, + StorageAccountsOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -40,9 +48,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :ivar management_policies: ManagementPoliciesOperations operations :vartype management_policies: azure.mgmt.storage.v2018_07_01.operations.ManagementPoliciesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -57,41 +65,28 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -100,7 +95,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_configuration.py index caa20f12ad8e..7029724a98ac 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_configuration.py @@ -25,18 +25,13 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str """ - def __init__( - self, - credential: "AsyncTokenCredential", - subscription_id: str, - **kwargs: Any - ) -> None: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -45,22 +40,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py index aeacc8c964fd..45b1e4dc07f2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/_storage_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobServicesOperations, ManagementPoliciesOperations, Operations, SkusOperations, StorageAccountsOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobServicesOperations, + ManagementPoliciesOperations, + Operations, + SkusOperations, + StorageAccountsOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -42,9 +50,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :ivar management_policies: ManagementPoliciesOperations operations :vartype management_policies: azure.mgmt.storage.v2018_07_01.aio.operations.ManagementPoliciesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -59,41 +67,28 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -102,7 +97,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/__init__.py index fd06c8765f84..ed1b0e250a6b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/__init__.py @@ -17,14 +17,15 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsagesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'ManagementPoliciesOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsagesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "ManagementPoliciesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_operations.py index 1c63992c5a3a..9a9a1973e15c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_containers_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -41,50 +69,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListContainerItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContainerItems, or the result of cls(response) + :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListContainerItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,33 +113,33 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListContainerItems', pipeline_response) + deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -126,40 +147,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -169,7 +274,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -177,73 +283,155 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -253,7 +441,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -261,75 +450,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -337,75 +519,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -413,10 +588,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -426,16 +600,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -443,40 +618,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -486,7 +745,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -494,73 +754,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -570,7 +912,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -578,51 +921,55 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum8], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -630,47 +977,144 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum8], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum8], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -678,10 +1122,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -689,17 +1132,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -707,6 +1149,7 @@ async def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum8], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -714,55 +1157,52 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -770,10 +1210,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -781,17 +1220,16 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -799,6 +1237,7 @@ async def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum8], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -808,55 +1247,52 @@ async def delete_immutability_policy( container after deleting all blobs inside the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -864,10 +1300,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -875,74 +1310,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -950,10 +1378,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -961,19 +1388,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -981,6 +1407,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -988,59 +1416,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1048,10 +1572,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1059,68 +1582,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequest - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1130,7 +1736,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1138,22 +1745,20 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_operations.py index 737a7a5cd0d7..c3c2af4d4d33 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_blob_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -41,64 +58,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum8], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum8], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum8], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -106,75 +204,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum8], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -182,22 +272,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_management_policies_operations.py index dd2859ba24d6..3106f93d704c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,55 +59,55 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Gets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName - :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountManagementPolicies, or the result of cls(response) + :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountManagementPolicies] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -97,81 +115,163 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountManagementPolicies', pipeline_response) + deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPoliciesRulesSetParameter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName - :param properties: The data policy rules to set to a storage account. + :param properties: The data policy rules to set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2018_07_01.models.ManagementPoliciesRulesSetParameter - :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :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: StorageAccountManagementPolicies, or the result of cls(response) + :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountManagementPolicies: + """Sets the data policy rules associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName + :param properties: The data policy rules to set to a storage account. Required. + :type properties: IO + :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: StorageAccountManagementPolicies or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPoliciesRulesSetParameter, IO], + **kwargs: Any + ) -> _models.StorageAccountManagementPolicies: + """Sets the data policy rules associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName + :param properties: The data policy rules to set to a storage account. Is either a model type or + a IO type. Required. + :type properties: ~azure.mgmt.storage.v2018_07_01.models.ManagementPoliciesRulesSetParameter 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 + :return: StorageAccountManagementPolicies or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountManagementPolicies] - _json = self._serialize.body(properties, 'ManagementPoliciesRulesSetParameter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPoliciesRulesSetParameter") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -179,74 +279,73 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountManagementPolicies', pipeline_response) + deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName - :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -254,10 +353,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -267,5 +365,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_operations.py index ad1f75f2f960..74ebae4bd7cd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_operations.py @@ -6,10 +6,18 @@ # 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, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +28,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,39 +56,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -82,13 +93,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -104,10 +109,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +120,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_operations.py index 63d8c62e76a4..498959cb6f70 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_skus_operations.py @@ -6,10 +6,18 @@ # 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, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +28,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,41 +56,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -84,14 +93,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -107,10 +109,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -120,8 +120,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_operations.py index 23084450be25..0f07ee3fa93d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +30,29 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,48 +72,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCheckNameAvailabilityParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2018_07_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -94,55 +171,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -150,10 +235,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -162,22 +246,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -186,17 +271,100 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCreateParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCreateParameters 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 @@ -209,20 +377,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -230,82 +395,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -313,10 +470,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -326,15 +482,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[str] = "geoReplicationStats", + expand: Literal["geoReplicationStats"] = "geoReplicationStats", **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -342,43 +497,42 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". + Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -386,32 +540,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -424,35 +578,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountUpdateParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -461,7 +697,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -469,61 +706,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -531,14 +763,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -554,10 +779,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -567,52 +790,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -620,15 +839,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -644,10 +855,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -657,54 +866,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -712,67 +915,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountRegenerateKeyParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2018_07_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -781,7 +1055,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -789,66 +1064,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.AccountSasParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -857,7 +1202,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -865,66 +1211,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ServiceSasParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -933,7 +1347,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -941,50 +1356,47 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -992,10 +1404,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1005,30 +1416,21 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -1039,52 +1441,47 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_operations.py index 09be6a0be022..f392a471f162 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/aio/operations/_usages_operations.py @@ -6,10 +6,18 @@ # 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, Callable, Dict, Optional, TypeVar from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +28,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,45 +56,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_07_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -88,15 +97,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -112,10 +113,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -125,8 +124,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py index 05d8a2809ffe..08748380c29e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/__init__.py @@ -66,130 +66,130 @@ from ._models_py3 import UsageName from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountStatus, - Bypass, - CorsRuleAllowedMethodsItem, - DefaultAction, - GeoReplicationStatus, - HttpProtocol, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - KeyPermission, - KeySource, - Kind, - LeaseContainerRequestAction, - LeaseDuration, - LeaseState, - LeaseStatus, - ManagementPolicyName, - Permissions, - ProvisioningState, - PublicAccess, - Reason, - ReasonCode, - Services, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CorsRuleAllowedMethodsItem +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import Enum8 +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'AzureEntityResource', - 'BlobContainer', - 'BlobServiceProperties', - 'CheckNameAvailabilityResult', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DeleteRetentionPolicy', - 'Dimension', - 'Encryption', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'KeyVaultProperties', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListContainerItem', - 'ListContainerItems', - 'ListServiceSasResponse', - 'ManagementPoliciesRules', - 'ManagementPoliciesRulesSetParameter', - 'MetricSpecification', - 'NetworkRuleSet', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Resource', - 'Restriction', - 'SKUCapability', - 'ServiceSasParameters', - 'ServiceSpecification', - 'Sku', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountManagementPolicies', - 'StorageAccountManagementPoliciesRulesProperty', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageSkuListResult', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'Bypass', - 'CorsRuleAllowedMethodsItem', - 'DefaultAction', - 'GeoReplicationStatus', - 'HttpProtocol', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'KeyPermission', - 'KeySource', - 'Kind', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseState', - 'LeaseStatus', - 'ManagementPolicyName', - 'Permissions', - 'ProvisioningState', - 'PublicAccess', - 'Reason', - 'ReasonCode', - 'Services', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'UsageUnit', + "AccountSasParameters", + "AzureEntityResource", + "BlobContainer", + "BlobServiceProperties", + "CheckNameAvailabilityResult", + "CorsRule", + "CorsRules", + "CustomDomain", + "DeleteRetentionPolicy", + "Dimension", + "Encryption", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "KeyVaultProperties", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListContainerItem", + "ListContainerItems", + "ListServiceSasResponse", + "ManagementPoliciesRules", + "ManagementPoliciesRulesSetParameter", + "MetricSpecification", + "NetworkRuleSet", + "Operation", + "OperationDisplay", + "OperationListResult", + "Resource", + "Restriction", + "SKUCapability", + "ServiceSasParameters", + "ServiceSpecification", + "Sku", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountManagementPolicies", + "StorageAccountManagementPoliciesRulesProperty", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageSkuListResult", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "Bypass", + "CorsRuleAllowedMethodsItem", + "DefaultAction", + "Enum8", + "GeoReplicationStatus", + "HttpProtocol", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "KeyPermission", + "KeySource", + "Kind", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseState", + "LeaseStatus", + "ManagementPolicyName", + "Permissions", + "ProvisioningState", + "PublicAccess", + "Reason", + "ReasonCode", + "Services", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py index e9b8ee86582e..2c6bbd9a93ab 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,63 +8,74 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization + +if sys.version_info >= (3, 9): + 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 - import __init__ as _models + from .. import models as _models +JSON = MutableMapping[str, Any] # pylint: disable=unsubscriptable-object -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2018_07_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2018_07_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_07_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_07_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -80,33 +92,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2018_07_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2018_07_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_07_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_07_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -117,7 +130,7 @@ def __init__( self.key_to_sign = key_to_sign -class Resource(msrest.serialization.Model): +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. @@ -133,24 +146,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -174,30 +183,26 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -213,17 +218,18 @@ class BlobContainer(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_07_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -244,35 +250,35 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -284,12 +290,12 @@ def __init__( ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_07_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_access = public_access self.last_modified_time = None self.lease_status = None @@ -328,18 +334,18 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, } def __init__( @@ -363,13 +369,13 @@ def __init__( :paramtype delete_retention_policy: ~azure.mgmt.storage.v2018_07_01.models.DeleteRetentionPolicy """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors self.default_service_version = default_service_version self.delete_retention_policy = delete_retention_policy -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -379,7 +385,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2018_07_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -387,66 +393,62 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2018_07_01.models.CorsRuleAllowedMethodsItem] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -460,24 +462,24 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2018_07_01.models.CorsRuleAllowedMethodsItem] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -485,7 +487,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -494,31 +496,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2018_07_01.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -526,35 +523,29 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The blob service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled for the Blob service. @@ -565,21 +556,15 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled for the Blob service. :paramtype enabled: bool @@ -587,12 +572,12 @@ def __init__( minimum specified value can be 1 and the maximum value can be 365. :paramtype days: int """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -602,51 +587,45 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_07_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2018_07_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. :vartype key_vault_properties: ~azure.mgmt.storage.v2018_07_01.models.KeyVaultProperties """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, } def __init__( @@ -660,20 +639,20 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2018_07_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2018_07_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. :paramtype key_vault_properties: ~azure.mgmt.storage.v2018_07_01.models.KeyVaultProperties """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.key_vault_properties = key_vault_properties -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -688,31 +667,26 @@ class EncryptionService(msrest.serialization.Model): """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is stored. :paramtype enabled: bool """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. Variables are only populated by the server, and will be ignored when sending a request. @@ -728,15 +702,15 @@ class EncryptionServices(msrest.serialization.Model): """ _validation = { - 'table': {'readonly': True}, - 'queue': {'readonly': True}, + "table": {"readonly": True}, + "queue": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -752,14 +726,14 @@ def __init__( :keyword file: The encryption function of the file storage service. :paramtype file: ~azure.mgmt.storage.v2018_07_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = None self.queue = None -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -779,30 +753,26 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Endpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -811,7 +781,7 @@ def __init__( self.dfs = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -820,7 +790,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2018_07_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -833,30 +803,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -867,31 +833,27 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Has constant value: "SystemAssigned". + :ivar type: The identity type. Required. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True, 'constant': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "SystemAssigned" - def __init__( - self, - **kwargs - ): - """ - """ - super(Identity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -913,49 +875,47 @@ class ImmutabilityPolicy(AzureEntityResource): :vartype type: str :ivar etag: Resource Etag. :vartype etag: str - :ivar immutability_period_since_creation_in_days: Required. The immutability period for the - blobs in the container since the policy creation, in days. + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. Required. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicyState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'required': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "immutability_period_since_creation_in_days": {"required": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, } - def __init__( - self, - *, - immutability_period_since_creation_in_days: int, - **kwargs - ): + def __init__(self, *, immutability_period_since_creation_in_days: int, **kwargs): """ - :keyword immutability_period_since_creation_in_days: Required. The immutability period for the - blobs in the container since the policy creation, in days. + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. Required. :paramtype immutability_period_since_creation_in_days: int """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -968,84 +928,74 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicyState """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, } - def __init__( - self, - *, - immutability_period_since_creation_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, immutability_period_since_creation_in_days: Optional[int] = None, **kwargs): """ :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. :paramtype immutability_period_since_creation_in_days: int """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. :ivar key_name: The name of KeyVault key. @@ -1057,9 +1007,9 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, } def __init__( @@ -1078,19 +1028,19 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -1106,15 +1056,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -1128,8 +1078,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -1143,7 +1093,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -1151,7 +1101,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -1162,17 +1112,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -1180,12 +1124,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -1197,38 +1141,33 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, } - def __init__( - self, - *, - tags: List[str], - **kwargs - ): + def __init__(self, *, tags: List[str], **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -1238,35 +1177,30 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2018_07_01.models.TagProperty] """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, } - def __init__( - self, - *, - tags: Optional[List["_models.TagProperty"]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[List["_models.TagProperty"]] = None, **kwargs): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2018_07_01.models.TagProperty] """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1276,24 +1210,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -1309,17 +1239,18 @@ class ListContainerItem(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_07_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_07_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -1340,35 +1271,35 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -1380,12 +1311,12 @@ def __init__( ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_07_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_access = public_access self.last_modified_time = None self.lease_status = None @@ -1398,7 +1329,7 @@ def __init__( self.has_immutability_policy = None -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """The list of blob containers. :ivar value: The list of blob containers. @@ -1406,24 +1337,19 @@ class ListContainerItems(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ListContainerItem"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ListContainerItem"]] = None, **kwargs): """ :keyword value: The list of blob containers. :paramtype value: list[~azure.mgmt.storage.v2018_07_01.models.ListContainerItem] """ - super(ListContainerItems, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1433,78 +1359,64 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class ManagementPoliciesRules(msrest.serialization.Model): +class ManagementPoliciesRules(_serialization.Model): """The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :ivar policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :vartype policy: any + :vartype policy: JSON """ _attribute_map = { - 'policy': {'key': 'policy', 'type': 'object'}, + "policy": {"key": "policy", "type": "object"}, } - def __init__( - self, - *, - policy: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy: Optional[JSON] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :paramtype policy: any + :paramtype policy: JSON """ - super(ManagementPoliciesRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy = policy -class ManagementPoliciesRulesSetParameter(msrest.serialization.Model): +class ManagementPoliciesRulesSetParameter(_serialization.Model): """The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :ivar policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :vartype policy: any + :vartype policy: JSON """ _attribute_map = { - 'policy': {'key': 'properties.policy', 'type': 'object'}, + "policy": {"key": "properties.policy", "type": "object"}, } - def __init__( - self, - *, - policy: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy: Optional[JSON] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :paramtype policy: any + :paramtype policy: JSON """ - super(ManagementPoliciesRulesSetParameter, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy = policy -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -1528,15 +1440,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -1573,7 +1485,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1585,41 +1497,41 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2018_07_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2018_07_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2018_07_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2018_07_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs @@ -1628,25 +1540,25 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2018_07_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: list[~azure.mgmt.storage.v2018_07_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2018_07_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2018_07_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules self.default_action = default_action -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1660,10 +1572,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -1685,14 +1597,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2018_07_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -1706,10 +1618,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -1731,14 +1643,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -1746,24 +1658,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2018_07_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -1776,59 +1683,54 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2018_07_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2018_07_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2018_07_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_07_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_07_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -1860,29 +1762,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, } _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -1909,20 +1811,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2018_07_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_07_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_07_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -1953,7 +1856,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -1974,7 +1877,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -1983,42 +1886,38 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2018_07_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS". + :ivar name: Gets or sets the SKU name. Required for account creation; optional for update. Note + that in older versions, SKU name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", and + "Premium_ZRS". :vartype name: str or ~azure.mgmt.storage.v2018_07_01.models.SkuName - :ivar tier: Gets the SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: Gets the SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2018_07_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -2032,22 +1931,22 @@ class Sku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -2058,15 +1957,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS". + :keyword name: Gets or sets the SKU name. Required for account creation; optional for update. + Note that in older versions, SKU name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", and + "Premium_ZRS". :paramtype name: str or ~azure.mgmt.storage.v2018_07_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2018_07_01.models.Restriction] """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -2076,7 +1976,7 @@ def __init__( self.restrictions = restrictions -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -2089,22 +1989,18 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None @@ -2124,46 +2020,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2178,19 +2068,19 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2018_07_01.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_07_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2018_07_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -2199,7 +2089,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2018_07_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -2211,7 +2101,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2018_07_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -2225,7 +2115,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_07_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_07_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2244,59 +2134,59 @@ class StorageAccount(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_azure_files_aad_integration': {'key': 'properties.azureFilesAadIntegration', 'type': 'bool'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_azure_files_aad_integration": {"key": "properties.azureFilesAadIntegration", "type": "bool"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -2308,9 +2198,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_07_01.models.Identity @@ -2323,7 +2213,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -2347,65 +2237,60 @@ def __init__( self.failover_in_progress = None -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2018_07_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_07_01.models.Identity @@ -2419,7 +2304,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2018_07_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_07_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2431,24 +2316,24 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, } _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_azure_files_aad_integration': {'key': 'properties.azureFilesAadIntegration', 'type': 'bool'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_azure_files_aad_integration": {"key": "properties.azureFilesAadIntegration", "type": "bool"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, } def __init__( @@ -2469,20 +2354,20 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2018_07_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_07_01.models.Identity @@ -2496,7 +2381,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_07_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_07_01.models.AccessTier :keyword enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2507,7 +2392,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -2522,7 +2407,7 @@ def __init__( self.is_hns_enabled = is_hns_enabled -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2532,35 +2417,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2018_07_01.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2571,24 +2452,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2598,20 +2475,16 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, + "value": {"key": "value", "type": "[StorageAccount]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -2630,38 +2503,33 @@ class StorageAccountManagementPolicies(Resource): :vartype type: str :ivar policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :vartype policy: any + :vartype policy: JSON :ivar last_modified_time: Returns the date and time the ManagementPolicies was last modified. :vartype last_modified_time: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy': {'key': 'properties.policy', 'type': 'object'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy": {"key": "properties.policy", "type": "object"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, } - def __init__( - self, - *, - policy: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy: Optional[JSON] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :paramtype policy: any + :paramtype policy: JSON """ - super(StorageAccountManagementPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy = policy self.last_modified_time = None @@ -2673,84 +2541,74 @@ class StorageAccountManagementPoliciesRulesProperty(ManagementPoliciesRules): :ivar policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :vartype policy: any + :vartype policy: JSON :ivar last_modified_time: Returns the date and time the ManagementPolicies was last modified. :vartype last_modified_time: ~datetime.datetime """ _validation = { - 'last_modified_time': {'readonly': True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'policy': {'key': 'policy', 'type': 'object'}, - 'last_modified_time': {'key': 'lastModifiedTime', 'type': 'iso-8601'}, + "policy": {"key": "policy", "type": "object"}, + "last_modified_time": {"key": "lastModifiedTime", "type": "iso-8601"}, } - def __init__( - self, - *, - policy: Optional[Any] = None, - **kwargs - ): + def __init__(self, *, policy: Optional[JSON] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicies Rules, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. - :paramtype policy: any + :paramtype policy: JSON """ - super(StorageAccountManagementPoliciesRulesProperty, self).__init__(policy=policy, **kwargs) + super().__init__(policy=policy, **kwargs) self.last_modified_time = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2018_07_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_07_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2760,7 +2618,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_07_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_07_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2772,16 +2630,16 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_azure_files_aad_integration': {'key': 'properties.azureFilesAadIntegration', 'type': 'bool'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_azure_files_aad_integration": {"key": "properties.azureFilesAadIntegration", "type": "bool"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, } def __init__( @@ -2804,16 +2662,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2018_07_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_07_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_07_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -2823,7 +2681,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2018_07_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_07_01.models.AccessTier :keyword enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2834,7 +2692,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_07_01.models.NetworkRuleSet """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -2847,7 +2705,7 @@ def __init__( self.network_rule_set = network_rule_set -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2857,24 +2715,20 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Sku]'}, + "value": {"key": "value", "type": "[Sku]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2892,28 +2746,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -2921,13 +2771,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -2944,30 +2794,26 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -2976,13 +2822,13 @@ def __init__( self.upn = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2018_07_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -2993,33 +2839,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -3027,24 +2869,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2018_07_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -3056,72 +2893,68 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2018_07_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2018_07_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py index 10bd237deace..38633de02b76 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,6 +25,7 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -36,7 +37,9 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CorsRuleAllowedMethodsItem.""" DELETE = "DELETE" GET = "GET" @@ -46,13 +49,20 @@ class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): OPTIONS = "OPTIONS" PUT = "PUT" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + +class Enum8(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum8.""" + + DEFAULT = "default" + + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -65,20 +75,21 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -88,24 +99,25 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -113,15 +125,16 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -131,9 +144,9 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -141,17 +154,20 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -166,22 +182,23 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -190,6 +207,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -200,6 +218,7 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -210,6 +229,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -220,6 +240,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -230,6 +251,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -242,16 +264,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): PREMIUM_LRS = "Premium_LRS" PREMIUM_ZRS = "Premium_ZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the SKU tier. This is based on the SKU name. - """ + """Gets the SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "provisioning" DEPROVISIONING = "deprovisioning" @@ -259,9 +281,9 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/__init__.py index fd06c8765f84..ed1b0e250a6b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/__init__.py @@ -17,14 +17,15 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsagesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'ManagementPoliciesOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsagesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "ManagementPoliciesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_operations.py index a42968de2055..92d23f5e03d6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_containers_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,365 +25,313 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum8], subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum8], subscription_id: str, *, if_match: Optional[str] = None, @@ -386,43 +340,42 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum8], subscription_id: str, *, if_match: str, @@ -431,36 +384,34 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -475,34 +426,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -512,93 +462,79 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class BlobContainersOperations: """ @@ -619,50 +555,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListContainerItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContainerItems, or the result of cls(response) + :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListContainerItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -670,33 +599,33 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListContainerItems', pipeline_response) + deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -704,40 +633,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -747,7 +760,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -755,73 +769,155 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [201]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -831,7 +927,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -839,75 +936,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -915,75 +1005,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -991,10 +1074,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1004,16 +1086,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1021,40 +1104,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1064,7 +1231,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1072,73 +1240,155 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_07_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -1148,7 +1398,8 @@ def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1156,51 +1407,55 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum8], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -1208,47 +1463,144 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum8], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum8], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1256,10 +1608,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1267,17 +1618,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1285,6 +1635,7 @@ def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum8], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1292,55 +1643,52 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1348,10 +1696,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1359,17 +1706,16 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( @@ -1377,6 +1723,7 @@ def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum8], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1386,55 +1733,52 @@ def delete_immutability_policy( container after deleting all blobs inside the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1442,10 +1786,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1453,74 +1796,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1528,10 +1864,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1539,19 +1874,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1559,6 +1893,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1566,59 +1902,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1626,10 +2058,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1637,68 +2068,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequest - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1708,7 +2222,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1716,22 +2231,20 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_operations.py index 56bee2c58b7f..4bf8585651e7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_blob_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,97 +25,98 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_set_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum8], subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum8], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -130,64 +137,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum8], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum8], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum8], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties 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 - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -195,75 +283,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum8], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_07_01.models.Enum8 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -271,22 +351,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_management_policies_operations.py index 60038da9ae60..e8f45cb69c11 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,136 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPoliciesRulesSetParameter] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,55 +175,55 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Gets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName - :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountManagementPolicies, or the result of cls(response) + :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountManagementPolicies] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -218,81 +231,163 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountManagementPolicies', pipeline_response) + deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPoliciesRulesSetParameter, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountManagementPolicies: """Sets the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName - :param properties: The data policy rules to set to a storage account. + :param properties: The data policy rules to set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2018_07_01.models.ManagementPoliciesRulesSetParameter - :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str + :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: StorageAccountManagementPolicies or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountManagementPolicies: + """Sets the data policy rules associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName + :param properties: The data policy rules to set to a storage account. Required. + :type properties: IO + :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: StorageAccountManagementPolicies or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPoliciesRulesSetParameter, IO], + **kwargs: Any + ) -> _models.StorageAccountManagementPolicies: + """Sets the data policy rules associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName + :param properties: The data policy rules to set to a storage account. Is either a model type or + a IO type. Required. + :type properties: ~azure.mgmt.storage.v2018_07_01.models.ManagementPoliciesRulesSetParameter 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 - :return: StorageAccountManagementPolicies, or the result of cls(response) + :return: StorageAccountManagementPolicies or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountManagementPolicies - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountManagementPolicies] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountManagementPolicies] - _json = self._serialize.body(properties, 'ManagementPoliciesRulesSetParameter') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPoliciesRulesSetParameter") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -300,74 +395,73 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountManagementPolicies', pipeline_response) + deserialized = self._deserialize("StorageAccountManagementPolicies", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the data policy rules associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_07_01.models.ManagementPolicyName - :keyword api_version: Api Version. Default value is "2018-03-01-preview". Note that overriding - this default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-03-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2018-03-01-preview") + ) # type: Literal["2018-03-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -375,10 +469,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -388,5 +481,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_operations.py index 31c83c0961d2..74624cd46f92 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +26,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,39 +78,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -112,13 +114,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -134,10 +130,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,8 +141,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_operations.py index 355b041f6f3a..83faa98dc11c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_skus_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +26,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,41 +83,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -120,14 +120,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -143,10 +136,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -156,8 +147,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_operations.py index d9e1c1d4de56..d2c28f465520 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_storage_accounts_operations.py @@ -6,11 +6,17 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +28,110 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,355 +139,298 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "geoReplicationStats", + expand: Literal["geoReplicationStats"] = "geoReplicationStats", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: """ @@ -519,48 +451,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCheckNameAvailabilityParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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.storage.v2018_07_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2018_07_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCheckNameAvailabilityParameters 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 - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -568,55 +550,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -624,10 +614,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -636,22 +625,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -660,17 +650,58 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCreateParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 @@ -682,20 +713,57 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -703,82 +771,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -786,10 +846,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -799,15 +858,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[str] = "geoReplicationStats", + expand: Literal["geoReplicationStats"] = "geoReplicationStats", **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -815,43 +873,42 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". + Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -859,32 +916,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -897,35 +954,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountUpdateParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -934,7 +1073,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -942,61 +1082,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1004,14 +1138,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1027,10 +1154,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1040,52 +1165,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1093,15 +1211,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -1117,10 +1227,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1130,54 +1238,48 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1185,67 +1287,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountRegenerateKeyParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2018_07_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1254,7 +1427,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1262,66 +1436,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.AccountSasParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1330,7 +1574,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1338,66 +1583,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ServiceSasParameters - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_07_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_07_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1406,7 +1719,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1414,50 +1728,47 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1465,10 +1776,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1478,30 +1788,21 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: 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 @@ -1512,52 +1813,47 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_operations.py index 5f3c3319832a..e522684bf483 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_07_01/operations/_usages_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +26,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,44 +86,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str - :keyword api_version: Api Version. Default value is "2018-07-01". Note that overriding this - default value may result in unsupported behavior. - :paramtype api_version: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_07_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-07-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-07-01")) # type: Literal["2018-07-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -125,15 +127,7 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, - ) + request = HttpRequest("GET", next_link) request = _convert_request(request) request.url = self._client.format_url(request.url) # type: ignore request.method = "GET" @@ -149,10 +143,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -162,8 +154,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_configuration.py index 2a7935dedc39..0a30c12d18ad 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-11-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-11-01") # type: str + api_version = kwargs.pop("api_version", "2018-11-01") # type: Literal["2018-11-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json index 821c231c15bc..c5463db13e4b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -105,4 +105,4 @@ "blob_services": "BlobServicesOperations", "blob_containers": "BlobContainersOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py index d3bba021f989..769ae451e8c4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_storage_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobServicesOperations, ManagementPoliciesOperations, Operations, SkusOperations, StorageAccountsOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobServicesOperations, + ManagementPoliciesOperations, + Operations, + SkusOperations, + StorageAccountsOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -40,9 +48,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype blob_services: azure.mgmt.storage.v2018_11_01.operations.BlobServicesOperations :ivar blob_containers: BlobContainersOperations operations :vartype blob_containers: azure.mgmt.storage.v2018_11_01.operations.BlobContainersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -60,41 +68,28 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -103,7 +98,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_configuration.py index e8af14a2ebe8..e5914588a877 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2018-11-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2018-11-01") # type: str + api_version = kwargs.pop("api_version", "2018-11-01") # type: Literal["2018-11-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py index 6dc3d35a14ee..476a88c3b60b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/_storage_management_client.py @@ -9,20 +9,28 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobServicesOperations, ManagementPoliciesOperations, Operations, SkusOperations, StorageAccountsOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobServicesOperations, + ManagementPoliciesOperations, + Operations, + SkusOperations, + StorageAccountsOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -42,9 +50,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :ivar blob_containers: BlobContainersOperations operations :vartype blob_containers: azure.mgmt.storage.v2018_11_01.aio.operations.BlobContainersOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -62,41 +70,28 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -105,7 +100,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/__init__.py index 4d4295e47e06..d14c7ec7f9c7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/__init__.py @@ -17,14 +17,15 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobServicesOperations", + "BlobContainersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_operations.py index 1b4007691a40..00c78cbd7890 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_containers_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -41,47 +69,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListContainerItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContainerItems, or the result of cls(response) + :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListContainerItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -89,33 +113,33 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListContainerItems', pipeline_response) + deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -123,37 +147,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -163,7 +274,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -171,10 +283,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -182,63 +293,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -248,7 +445,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -256,72 +454,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -329,72 +523,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -402,10 +592,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -415,16 +604,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -432,37 +622,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -472,7 +749,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -480,70 +758,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -553,7 +916,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -561,51 +925,55 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum10], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -613,44 +981,144 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum10], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum10], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -658,10 +1126,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -669,17 +1136,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -687,6 +1153,7 @@ async def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum10], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -694,52 +1161,52 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -747,10 +1214,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -758,17 +1224,16 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -776,6 +1241,7 @@ async def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum10], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -785,52 +1251,52 @@ async def delete_immutability_policy( container after deleting all blobs inside the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -838,10 +1304,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -849,71 +1314,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -921,10 +1382,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -932,19 +1392,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -952,6 +1411,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -959,56 +1420,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1016,10 +1576,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1027,65 +1586,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1095,7 +1740,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1103,22 +1749,20 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_operations.py index 3b62ce6b0dba..1c4bac7b1f87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_blob_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,19 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -41,61 +58,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum10], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum10], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum10], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -103,72 +204,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum10], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -176,22 +272,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_operations.py index 324761d824ef..864bad01e7f0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,52 +59,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -94,78 +113,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy + :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: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -173,71 +274,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -245,10 +346,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -258,5 +358,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_operations.py index a0587349cf60..2c937b19a5e4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_operations.py index 4ae0541a8198..4de5535b70e4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_operations.py index d8ce40438942..26cefcbbcb18 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_revoke_user_delegation_keys_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +74,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2018_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2018_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCheckNameAvailabilityParameters 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 - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +173,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +237,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +248,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +273,17 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCreateParameters + :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 @@ -203,20 +296,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCreateParameters 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. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +397,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +472,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,15 +484,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[str] = "geoReplicationStats", + expand: Literal["geoReplicationStats"] = "geoReplicationStats", **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -333,40 +499,42 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". + Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,32 +542,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -412,32 +580,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -446,7 +699,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -454,58 +708,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -513,13 +765,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -536,10 +792,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,49 +803,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -599,14 +852,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -623,10 +879,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -636,51 +890,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -688,64 +939,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2018_11_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -754,7 +1079,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -762,63 +1088,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -827,7 +1226,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -835,63 +1235,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -900,7 +1371,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -908,50 +1380,47 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -959,10 +1428,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -972,26 +1440,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1003,95 +1465,89 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1099,10 +1555,9 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1112,5 +1567,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_operations.py index f76e7817ea70..97448243857f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,42 +57,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2018_11_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -85,14 +98,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -109,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -122,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py index 85d8f76f4325..8780396b3394 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/__init__.py @@ -72,138 +72,138 @@ from ._models_py3 import UsageName from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountStatus, - Bypass, - CorsRuleAllowedMethodsItem, - DefaultAction, - GeoReplicationStatus, - HttpProtocol, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - KeyPermission, - KeySource, - Kind, - LeaseContainerRequestAction, - LeaseDuration, - LeaseState, - LeaseStatus, - ManagementPolicyName, - Permissions, - ProvisioningState, - PublicAccess, - Reason, - ReasonCode, - RuleType, - Services, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CorsRuleAllowedMethodsItem +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import Enum10 +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'AzureEntityResource', - 'BlobContainer', - 'BlobServiceProperties', - 'CheckNameAvailabilityResult', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DateAfterCreation', - 'DateAfterModification', - 'DeleteRetentionPolicy', - 'Dimension', - 'Encryption', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'KeyVaultProperties', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListContainerItem', - 'ListContainerItems', - 'ListServiceSasResponse', - 'ManagementPolicy', - 'ManagementPolicyAction', - 'ManagementPolicyBaseBlob', - 'ManagementPolicyDefinition', - 'ManagementPolicyFilter', - 'ManagementPolicyRule', - 'ManagementPolicySchema', - 'ManagementPolicySnapShot', - 'MetricSpecification', - 'NetworkRuleSet', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Resource', - 'Restriction', - 'SKUCapability', - 'ServiceSasParameters', - 'ServiceSpecification', - 'Sku', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageSkuListResult', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'Bypass', - 'CorsRuleAllowedMethodsItem', - 'DefaultAction', - 'GeoReplicationStatus', - 'HttpProtocol', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'KeyPermission', - 'KeySource', - 'Kind', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseState', - 'LeaseStatus', - 'ManagementPolicyName', - 'Permissions', - 'ProvisioningState', - 'PublicAccess', - 'Reason', - 'ReasonCode', - 'RuleType', - 'Services', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'UsageUnit', + "AccountSasParameters", + "AzureEntityResource", + "BlobContainer", + "BlobServiceProperties", + "CheckNameAvailabilityResult", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "Dimension", + "Encryption", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "KeyVaultProperties", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListContainerItem", + "ListContainerItems", + "ListServiceSasResponse", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "MetricSpecification", + "NetworkRuleSet", + "Operation", + "OperationDisplay", + "OperationListResult", + "Resource", + "Restriction", + "SKUCapability", + "ServiceSasParameters", + "ServiceSpecification", + "Sku", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageSkuListResult", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "Bypass", + "CorsRuleAllowedMethodsItem", + "DefaultAction", + "Enum10", + "GeoReplicationStatus", + "HttpProtocol", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "KeyPermission", + "KeySource", + "Kind", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseState", + "LeaseStatus", + "ManagementPolicyName", + "Permissions", + "ProvisioningState", + "PublicAccess", + "Reason", + "ReasonCode", + "RuleType", + "Services", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py index eaf95925e8da..c09c5cb9e749 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,63 +8,69 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2018_11_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2018_11_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_11_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_11_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -80,33 +87,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2018_11_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2018_11_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_11_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_11_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -117,7 +125,7 @@ def __init__( self.key_to_sign = key_to_sign -class Resource(msrest.serialization.Model): +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. @@ -133,24 +141,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -174,30 +178,26 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -213,17 +213,18 @@ class BlobContainer(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_11_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -244,35 +245,35 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -284,12 +285,12 @@ def __init__( ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_11_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_access = public_access self.last_modified_time = None self.lease_status = None @@ -328,18 +329,18 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, } def __init__( @@ -363,13 +364,13 @@ def __init__( :paramtype delete_retention_policy: ~azure.mgmt.storage.v2018_11_01.models.DeleteRetentionPolicy """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors self.default_service_version = default_service_version self.delete_retention_policy = delete_retention_policy -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -379,7 +380,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2018_11_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -387,66 +388,62 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2018_11_01.models.CorsRuleAllowedMethodsItem] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -460,24 +457,24 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2018_11_01.models.CorsRuleAllowedMethodsItem] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -485,7 +482,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -494,31 +491,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2018_11_01.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -526,101 +518,85 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DateAfterCreation(msrest.serialization.Model): +class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. All required parameters must be populated in order to send to Azure. - :ivar days_after_creation_greater_than: Required. Integer value indicating the age in days - after creation. + :ivar days_after_creation_greater_than: Integer value indicating the age in days after + creation. Required. :vartype days_after_creation_greater_than: int """ _validation = { - 'days_after_creation_greater_than': {'required': True, 'minimum': 0}, + "days_after_creation_greater_than": {"required": True, "minimum": 0}, } _attribute_map = { - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'int'}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "int"}, } - def __init__( - self, - *, - days_after_creation_greater_than: int, - **kwargs - ): + def __init__(self, *, days_after_creation_greater_than: int, **kwargs): """ - :keyword days_after_creation_greater_than: Required. Integer value indicating the age in days - after creation. + :keyword days_after_creation_greater_than: Integer value indicating the age in days after + creation. Required. :paramtype days_after_creation_greater_than: int """ - super(DateAfterCreation, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_creation_greater_than = days_after_creation_greater_than -class DateAfterModification(msrest.serialization.Model): +class DateAfterModification(_serialization.Model): """Object to define the number of days after last modification. All required parameters must be populated in order to send to Azure. - :ivar days_after_modification_greater_than: Required. Integer value indicating the age in days - after last modification. + :ivar days_after_modification_greater_than: Integer value indicating the age in days after last + modification. Required. :vartype days_after_modification_greater_than: int """ _validation = { - 'days_after_modification_greater_than': {'required': True, 'minimum': 0}, + "days_after_modification_greater_than": {"required": True, "minimum": 0}, } _attribute_map = { - 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'int'}, + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "int"}, } - def __init__( - self, - *, - days_after_modification_greater_than: int, - **kwargs - ): + def __init__(self, *, days_after_modification_greater_than: int, **kwargs): """ - :keyword days_after_modification_greater_than: Required. Integer value indicating the age in - days after last modification. + :keyword days_after_modification_greater_than: Integer value indicating the age in days after + last modification. Required. :paramtype days_after_modification_greater_than: int """ - super(DateAfterModification, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_modification_greater_than = days_after_modification_greater_than -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The blob service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled for the Blob service. @@ -631,21 +607,15 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled for the Blob service. :paramtype enabled: bool @@ -653,12 +623,12 @@ def __init__( minimum specified value can be 1 and the maximum value can be 365. :paramtype days: int """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -668,51 +638,45 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2018_11_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2018_11_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. :vartype key_vault_properties: ~azure.mgmt.storage.v2018_11_01.models.KeyVaultProperties """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, } def __init__( @@ -726,20 +690,20 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2018_11_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2018_11_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. :paramtype key_vault_properties: ~azure.mgmt.storage.v2018_11_01.models.KeyVaultProperties """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.key_vault_properties = key_vault_properties -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -754,31 +718,26 @@ class EncryptionService(msrest.serialization.Model): """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is stored. :paramtype enabled: bool """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. Variables are only populated by the server, and will be ignored when sending a request. @@ -794,15 +753,15 @@ class EncryptionServices(msrest.serialization.Model): """ _validation = { - 'table': {'readonly': True}, - 'queue': {'readonly': True}, + "table": {"readonly": True}, + "queue": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -818,14 +777,14 @@ def __init__( :keyword file: The encryption function of the file storage service. :paramtype file: ~azure.mgmt.storage.v2018_11_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = None self.queue = None -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -845,30 +804,26 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Endpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -877,7 +832,7 @@ def __init__( self.dfs = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -886,7 +841,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2018_11_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -899,30 +854,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -933,31 +884,27 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Has constant value: "SystemAssigned". + :ivar type: The identity type. Required. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True, 'constant': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "SystemAssigned" - def __init__( - self, - **kwargs - ): - """ - """ - super(Identity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -979,49 +926,47 @@ class ImmutabilityPolicy(AzureEntityResource): :vartype type: str :ivar etag: Resource Etag. :vartype etag: str - :ivar immutability_period_since_creation_in_days: Required. The immutability period for the - blobs in the container since the policy creation, in days. + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. Required. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicyState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'required': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "immutability_period_since_creation_in_days": {"required": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, } - def __init__( - self, - *, - immutability_period_since_creation_in_days: int, - **kwargs - ): + def __init__(self, *, immutability_period_since_creation_in_days: int, **kwargs): """ - :keyword immutability_period_since_creation_in_days: Required. The immutability period for the - blobs in the container since the policy creation, in days. + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. Required. :paramtype immutability_period_since_creation_in_days: int """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -1034,84 +979,74 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicyState """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, } - def __init__( - self, - *, - immutability_period_since_creation_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, immutability_period_since_creation_in_days: Optional[int] = None, **kwargs): """ :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. :paramtype immutability_period_since_creation_in_days: int """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. :ivar key_name: The name of KeyVault key. @@ -1123,9 +1058,9 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, } def __init__( @@ -1144,19 +1079,19 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -1172,15 +1107,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -1194,8 +1129,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -1209,7 +1144,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -1217,7 +1152,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -1228,17 +1163,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -1246,12 +1175,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -1263,38 +1192,33 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, } - def __init__( - self, - *, - tags: List[str], - **kwargs - ): + def __init__(self, *, tags: List[str], **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -1304,35 +1228,30 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2018_11_01.models.TagProperty] """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, } - def __init__( - self, - *, - tags: Optional[List["_models.TagProperty"]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[List["_models.TagProperty"]] = None, **kwargs): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2018_11_01.models.TagProperty] """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1342,24 +1261,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -1375,17 +1290,18 @@ class ListContainerItem(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2018_11_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2018_11_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -1406,35 +1322,35 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -1446,12 +1362,12 @@ def __init__( ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2018_11_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_access = public_access self.last_modified_time = None self.lease_status = None @@ -1464,7 +1380,7 @@ def __init__( self.has_immutability_policy = None -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """The list of blob containers. :ivar value: The list of blob containers. @@ -1472,24 +1388,19 @@ class ListContainerItems(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ListContainerItem"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ListContainerItem"]] = None, **kwargs): """ :keyword value: The list of blob containers. :paramtype value: list[~azure.mgmt.storage.v2018_11_01.models.ListContainerItem] """ - super(ListContainerItems, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1499,20 +1410,16 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None @@ -1537,37 +1444,32 @@ class ManagementPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.ManagementPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :paramtype policy: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicySchema """ - super(ManagementPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.policy = policy -class ManagementPolicyAction(msrest.serialization.Model): +class ManagementPolicyAction(_serialization.Model): """Actions are applied to the filtered blobs when the execution condition is met. :ivar base_blob: The management policy action for base blob. @@ -1577,8 +1479,8 @@ class ManagementPolicyAction(msrest.serialization.Model): """ _attribute_map = { - 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, - 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, } def __init__( @@ -1594,12 +1496,12 @@ def __init__( :keyword snapshot: The management policy action for snapshot. :paramtype snapshot: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicySnapShot """ - super(ManagementPolicyAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_blob = base_blob self.snapshot = snapshot -class ManagementPolicyBaseBlob(msrest.serialization.Model): +class ManagementPolicyBaseBlob(_serialization.Model): """Management policy action for base blob. :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot @@ -1613,9 +1515,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, - 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, } def __init__( @@ -1636,30 +1538,30 @@ def __init__( :keyword delete: The function to delete the blob. :paramtype delete: ~azure.mgmt.storage.v2018_11_01.models.DateAfterModification """ - super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class ManagementPolicyDefinition(msrest.serialization.Model): +class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. All required parameters must be populated in order to send to Azure. - :ivar actions: Required. An object that defines the action set. + :ivar actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyAction :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyFilter """ _validation = { - 'actions': {'required': True}, + "actions": {"required": True}, } _attribute_map = { - 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, - 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, } def __init__( @@ -1670,81 +1572,75 @@ def __init__( **kwargs ): """ - :keyword actions: Required. An object that defines the action set. + :keyword actions: An object that defines the action set. Required. :paramtype actions: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyAction :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyFilter """ - super(ManagementPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.filters = filters -class ManagementPolicyFilter(msrest.serialization.Model): +class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Only blockBlob is supported. + :ivar blob_types: An array of predefined enum values. Only blockBlob is supported. Required. :vartype blob_types: list[str] """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, } - def __init__( - self, - *, - blob_types: List[str], - prefix_match: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, blob_types: List[str], prefix_match: Optional[List[str]] = None, **kwargs): """ :keyword prefix_match: An array of strings for prefixes to be match. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Only blockBlob is supported. + :keyword blob_types: An array of predefined enum values. Only blockBlob is supported. Required. :paramtype blob_types: list[str] """ - super(ManagementPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types -class ManagementPolicyRule(msrest.serialization.Model): +class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. :ivar enabled: Rule is enabled if set to true. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" :vartype type: str or ~azure.mgmt.storage.v2018_11_01.models.RuleType - :ivar definition: Required. An object that defines the Lifecycle rule. + :ivar definition: An object that defines the Lifecycle rule. Required. :vartype definition: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyDefinition """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - 'definition': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, } def __init__( @@ -1759,55 +1655,52 @@ def __init__( """ :keyword enabled: Rule is enabled if set to true. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" :paramtype type: str or ~azure.mgmt.storage.v2018_11_01.models.RuleType - :keyword definition: Required. An object that defines the Lifecycle rule. + :keyword definition: An object that defines the Lifecycle rule. Required. :paramtype definition: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyDefinition """ - super(ManagementPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.type = type self.definition = definition -class ManagementPolicySchema(msrest.serialization.Model): +class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. All required parameters must be populated in order to send to Azure. - :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :vartype rules: list[~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyRule] """ _validation = { - 'rules': {'required': True}, + "rules": {"required": True}, } _attribute_map = { - 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, } - def __init__( - self, - *, - rules: List["_models.ManagementPolicyRule"], - **kwargs - ): + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): """ - :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :paramtype rules: list[~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyRule] """ - super(ManagementPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.rules = rules -class ManagementPolicySnapShot(msrest.serialization.Model): +class ManagementPolicySnapShot(_serialization.Model): """Management policy action for snapshot. :ivar delete: The function to delete the blob snapshot. @@ -1815,24 +1708,19 @@ class ManagementPolicySnapShot(msrest.serialization.Model): """ _attribute_map = { - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } - def __init__( - self, - *, - delete: Optional["_models.DateAfterCreation"] = None, - **kwargs - ): + def __init__(self, *, delete: Optional["_models.DateAfterCreation"] = None, **kwargs): """ :keyword delete: The function to delete the blob snapshot. :paramtype delete: ~azure.mgmt.storage.v2018_11_01.models.DateAfterCreation """ - super(ManagementPolicySnapShot, self).__init__(**kwargs) + super().__init__(**kwargs) self.delete = delete -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -1856,15 +1744,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -1901,7 +1789,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -1913,41 +1801,41 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2018_11_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2018_11_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2018_11_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2018_11_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs @@ -1956,25 +1844,25 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2018_11_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: list[~azure.mgmt.storage.v2018_11_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2018_11_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2018_11_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules self.default_action = default_action -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -1988,10 +1876,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -2013,14 +1901,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2018_11_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -2034,10 +1922,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2059,14 +1947,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -2074,24 +1962,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2018_11_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -2104,59 +1987,54 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2018_11_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2018_11_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2018_11_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2018_11_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2018_11_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -2188,29 +2066,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, - } - - _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, + } + + _attribute_map = { + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -2237,20 +2115,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2018_11_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2018_11_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2018_11_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -2281,7 +2160,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -2302,7 +2181,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -2311,42 +2190,38 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2018_11_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS". + :ivar name: Gets or sets the SKU name. Required for account creation; optional for update. Note + that in older versions, SKU name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", and + "Premium_ZRS". :vartype name: str or ~azure.mgmt.storage.v2018_11_01.models.SkuName - :ivar tier: Gets the SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: Gets the SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2018_11_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -2360,22 +2235,22 @@ class Sku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -2386,15 +2261,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Known values are: - "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS". + :keyword name: Gets or sets the SKU name. Required for account creation; optional for update. + Note that in older versions, SKU name was called accountType. Required. Known values are: + "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", and + "Premium_ZRS". :paramtype name: str or ~azure.mgmt.storage.v2018_11_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2018_11_01.models.Restriction] """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -2404,7 +2280,7 @@ def __init__( self.restrictions = restrictions -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -2417,22 +2293,18 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None @@ -2452,46 +2324,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2506,19 +2372,19 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2018_11_01.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_11_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2018_11_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -2527,7 +2393,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2018_11_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -2539,7 +2405,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2018_11_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -2553,7 +2419,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_11_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_11_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2572,59 +2438,59 @@ class StorageAccount(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_azure_files_aad_integration': {'key': 'properties.azureFilesAadIntegration', 'type': 'bool'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_azure_files_aad_integration": {"key": "properties.azureFilesAadIntegration", "type": "bool"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -2636,9 +2502,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_11_01.models.Identity @@ -2651,7 +2517,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -2675,65 +2541,60 @@ def __init__( self.failover_in_progress = None -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2018_11_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_11_01.models.Identity @@ -2747,7 +2608,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2018_11_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_11_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2759,24 +2620,24 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, } _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_azure_files_aad_integration': {'key': 'properties.azureFilesAadIntegration', 'type': 'bool'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_azure_files_aad_integration": {"key": "properties.azureFilesAadIntegration", "type": "bool"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, } def __init__( @@ -2797,20 +2658,20 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2018_11_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_11_01.models.Identity @@ -2824,7 +2685,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_11_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_11_01.models.AccessTier :keyword enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -2835,7 +2696,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -2850,7 +2711,7 @@ def __init__( self.is_hns_enabled = is_hns_enabled -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2860,35 +2721,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2018_11_01.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2899,24 +2756,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -2926,72 +2779,63 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, + "value": {"key": "value", "type": "[StorageAccount]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2018_11_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2018_11_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -3001,7 +2845,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2018_11_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2018_11_01.models.AccessTier :ivar enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -3013,16 +2857,16 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'enable_azure_files_aad_integration': {'key': 'properties.azureFilesAadIntegration', 'type': 'bool'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "enable_azure_files_aad_integration": {"key": "properties.azureFilesAadIntegration", "type": "bool"}, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, } def __init__( @@ -3045,16 +2889,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2018_11_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2018_11_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2018_11_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -3064,7 +2908,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2018_11_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2018_11_01.models.AccessTier :keyword enable_azure_files_aad_integration: Enables Azure Files AAD Integration for SMB if sets to true. @@ -3075,7 +2919,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2018_11_01.models.NetworkRuleSet """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -3088,7 +2932,7 @@ def __init__( self.network_rule_set = network_rule_set -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -3098,24 +2942,20 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Sku]'}, + "value": {"key": "value", "type": "[Sku]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3133,28 +2973,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -3162,13 +2998,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -3185,30 +3021,26 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -3217,13 +3049,13 @@ def __init__( self.upn = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2018_11_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -3234,33 +3066,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -3268,24 +3096,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2018_11_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -3297,72 +3120,68 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2018_11_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2018_11_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py index 895e7f2b2388..0fd24aeeff07 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,6 +25,7 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -36,7 +37,9 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CorsRuleAllowedMethodsItem.""" DELETE = "DELETE" GET = "GET" @@ -46,13 +49,20 @@ class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): OPTIONS = "OPTIONS" PUT = "PUT" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + +class Enum10(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum10.""" + + DEFAULT = "default" + + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -65,20 +75,21 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -88,24 +99,25 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -113,15 +125,16 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -131,9 +144,9 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -141,17 +154,20 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -166,22 +182,23 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -190,6 +207,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -200,12 +218,13 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Lifecycle - """ + """The valid value is Lifecycle.""" LIFECYCLE = "Lifecycle" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -216,6 +235,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -226,6 +246,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -236,6 +257,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -248,16 +270,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): PREMIUM_LRS = "Premium_LRS" PREMIUM_ZRS = "Premium_ZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the SKU tier. This is based on the SKU name. - """ + """Gets the SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "provisioning" DEPROVISIONING = "deprovisioning" @@ -265,9 +287,9 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/__init__.py index 4d4295e47e06..d14c7ec7f9c7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/__init__.py @@ -17,14 +17,15 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobServicesOperations", + "BlobContainersOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_operations.py index 0f3d31dae7bb..0377b637dde4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_containers_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,365 +25,313 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum10], subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum10], subscription_id: str, *, if_match: Optional[str] = None, @@ -386,43 +340,42 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum10], subscription_id: str, *, if_match: str, @@ -431,36 +384,34 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -475,34 +426,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -512,93 +462,79 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class BlobContainersOperations: """ @@ -619,47 +555,43 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListContainerItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListContainerItems: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListContainerItems, or the result of cls(response) + :return: ListContainerItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListContainerItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -667,33 +599,33 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListContainerItems', pipeline_response) + deserialized = self._deserialize("ListContainerItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -701,37 +633,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -741,7 +760,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -749,10 +769,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -760,63 +779,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -826,7 +931,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -834,72 +940,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -907,72 +1009,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -980,10 +1078,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -993,16 +1090,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1010,37 +1108,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1050,7 +1235,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1058,70 +1244,155 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2018_11_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -1131,7 +1402,8 @@ def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1139,51 +1411,55 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum10], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -1191,44 +1467,144 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum10], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum10], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1236,10 +1612,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1247,17 +1622,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1265,6 +1639,7 @@ def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum10], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1272,52 +1647,52 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1325,10 +1700,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1336,17 +1710,16 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( @@ -1354,6 +1727,7 @@ def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum10], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1363,52 +1737,52 @@ def delete_immutability_policy( container after deleting all blobs inside the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1416,10 +1790,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1427,71 +1800,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1499,10 +1868,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1510,19 +1878,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1530,6 +1897,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1537,56 +1906,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1594,10 +2062,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1605,65 +2072,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1673,7 +2226,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1681,22 +2235,20 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_operations.py index 3ad1c0edfe7d..02a8b046f14f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_blob_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,97 +25,98 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_set_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum10], subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum10], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -130,61 +137,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum10], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum10], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum10], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties 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 - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -192,72 +283,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum10], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2018_11_01.models.Enum10 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -265,22 +351,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_operations.py index 4f44fe3159aa..00bc1bd2bcc3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,130 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,52 +169,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -215,78 +223,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy 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 - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -294,71 +384,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2018_11_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -366,10 +456,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +468,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_operations.py index 7447d5b49380..9dfad430f667 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_operations.py index 79e112ac373e..ff841b8bab64 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_operations.py index 4aaa29d1b6be..cbf844af4fff 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +29,110 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,385 +140,325 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "geoReplicationStats", + expand: Literal["geoReplicationStats"] = "geoReplicationStats", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_revoke_user_delegation_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: """ @@ -549,45 +479,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2018_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2018_11_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCheckNameAvailabilityParameters 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 - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -595,55 +578,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -651,10 +642,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -663,22 +653,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -687,14 +678,98 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountCreateParameters 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 @@ -706,20 +781,17 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -727,79 +799,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -807,10 +874,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -820,15 +886,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[str] = "geoReplicationStats", + expand: Literal["geoReplicationStats"] = "geoReplicationStats", **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -836,40 +901,42 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". + Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -877,32 +944,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -915,32 +982,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -949,7 +1101,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -957,58 +1110,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1016,13 +1166,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1039,10 +1193,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1052,49 +1204,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1102,14 +1250,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1126,10 +1277,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1139,51 +1288,48 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_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.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1191,64 +1337,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. :type regenerate_key: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1 or key2. + Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2018_11_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1257,7 +1477,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1265,63 +1486,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1330,7 +1624,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1338,63 +1633,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2018_11_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2018_11_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1403,7 +1769,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1411,50 +1778,47 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1462,10 +1826,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1475,26 +1838,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1506,95 +1863,89 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1602,10 +1953,9 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1615,5 +1965,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_operations.py index 40ce19e78634..eb76e93fec2b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2018_11_01/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,41 +87,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2018_11_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2018-11-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2018-11-01")) # type: Literal["2018-11-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -122,14 +128,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -146,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -159,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_configuration.py index d997826051ea..a7f6c3a3435d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-04-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + api_version = kwargs.pop("api_version", "2019-04-01") # type: Literal["2019-04-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json index 14326d881fac..dd27ad2904d0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -107,4 +107,4 @@ "file_services": "FileServicesOperations", "file_shares": "FileSharesOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py index a0f640c8db22..14becf6267cc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_storage_management_client.py @@ -9,20 +9,30 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobServicesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, Operations, SkusOperations, StorageAccountsOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobServicesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + Operations, + SkusOperations, + StorageAccountsOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -44,9 +54,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype file_services: azure.mgmt.storage.v2019_04_01.operations.FileServicesOperations :ivar file_shares: FileSharesOperations operations :vartype file_shares: azure.mgmt.storage.v2019_04_01.operations.FileSharesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -64,47 +74,30 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -113,7 +106,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_configuration.py index a72047cbad2b..e11f71b7be6f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-04-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-04-01") # type: str + api_version = kwargs.pop("api_version", "2019-04-01") # type: Literal["2019-04-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py index 3ce1382f61f5..96f1bf9dd685 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/_storage_management_client.py @@ -9,20 +9,30 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobServicesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, Operations, SkusOperations, StorageAccountsOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobServicesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + Operations, + SkusOperations, + StorageAccountsOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -46,9 +56,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype file_services: azure.mgmt.storage.v2019_04_01.aio.operations.FileServicesOperations :ivar file_shares: FileSharesOperations operations :vartype file_shares: azure.mgmt.storage.v2019_04_01.aio.operations.FileSharesOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -66,47 +76,30 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -115,7 +108,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/__init__.py index 12917503aa75..912b016c2b9e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/__init__.py @@ -19,16 +19,17 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_operations.py index f52b68e39263..976594c7f85f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_containers_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -43,7 +72,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,16 +81,16 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListContainerItems]: + ) -> AsyncIterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param skip_token: Optional. Continuation token for the list operation. Default value is None. :type skip_token: str @@ -73,33 +101,37 @@ def list( listed. 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 ListContainerItems or the result of cls(response) + :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -107,18 +139,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip_token=skip_token, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -135,10 +166,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -148,19 +177,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -168,37 +197,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -208,7 +324,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -216,10 +333,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -227,63 +343,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -293,7 +495,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -301,72 +504,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -374,72 +573,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -447,10 +642,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -460,16 +654,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -477,37 +672,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -517,7 +799,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -525,70 +808,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -598,7 +966,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -606,51 +975,55 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum16], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -658,44 +1031,144 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum16], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum16], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -703,10 +1176,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -714,17 +1186,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -732,6 +1203,7 @@ async def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum16], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -739,52 +1211,52 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -792,10 +1264,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -803,17 +1274,16 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -821,6 +1291,7 @@ async def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum16], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -830,52 +1301,52 @@ async def delete_immutability_policy( container after deleting all blobs inside the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -883,10 +1354,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -894,71 +1364,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -966,10 +1432,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -977,19 +1442,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -997,6 +1461,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1004,56 +1470,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1061,10 +1626,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1072,65 +1636,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1140,7 +1790,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1148,22 +1799,20 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_operations.py index b31f94456a7f..d48de2a9e675 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_blob_services_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -43,48 +62,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,66 +150,149 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum16], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum16], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum16], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -197,72 +300,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum16], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -270,22 +368,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_operations.py index 778aaff67642..2c325ca3644b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +102,162 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum16], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum16], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum16], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +265,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum16], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +333,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_operations.py index 41ffb6148170..2b0486ca8af9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_file_shares_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_shares_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileSharesOperations: """ .. warning:: @@ -43,7 +64,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,15 +73,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.FileShareItems]: + ) -> AsyncIterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param skip_token: Optional. Continuation token for the list operation. Default value is None. :type skip_token: str @@ -72,33 +92,37 @@ def list( listed. 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 FileShareItems or the result of cls(response) + :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -106,18 +130,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip_token=skip_token, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -134,10 +157,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -147,19 +168,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -167,37 +188,124 @@ async def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, @@ -207,7 +315,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -215,10 +324,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -226,63 +334,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -292,7 +486,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -300,72 +495,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - share_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, share_name: str, **kwargs: Any ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -373,72 +564,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - share_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, share_name: str, **kwargs: Any ) -> None: """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -446,10 +633,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -459,5 +645,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_operations.py index b8e776d6caed..da65caf69ab9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,52 +59,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -94,78 +113,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy + :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: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -173,71 +274,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -245,10 +346,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -258,5 +358,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_operations.py index 137bad1d503b..844d33381b75 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_operations.py index ace3770fecfe..7a00bbdab9ad 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_operations.py index 402191332716..1275084036b2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_revoke_user_delegation_keys_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +74,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2019_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2019_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCheckNameAvailabilityParameters 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 - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +173,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +237,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +248,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +273,100 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCreateParameters 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 @@ -203,20 +379,17 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +397,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +472,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,15 +484,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[str] = "geoReplicationStats", + expand: Literal["geoReplicationStats"] = "geoReplicationStats", **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -333,40 +499,42 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". + Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,32 +542,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -412,32 +580,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountUpdateParameters + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -446,7 +699,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -454,58 +708,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -513,13 +765,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -536,10 +792,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,49 +803,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -599,14 +852,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -623,10 +879,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -636,57 +890,53 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -694,65 +944,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2019_04_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -761,7 +1084,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -769,63 +1093,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.AccountSasParameters 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 - :return: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -834,7 +1231,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -842,63 +1240,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ServiceSasParameters + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -907,7 +1376,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -915,50 +1385,47 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -966,10 +1433,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -979,26 +1445,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1010,95 +1470,89 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1106,10 +1560,9 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1119,5 +1572,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_operations.py index dcc371d56952..ccfe82c5c649 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,42 +57,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_04_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -85,14 +98,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -109,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -122,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/__init__.py index ff69ee353850..d8cb8bcd4ff5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/__init__.py @@ -82,154 +82,154 @@ from ._models_py3 import UsageName from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountStatus, - Bypass, - CorsRuleAllowedMethodsItem, - DefaultAction, - DirectoryServiceOptions, - GeoReplicationStatus, - HttpProtocol, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - KeyPermission, - KeySource, - Kind, - LargeFileSharesState, - LeaseContainerRequestAction, - LeaseDuration, - LeaseState, - LeaseStatus, - ManagementPolicyName, - MinimumTlsVersion, - Permissions, - ProvisioningState, - PublicAccess, - Reason, - ReasonCode, - RuleType, - Services, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CorsRuleAllowedMethodsItem +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import Enum16 +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'ActiveDirectoryProperties', - 'AzureEntityResource', - 'AzureFilesIdentityBasedAuthentication', - 'BlobContainer', - 'BlobServiceItems', - 'BlobServiceProperties', - 'ChangeFeed', - 'CheckNameAvailabilityResult', - 'CloudErrorBody', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DateAfterCreation', - 'DateAfterModification', - 'DeleteRetentionPolicy', - 'Dimension', - 'Encryption', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'FileServiceItems', - 'FileServiceProperties', - 'FileShare', - 'FileShareItem', - 'FileShareItems', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'KeyVaultProperties', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListContainerItem', - 'ListContainerItems', - 'ListServiceSasResponse', - 'ManagementPolicy', - 'ManagementPolicyAction', - 'ManagementPolicyBaseBlob', - 'ManagementPolicyDefinition', - 'ManagementPolicyFilter', - 'ManagementPolicyRule', - 'ManagementPolicySchema', - 'ManagementPolicySnapShot', - 'MetricSpecification', - 'NetworkRuleSet', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'Resource', - 'Restriction', - 'SKUCapability', - 'ServiceSasParameters', - 'ServiceSpecification', - 'Sku', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageSkuListResult', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'Bypass', - 'CorsRuleAllowedMethodsItem', - 'DefaultAction', - 'DirectoryServiceOptions', - 'GeoReplicationStatus', - 'HttpProtocol', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'KeyPermission', - 'KeySource', - 'Kind', - 'LargeFileSharesState', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseState', - 'LeaseStatus', - 'ManagementPolicyName', - 'MinimumTlsVersion', - 'Permissions', - 'ProvisioningState', - 'PublicAccess', - 'Reason', - 'ReasonCode', - 'RuleType', - 'Services', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'UsageUnit', + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorBody", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "Dimension", + "Encryption", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "KeyVaultProperties", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListContainerItem", + "ListContainerItems", + "ListServiceSasResponse", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "MetricSpecification", + "NetworkRuleSet", + "Operation", + "OperationDisplay", + "OperationListResult", + "Resource", + "Restriction", + "SKUCapability", + "ServiceSasParameters", + "ServiceSpecification", + "Sku", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageSkuListResult", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "Bypass", + "CorsRuleAllowedMethodsItem", + "DefaultAction", + "DirectoryServiceOptions", + "Enum16", + "GeoReplicationStatus", + "HttpProtocol", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "KeyPermission", + "KeySource", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseState", + "LeaseStatus", + "ManagementPolicyName", + "MinimumTlsVersion", + "Permissions", + "ProvisioningState", + "PublicAccess", + "Reason", + "ReasonCode", + "RuleType", + "Services", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py index b023f8cecd18..f7b10a00f6d5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,63 +8,69 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2019_04_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2019_04_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2019_04_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2019_04_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -80,33 +87,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2019_04_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2019_04_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2019_04_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2019_04_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -117,42 +125,42 @@ def __init__( self.key_to_sign = key_to_sign -class ActiveDirectoryProperties(msrest.serialization.Model): +class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). All required parameters must be populated in order to send to Azure. - :ivar domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :vartype domain_name: str - :ivar net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. Required. :vartype net_bios_domain_name: str - :ivar forest_name: Required. Specifies the Active Directory forest to get. + :ivar forest_name: Specifies the Active Directory forest to get. Required. :vartype forest_name: str - :ivar domain_guid: Required. Specifies the domain GUID. + :ivar domain_guid: Specifies the domain GUID. Required. :vartype domain_guid: str - :ivar domain_sid: Required. Specifies the security identifier (SID). + :ivar domain_sid: Specifies the security identifier (SID). Required. :vartype domain_sid: str - :ivar azure_storage_sid: Required. Specifies the security identifier (SID) for Azure Storage. + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. Required. :vartype azure_storage_sid: str """ _validation = { - 'domain_name': {'required': True}, - 'net_bios_domain_name': {'required': True}, - 'forest_name': {'required': True}, - 'domain_guid': {'required': True}, - 'domain_sid': {'required': True}, - 'azure_storage_sid': {'required': True}, + "domain_name": {"required": True}, + "net_bios_domain_name": {"required": True}, + "forest_name": {"required": True}, + "domain_guid": {"required": True}, + "domain_sid": {"required": True}, + "azure_storage_sid": {"required": True}, } _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'net_bios_domain_name': {'key': 'netBiosDomainName', 'type': 'str'}, - 'forest_name': {'key': 'forestName', 'type': 'str'}, - 'domain_guid': {'key': 'domainGuid', 'type': 'str'}, - 'domain_sid': {'key': 'domainSid', 'type': 'str'}, - 'azure_storage_sid': {'key': 'azureStorageSid', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, } def __init__( @@ -167,22 +175,22 @@ def __init__( **kwargs ): """ - :keyword domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :paramtype domain_name: str - :keyword net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. Required. :paramtype net_bios_domain_name: str - :keyword forest_name: Required. Specifies the Active Directory forest to get. + :keyword forest_name: Specifies the Active Directory forest to get. Required. :paramtype forest_name: str - :keyword domain_guid: Required. Specifies the domain GUID. + :keyword domain_guid: Specifies the domain GUID. Required. :paramtype domain_guid: str - :keyword domain_sid: Required. Specifies the security identifier (SID). + :keyword domain_sid: Specifies the security identifier (SID). Required. :paramtype domain_sid: str - :keyword azure_storage_sid: Required. Specifies the security identifier (SID) for Azure - Storage. + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + Required. :paramtype azure_storage_sid: str """ - super(ActiveDirectoryProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.net_bios_domain_name = net_bios_domain_name self.forest_name = forest_name @@ -191,7 +199,7 @@ def __init__( self.azure_storage_sid = azure_storage_sid -class Resource(msrest.serialization.Model): +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. @@ -207,24 +215,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -248,36 +252,32 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): +class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Known values - are: "None", "AADDS", "AD". + :ivar directory_service_options: Indicates the directory service used. Required. Known values + are: "None", "AADDS", and "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2019_04_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -286,12 +286,12 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): """ _validation = { - 'directory_service_options': {'required': True}, + "directory_service_options": {"required": True}, } _attribute_map = { - 'directory_service_options': {'key': 'directoryServiceOptions', 'type': 'str'}, - 'active_directory_properties': {'key': 'activeDirectoryProperties', 'type': 'ActiveDirectoryProperties'}, + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, } def __init__( @@ -302,20 +302,20 @@ def __init__( **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Known - values are: "None", "AADDS", "AD". + :keyword directory_service_options: Indicates the directory service used. Required. Known + values are: "None", "AADDS", and "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2019_04_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. :paramtype active_directory_properties: ~azure.mgmt.storage.v2019_04_01.models.ActiveDirectoryProperties """ - super(AzureFilesIdentityBasedAuthentication, self).__init__(**kwargs) + super().__init__(**kwargs) self.directory_service_options = directory_service_options self.active_directory_properties = active_directory_properties -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -331,17 +331,18 @@ class BlobContainer(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2019_04_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -362,35 +363,35 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -402,12 +403,12 @@ def __init__( ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2019_04_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_access = public_access self.last_modified_time = None self.lease_status = None @@ -420,7 +421,7 @@ def __init__( self.has_immutability_policy = None -class BlobServiceItems(msrest.serialization.Model): +class BlobServiceItems(_serialization.Model): """BlobServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -430,20 +431,16 @@ class BlobServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobServiceProperties]'}, + "value": {"key": "value", "type": "[BlobServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -477,20 +474,20 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'automatic_snapshot_policy_enabled': {'key': 'properties.automaticSnapshotPolicyEnabled', 'type': 'bool'}, - 'change_feed': {'key': 'properties.changeFeed', 'type': 'ChangeFeed'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, } def __init__( @@ -520,7 +517,7 @@ def __init__( :keyword change_feed: The blob service properties for change feed events. :paramtype change_feed: ~azure.mgmt.storage.v2019_04_01.models.ChangeFeed """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors self.default_service_version = default_service_version self.delete_retention_policy = delete_retention_policy @@ -528,7 +525,7 @@ def __init__( self.change_feed = change_feed -class ChangeFeed(msrest.serialization.Model): +class ChangeFeed(_serialization.Model): """The blob service properties for change feed events. :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. @@ -536,24 +533,19 @@ class ChangeFeed(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. :paramtype enabled: bool """ - super(ChangeFeed, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -563,7 +555,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2019_04_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -571,30 +563,26 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -611,10 +599,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -639,50 +627,50 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2019_04_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2019_04_01.models.CorsRuleAllowedMethodsItem] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -696,24 +684,24 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2019_04_01.models.CorsRuleAllowedMethodsItem] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -721,7 +709,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -730,31 +718,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2019_04_01.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -762,101 +745,85 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DateAfterCreation(msrest.serialization.Model): +class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. All required parameters must be populated in order to send to Azure. - :ivar days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :vartype days_after_creation_greater_than: float """ _validation = { - 'days_after_creation_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, } - def __init__( - self, - *, - days_after_creation_greater_than: float, - **kwargs - ): + def __init__(self, *, days_after_creation_greater_than: float, **kwargs): """ - :keyword days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :paramtype days_after_creation_greater_than: float """ - super(DateAfterCreation, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_creation_greater_than = days_after_creation_greater_than -class DateAfterModification(msrest.serialization.Model): +class DateAfterModification(_serialization.Model): """Object to define the number of days after last modification. All required parameters must be populated in order to send to Azure. - :ivar days_after_modification_greater_than: Required. Value indicating the age in days after - last modification. + :ivar days_after_modification_greater_than: Value indicating the age in days after last + modification. Required. :vartype days_after_modification_greater_than: float """ _validation = { - 'days_after_modification_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, + "days_after_modification_greater_than": {"required": True, "minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'float'}, + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, } - def __init__( - self, - *, - days_after_modification_greater_than: float, - **kwargs - ): + def __init__(self, *, days_after_modification_greater_than: float, **kwargs): """ - :keyword days_after_modification_greater_than: Required. Value indicating the age in days after - last modification. + :keyword days_after_modification_greater_than: Value indicating the age in days after last + modification. Required. :paramtype days_after_modification_greater_than: float """ - super(DateAfterModification, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_modification_greater_than = days_after_modification_greater_than -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The blob service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled for the Blob service. @@ -867,21 +834,15 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled for the Blob service. :paramtype enabled: bool @@ -889,12 +850,12 @@ def __init__( minimum specified value can be 1 and the maximum value can be 365. :paramtype days: int """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -904,51 +865,45 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2019_04_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2019_04_01.models.KeySource :ivar key_vault_properties: Properties provided by key vault. :vartype key_vault_properties: ~azure.mgmt.storage.v2019_04_01.models.KeyVaultProperties """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, } def __init__( @@ -962,20 +917,20 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2019_04_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2019_04_01.models.KeySource :keyword key_vault_properties: Properties provided by key vault. :paramtype key_vault_properties: ~azure.mgmt.storage.v2019_04_01.models.KeyVaultProperties """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.key_vault_properties = key_vault_properties -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -990,31 +945,26 @@ class EncryptionService(msrest.serialization.Model): """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is stored. :paramtype enabled: bool """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. Variables are only populated by the server, and will be ignored when sending a request. @@ -1030,15 +980,15 @@ class EncryptionServices(msrest.serialization.Model): """ _validation = { - 'table': {'readonly': True}, - 'queue': {'readonly': True}, + "table": {"readonly": True}, + "queue": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -1054,14 +1004,14 @@ def __init__( :keyword file: The encryption function of the file storage service. :paramtype file: ~azure.mgmt.storage.v2019_04_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = None self.queue = None -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1081,30 +1031,26 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Endpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -1113,7 +1059,7 @@ def __init__( self.dfs = None -class FileServiceItems(msrest.serialization.Model): +class FileServiceItems(_serialization.Model): """FileServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -1123,20 +1069,16 @@ class FileServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileServiceProperties]'}, + "value": {"key": "value", "type": "[FileServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -1160,31 +1102,26 @@ class FileServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the File service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the File service. :paramtype cors: ~azure.mgmt.storage.v2019_04_01.models.CorsRules """ - super(FileServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors @@ -1213,31 +1150,25 @@ class FileShare(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 5120, 'minimum': 1}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 5120, "minimum": 1}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - share_quota: Optional[int] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, **kwargs): """ :keyword metadata: A name-value pair to associate with the share as metadata. :paramtype metadata: dict[str, str] @@ -1245,7 +1176,7 @@ def __init__( less than or equal to 5TB (5120). :paramtype share_quota: int """ - super(FileShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -1276,31 +1207,25 @@ class FileShareItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 5120, 'minimum': 1}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 5120, "minimum": 1}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - share_quota: Optional[int] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, share_quota: Optional[int] = None, **kwargs): """ :keyword metadata: A name-value pair to associate with the share as metadata. :paramtype metadata: dict[str, str] @@ -1308,13 +1233,13 @@ def __init__( less than or equal to 5TB (5120). :paramtype share_quota: int """ - super(FileShareItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota -class FileShareItems(msrest.serialization.Model): +class FileShareItems(_serialization.Model): """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. Variables are only populated by the server, and will be ignored when sending a request. @@ -1327,27 +1252,23 @@ class FileShareItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileShareItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileShareItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -1356,7 +1277,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2019_04_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -1369,30 +1290,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -1403,31 +1320,27 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Has constant value: "SystemAssigned". + :ivar type: The identity type. Required. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True, 'constant': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "SystemAssigned" - def __init__( - self, - **kwargs - ): - """ - """ - super(Identity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -1449,49 +1362,47 @@ class ImmutabilityPolicy(AzureEntityResource): :vartype type: str :ivar etag: Resource Etag. :vartype etag: str - :ivar immutability_period_since_creation_in_days: Required. The immutability period for the - blobs in the container since the policy creation, in days. + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. Required. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicyState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'required': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "immutability_period_since_creation_in_days": {"required": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, } - def __init__( - self, - *, - immutability_period_since_creation_in_days: int, - **kwargs - ): + def __init__(self, *, immutability_period_since_creation_in_days: int, **kwargs): """ - :keyword immutability_period_since_creation_in_days: Required. The immutability period for the - blobs in the container since the policy creation, in days. + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. Required. :paramtype immutability_period_since_creation_in_days: int """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -1504,84 +1415,74 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicyState """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, } - def __init__( - self, - *, - immutability_period_since_creation_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, immutability_period_since_creation_in_days: Optional[int] = None, **kwargs): """ :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. :paramtype immutability_period_since_creation_in_days: int """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. :ivar key_name: The name of KeyVault key. @@ -1593,9 +1494,9 @@ class KeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, } def __init__( @@ -1614,19 +1515,19 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -1642,15 +1543,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -1664,8 +1565,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -1679,7 +1580,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -1687,7 +1588,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -1698,17 +1599,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -1716,12 +1611,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -1733,38 +1628,33 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, } - def __init__( - self, - *, - tags: List[str], - **kwargs - ): + def __init__(self, *, tags: List[str], **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -1774,35 +1664,30 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2019_04_01.models.TagProperty] """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, } - def __init__( - self, - *, - tags: Optional[List["_models.TagProperty"]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[List["_models.TagProperty"]] = None, **kwargs): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2019_04_01.models.TagProperty] """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1812,24 +1697,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -1845,17 +1726,18 @@ class ListContainerItem(AzureEntityResource): :ivar etag: Resource Etag. :vartype etag: str :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2019_04_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2019_04_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -1876,35 +1758,35 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -1916,12 +1798,12 @@ def __init__( ): """ :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2019_04_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.public_access = public_access self.last_modified_time = None self.lease_status = None @@ -1934,7 +1816,7 @@ def __init__( self.has_immutability_policy = None -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. Variables are only populated by the server, and will be ignored when sending a request. @@ -1947,27 +1829,23 @@ class ListContainerItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListContainerItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1977,20 +1855,16 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None @@ -2015,37 +1889,32 @@ class ManagementPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.ManagementPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :paramtype policy: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicySchema """ - super(ManagementPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.policy = policy -class ManagementPolicyAction(msrest.serialization.Model): +class ManagementPolicyAction(_serialization.Model): """Actions are applied to the filtered blobs when the execution condition is met. :ivar base_blob: The management policy action for base blob. @@ -2055,8 +1924,8 @@ class ManagementPolicyAction(msrest.serialization.Model): """ _attribute_map = { - 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, - 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, } def __init__( @@ -2072,12 +1941,12 @@ def __init__( :keyword snapshot: The management policy action for snapshot. :paramtype snapshot: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicySnapShot """ - super(ManagementPolicyAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_blob = base_blob self.snapshot = snapshot -class ManagementPolicyBaseBlob(msrest.serialization.Model): +class ManagementPolicyBaseBlob(_serialization.Model): """Management policy action for base blob. :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot @@ -2091,9 +1960,9 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, - 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, } def __init__( @@ -2114,30 +1983,30 @@ def __init__( :keyword delete: The function to delete the blob. :paramtype delete: ~azure.mgmt.storage.v2019_04_01.models.DateAfterModification """ - super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class ManagementPolicyDefinition(msrest.serialization.Model): +class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. All required parameters must be populated in order to send to Azure. - :ivar actions: Required. An object that defines the action set. + :ivar actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyAction :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyFilter """ _validation = { - 'actions': {'required': True}, + "actions": {"required": True}, } _attribute_map = { - 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, - 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, } def __init__( @@ -2148,81 +2017,75 @@ def __init__( **kwargs ): """ - :keyword actions: Required. An object that defines the action set. + :keyword actions: An object that defines the action set. Required. :paramtype actions: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyAction :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyFilter """ - super(ManagementPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.filters = filters -class ManagementPolicyFilter(msrest.serialization.Model): +class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Only blockBlob is supported. + :ivar blob_types: An array of predefined enum values. Only blockBlob is supported. Required. :vartype blob_types: list[str] """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, } - def __init__( - self, - *, - blob_types: List[str], - prefix_match: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, blob_types: List[str], prefix_match: Optional[List[str]] = None, **kwargs): """ :keyword prefix_match: An array of strings for prefixes to be match. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Only blockBlob is supported. + :keyword blob_types: An array of predefined enum values. Only blockBlob is supported. Required. :paramtype blob_types: list[str] """ - super(ManagementPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types -class ManagementPolicyRule(msrest.serialization.Model): +class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. :ivar enabled: Rule is enabled if set to true. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" :vartype type: str or ~azure.mgmt.storage.v2019_04_01.models.RuleType - :ivar definition: Required. An object that defines the Lifecycle rule. + :ivar definition: An object that defines the Lifecycle rule. Required. :vartype definition: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyDefinition """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - 'definition': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, } def __init__( @@ -2237,55 +2100,52 @@ def __init__( """ :keyword enabled: Rule is enabled if set to true. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" :paramtype type: str or ~azure.mgmt.storage.v2019_04_01.models.RuleType - :keyword definition: Required. An object that defines the Lifecycle rule. + :keyword definition: An object that defines the Lifecycle rule. Required. :paramtype definition: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyDefinition """ - super(ManagementPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.type = type self.definition = definition -class ManagementPolicySchema(msrest.serialization.Model): +class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. All required parameters must be populated in order to send to Azure. - :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :vartype rules: list[~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyRule] """ _validation = { - 'rules': {'required': True}, + "rules": {"required": True}, } _attribute_map = { - 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, } - def __init__( - self, - *, - rules: List["_models.ManagementPolicyRule"], - **kwargs - ): + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): """ - :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :paramtype rules: list[~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyRule] """ - super(ManagementPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.rules = rules -class ManagementPolicySnapShot(msrest.serialization.Model): +class ManagementPolicySnapShot(_serialization.Model): """Management policy action for snapshot. :ivar delete: The function to delete the blob snapshot. @@ -2293,24 +2153,19 @@ class ManagementPolicySnapShot(msrest.serialization.Model): """ _attribute_map = { - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } - def __init__( - self, - *, - delete: Optional["_models.DateAfterCreation"] = None, - **kwargs - ): + def __init__(self, *, delete: Optional["_models.DateAfterCreation"] = None, **kwargs): """ :keyword delete: The function to delete the blob snapshot. :paramtype delete: ~azure.mgmt.storage.v2019_04_01.models.DateAfterCreation """ - super(ManagementPolicySnapShot, self).__init__(**kwargs) + super().__init__(**kwargs) self.delete = delete -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -2334,15 +2189,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -2379,7 +2234,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -2391,41 +2246,41 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2019_04_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2019_04_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2019_04_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2019_04_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs @@ -2434,25 +2289,25 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2019_04_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: list[~azure.mgmt.storage.v2019_04_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2019_04_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2019_04_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules self.default_action = default_action -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -2466,10 +2321,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -2491,14 +2346,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2019_04_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -2512,10 +2367,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -2537,14 +2392,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -2552,24 +2407,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2019_04_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -2582,59 +2432,54 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2019_04_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2019_04_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2019_04_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2019_04_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2019_04_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -2666,29 +2511,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, - } - - _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, + } + + _attribute_map = { + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -2715,20 +2560,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2019_04_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2019_04_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2019_04_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -2759,7 +2605,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -2780,7 +2626,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -2789,43 +2635,38 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2019_04_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Known values are: + :ivar name: Gets or sets the SKU name. Required for account creation; optional for update. Note + that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2019_04_01.models.SkuName - :ivar tier: Gets the SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: Gets the SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2019_04_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -2839,22 +2680,22 @@ class Sku(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -2865,16 +2706,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. Gets or sets the SKU name. Required for account creation; optional for - update. Note that in older versions, SKU name was called accountType. Known values are: + :keyword name: Gets or sets the SKU name. Required for account creation; optional for update. + Note that in older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2019_04_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2019_04_01.models.Restriction] """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -2884,7 +2725,7 @@ def __init__( self.restrictions = restrictions -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -2897,22 +2738,18 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None @@ -2932,46 +2769,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2986,19 +2817,19 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2019_04_01.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2019_04_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2019_04_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -3007,7 +2838,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2019_04_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -3019,7 +2850,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2019_04_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -3033,7 +2864,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2019_04_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -3051,7 +2882,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in @@ -3059,7 +2890,7 @@ class StorageAccount(TrackedResource): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3069,63 +2900,66 @@ class StorageAccount(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -3141,9 +2975,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2019_04_01.models.Identity @@ -3157,7 +2991,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers @@ -3165,7 +2999,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3173,7 +3007,7 @@ def __init__( default value is null, which is equivalent to true. :paramtype allow_shared_key_access: bool """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -3201,65 +3035,60 @@ def __init__( self.allow_shared_key_access = allow_shared_key_access -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2019_04_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2019_04_01.models.Identity @@ -3273,7 +3102,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2019_04_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -3285,7 +3114,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in @@ -3293,7 +3122,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3303,28 +3132,31 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, } def __init__( @@ -3349,20 +3181,20 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2019_04_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2019_04_01.models.Identity @@ -3376,7 +3208,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2019_04_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_04_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -3388,7 +3220,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers @@ -3396,7 +3228,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3404,7 +3236,7 @@ def __init__( default value is null, which is equivalent to true. :paramtype allow_shared_key_access: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -3423,7 +3255,7 @@ def __init__( self.allow_shared_key_access = allow_shared_key_access -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -3433,35 +3265,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2019_04_01.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -3472,24 +3300,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -3502,75 +3326,66 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2, kerb1, kerb2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2, kerb1, kerb2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2019_04_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2019_04_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -3580,7 +3395,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2019_04_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -3591,7 +3406,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2019_04_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in @@ -3599,7 +3414,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3609,20 +3424,23 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, } def __init__( @@ -3649,16 +3467,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2019_04_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2019_04_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2019_04_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -3668,7 +3486,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2019_04_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_04_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -3680,7 +3498,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2019_04_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_04_01.models.LargeFileSharesState :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers @@ -3688,7 +3506,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -3696,7 +3514,7 @@ def __init__( default value is null, which is equivalent to true. :paramtype allow_shared_key_access: bool """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -3713,7 +3531,7 @@ def __init__( self.allow_shared_key_access = allow_shared_key_access -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -3723,24 +3541,20 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Sku]'}, + "value": {"key": "value", "type": "[Sku]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3758,28 +3572,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -3787,13 +3597,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -3810,30 +3620,26 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -3842,13 +3648,13 @@ def __init__( self.upn = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2019_04_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -3859,33 +3665,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -3893,24 +3695,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2019_04_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -3922,72 +3719,68 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2019_04_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2019_04_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py index 85dc99f0210b..c43947324d9b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,6 +25,7 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -36,7 +37,9 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CorsRuleAllowedMethodsItem.""" DELETE = "DELETE" GET = "GET" @@ -46,21 +49,28 @@ class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): OPTIONS = "OPTIONS" PUT = "PUT" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the directory service used. - """ + """Indicates the directory service used.""" NONE = "None" AADDS = "AADDS" AD = "AD" + +class Enum16(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum16.""" + + DEFAULT = "default" + + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -73,20 +83,21 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -96,24 +107,25 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -121,22 +133,23 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - """ + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -146,9 +159,9 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -156,17 +169,20 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. @@ -176,6 +192,7 @@ class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -190,22 +207,23 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -214,6 +232,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -224,12 +243,13 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Lifecycle - """ + """The valid value is Lifecycle.""" LIFECYCLE = "Lifecycle" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -240,6 +260,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -250,6 +271,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -260,6 +282,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets the SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -274,16 +297,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the SKU tier. This is based on the SKU name. - """ + """Gets the SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "provisioning" DEPROVISIONING = "deprovisioning" @@ -291,9 +314,9 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/__init__.py index 12917503aa75..912b016c2b9e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/__init__.py @@ -19,16 +19,17 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_operations.py index 943dfb607adb..0323b32494e6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_containers_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -40,355 +54,301 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip_token is not None: - _params['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum16], subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum16], subscription_id: str, *, if_match: Optional[str] = None, @@ -397,43 +357,42 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum16], subscription_id: str, *, if_match: str, @@ -442,36 +401,34 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -486,34 +443,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -523,93 +479,79 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class BlobContainersOperations: """ @@ -630,7 +572,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -640,16 +581,16 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.ListContainerItems]: + ) -> Iterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param skip_token: Optional. Continuation token for the list operation. Default value is None. :type skip_token: str @@ -660,32 +601,36 @@ def list( listed. 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 ListContainerItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -693,18 +638,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip_token=skip_token, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -721,10 +665,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -734,19 +676,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -754,37 +696,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -794,7 +823,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -802,10 +832,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -813,63 +842,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -879,7 +994,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -887,72 +1003,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -960,72 +1072,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1033,10 +1141,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1046,16 +1153,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1063,37 +1171,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1103,7 +1298,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1111,70 +1307,155 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_04_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -1184,7 +1465,8 @@ def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1192,51 +1474,55 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum16], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -1244,44 +1530,144 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum16], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum16], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1289,10 +1675,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1300,17 +1685,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1318,6 +1702,7 @@ def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum16], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1325,52 +1710,52 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1378,10 +1763,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1389,17 +1773,16 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( @@ -1407,6 +1790,7 @@ def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum16], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1416,52 +1800,52 @@ def delete_immutability_policy( container after deleting all blobs inside the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1469,10 +1853,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1480,71 +1863,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1552,10 +1931,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1563,19 +1941,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1583,6 +1960,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1590,56 +1969,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1647,10 +2125,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1658,65 +2135,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequest + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1726,7 +2289,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1734,22 +2298,20 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_operations.py index 27ac55976532..2302ec2f80b0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_blob_services_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,134 +27,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum16], subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum16], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -168,47 +170,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -216,15 +220,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -241,10 +247,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -254,66 +258,149 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum16], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum16], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum16], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -321,72 +408,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum16], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -394,22 +476,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_operations.py index 43cd349cf9e3..99b9a1efbb60 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum16], subscription_id: str, - *, - json: Optional[_models.FileServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum16], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class FileServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +211,162 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum16], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum16], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum16], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +374,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum16], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_04_01.models.Enum16 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +442,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_operations.py index 333d516521e6..3329c58ff9ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_file_shares_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -40,210 +54,180 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if skip_token is not None: - _params['$skipToken'] = _SERIALIZER.query("skip_token", skip_token, 'str') + _params["$skipToken"] = _SERIALIZER.query("skip_token", skip_token, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class FileSharesOperations: """ @@ -264,7 +248,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -274,15 +257,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.FileShareItems]: + ) -> Iterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param skip_token: Optional. Continuation token for the list operation. Default value is None. :type skip_token: str @@ -293,32 +276,36 @@ def list( listed. 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 FileShareItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, skip_token=skip_token, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -326,18 +313,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - skip_token=skip_token, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -354,10 +340,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -367,19 +351,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -387,37 +371,124 @@ def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, @@ -427,7 +498,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -435,10 +507,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -446,63 +517,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2019_04_01.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -512,7 +669,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -520,72 +678,66 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - share_name: str, - **kwargs: Any - ) -> _models.FileShare: + def get(self, resource_group_name: str, account_name: str, share_name: str, **kwargs: Any) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -593,72 +745,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - share_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, share_name: str, **kwargs: Any ) -> None: """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -666,10 +814,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -679,5 +826,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_operations.py index c2162acbc90f..d29b39878c7e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,130 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,52 +169,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -215,78 +223,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy 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 - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -294,71 +384,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_04_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -366,10 +456,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +468,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_operations.py index 9578e48939a7..312112d609ff 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_operations.py index 0ab17ac0b640..beccfacf33e1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Sku"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Sku or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.Sku] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_operations.py index ae6813ca3515..f5a35aae00b1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +29,110 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,153 +140,129 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "geoReplicationStats", + expand: Literal["geoReplicationStats"] = "geoReplicationStats", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -304,235 +270,202 @@ def build_list_keys_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "kerb", + expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) def build_revoke_user_delegation_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: """ @@ -553,45 +486,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2019_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -599,55 +585,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -655,10 +649,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -667,22 +660,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -691,14 +685,17 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCreateParameters + :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 @@ -710,20 +707,98 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -731,79 +806,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -811,10 +881,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -824,15 +893,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[str] = "geoReplicationStats", + expand: Literal["geoReplicationStats"] = "geoReplicationStats", **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -840,40 +908,42 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats. - Known values are "geoReplicationStats" or None. Default value is "geoReplicationStats". + Known values are "geoReplicationStats" and None. Default value is "geoReplicationStats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -881,32 +951,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -919,32 +989,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -953,7 +1108,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -961,58 +1117,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1020,13 +1173,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1043,10 +1200,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1056,49 +1211,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1106,14 +1257,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1130,10 +1284,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1143,57 +1295,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1201,65 +1349,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2019_04_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1268,7 +1489,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1276,63 +1498,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1341,7 +1636,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1349,63 +1645,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ServiceSasParameters + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_04_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_04_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1414,7 +1781,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1422,50 +1790,47 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1473,10 +1838,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1486,26 +1850,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1517,95 +1875,89 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1613,10 +1965,9 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1626,5 +1977,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_operations.py index ff9c20826474..28cc48aba7dc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_04_01/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,41 +87,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_04_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-04-01")) # type: Literal["2019-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -122,14 +128,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -146,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -159,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_configuration.py index e0b46c23cefb..d1890e6d686d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-06-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", "2019-06-01") # type: Literal["2019-06-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json index a24a8684a71d..dc3b203995d4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -116,4 +116,4 @@ "table_services": "TableServicesOperations", "table": "TableOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py index 91bc15a84877..e99cb9c57ad3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_storage_management_client.py @@ -9,20 +9,39 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -67,9 +86,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2019_06_01.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2019_06_01.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -87,25 +106,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -124,37 +139,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -163,7 +157,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_configuration.py index 570411bf22fd..d957d7fc8a87 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2019-06-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2019-06-01") # type: str + api_version = kwargs.pop("api_version", "2019-06-01") # type: Literal["2019-06-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py index 4310862f67c8..cc2c317077c9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/_storage_management_client.py @@ -9,20 +9,39 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -69,9 +88,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2019_06_01.aio.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2019_06_01.aio.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -89,25 +108,21 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -126,37 +141,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -165,7 +159,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/__init__.py index 25083f1873e4..ffe96543da2a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/__init__.py @@ -28,25 +28,26 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_operations.py index 5d4c354b415d..4e972705702a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_containers_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -43,7 +72,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,18 +79,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListContainerItems]: + ) -> AsyncIterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -71,36 +99,40 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2019_06_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -108,18 +140,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -136,10 +167,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,19 +178,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -169,37 +198,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -209,7 +325,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -217,10 +334,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -228,63 +344,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -294,7 +496,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -302,72 +505,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -375,72 +574,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -448,10 +643,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -461,16 +655,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -478,37 +673,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -518,7 +800,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -526,70 +809,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -599,7 +967,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -607,51 +976,55 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum27], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -659,44 +1032,144 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum27], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum27], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -704,10 +1177,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -715,17 +1187,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -733,6 +1204,7 @@ async def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum27], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -740,52 +1212,52 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -793,10 +1265,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -804,17 +1275,16 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -822,6 +1292,7 @@ async def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum27], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -831,52 +1302,52 @@ async def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -884,10 +1355,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -895,71 +1365,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -967,10 +1433,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -978,19 +1443,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -998,6 +1462,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1005,56 +1471,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1062,10 +1627,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1073,65 +1637,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1141,7 +1791,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1149,22 +1800,20 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_operations.py index f9217384d9c1..570544e1206c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_inventory_policies_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_inventory_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._blob_inventory_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobInventoryPoliciesOperations: """ .. warning:: @@ -43,52 +63,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +117,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,68 +127,151 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy 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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -176,10 +279,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,61 +289,62 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -249,10 +352,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -263,51 +365,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -315,15 +416,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -340,10 +443,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -354,8 +455,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_operations.py index 3e0316426304..3437979e9199 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_blob_services_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -43,48 +62,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,66 +150,149 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum27], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum27], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum27], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -197,72 +300,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum27], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -270,22 +368,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_operations.py index 4d1ab9dfafe0..2e86188afa89 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_encryption_scopes_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._encryption_scopes_operations import build_get_request, build_list_request, build_patch_request, build_put_request -T = TypeVar('T') +from ...operations._encryption_scopes_operations import ( + build_get_request, + build_list_request, + build_patch_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EncryptionScopesOperations: """ .. warning:: @@ -43,14 +63,15 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -58,47 +79,137 @@ async def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -106,10 +217,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -118,73 +228,160 @@ async def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace_async + @overload async def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +389,9 @@ async def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,62 +399,59 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -266,10 +459,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -277,58 +469,57 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EncryptionScopeListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) + :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -336,15 +527,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -361,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -374,8 +565,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_operations.py index 44f02ad0f997..a5ed4adacee6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +102,162 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum27], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum27], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum27], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +265,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum27], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +333,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_operations.py index 90ee26af22d8..97e9a98091ba 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_file_shares_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_shares_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_restore_request, build_update_request -T = TypeVar('T') +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_restore_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileSharesOperations: """ .. warning:: @@ -43,7 +65,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,17 +72,17 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[str] = "deleted", + expand: Literal["deleted"] = "deleted", **kwargs: Any - ) -> AsyncIterable[_models.FileShareItems]: + ) -> AsyncIterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -70,36 +91,40 @@ def list( listed. Default value is None. :type filter: str :param expand: Optional, used to expand the properties within share's properties. Known values - are "deleted" or None. Default value is "deleted". + are "deleted" and None. Default value is "deleted". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) + :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -107,18 +132,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -135,10 +159,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -148,19 +170,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -168,37 +190,124 @@ async def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, @@ -208,7 +317,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -216,10 +326,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -227,63 +336,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -293,7 +488,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -301,25 +497,23 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def get( @@ -327,51 +521,53 @@ async def get( resource_group_name: str, account_name: str, share_name: str, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", **kwargs: Any ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Known values - are "stats" or None. Default value is "stats". + are "stats" and None. Default value is "stats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -379,72 +575,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - share_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, share_name: str, **kwargs: Any ) -> None: """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -452,10 +644,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -465,52 +656,135 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace_async + @overload async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2019_06_01.models.DeletedShare + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2019_06_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -520,7 +794,8 @@ async def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -528,10 +803,9 @@ async def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -541,5 +815,4 @@ async def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_operations.py index 6274254e6b76..538c636d4744 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,52 +59,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -94,78 +113,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy + :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: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -173,71 +274,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -245,10 +346,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -258,5 +358,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_operations.py index 97aa09894329..338e8af105e6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_object_replication_policies_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._object_replication_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._object_replication_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ObjectReplicationPoliciesOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,56 +152,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -189,10 +205,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -200,68 +215,150 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy 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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -269,10 +366,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,60 +376,57 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -341,10 +434,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -355,5 +447,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_operations.py index 5034dfa03eed..5f20823bb542 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_endpoint_connections_operations.py index 430304bb2ba2..7622e6cd4d2b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request, build_get_request, build_list_request, build_put_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +151,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +204,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +214,148 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection 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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +363,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +373,57 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +431,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,5 +444,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_link_resources_operations.py index bb4a979afe70..d83b5efab3c1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,46 +55,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -88,22 +100,20 @@ async def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_operations.py index 7cc80ce86492..711f7eed54c9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._queue_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueOperations: """ .. warning:: @@ -43,60 +64,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue 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 - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -104,79 +210,163 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -184,72 +374,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -257,72 +443,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -330,10 +512,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -343,8 +524,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -354,15 +534,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListQueueResource]: + ) -> AsyncIterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -371,32 +551,36 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) + :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -404,17 +588,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -431,10 +615,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -444,8 +626,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_operations.py index a38f3f21e73c..b433d95e4c75 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_queue_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._queue_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +102,163 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum27], parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :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: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum27], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum27], + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties 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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +266,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum27], **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +334,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_operations.py index 5db29af2be8e..7caf5cadc4d1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) + :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +95,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +133,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_operations.py index cffa49d6fedf..adcc08783a51 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,31 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_restore_blob_ranges_request_initial, build_revoke_user_delegation_keys_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_restore_blob_ranges_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +75,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2019_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2019_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +174,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +238,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +249,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +274,17 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCreateParameters + :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 @@ -203,20 +297,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCreateParameters 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. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +398,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +473,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,15 +485,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -333,40 +500,43 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2019_06_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,32 +544,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -412,32 +582,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -446,7 +701,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -454,58 +710,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -513,13 +767,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -536,10 +794,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,49 +805,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -599,14 +854,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -623,10 +881,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -636,57 +892,53 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -694,65 +946,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2019_06_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -761,7 +1086,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -769,63 +1095,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -834,7 +1233,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -842,63 +1242,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -907,7 +1378,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -915,50 +1387,47 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -966,10 +1435,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -979,26 +1447,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1010,85 +1472,90 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1096,10 +1563,9 @@ async def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1107,38 +1573,81 @@ async def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - @distributed_trace_async + @overload async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1151,20 +1660,55 @@ async def begin_restore_blob_ranges( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobRestoreParameters 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. + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1172,79 +1716,76 @@ async def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1252,10 +1793,9 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1265,5 +1805,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_operations.py index 4f5be6f6a2d6..29d4c6c0b650 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._table_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableOperations: """ .. warning:: @@ -43,52 +64,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -96,71 +114,67 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -168,71 +182,65 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,71 +248,67 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -312,10 +316,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -325,50 +328,47 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -376,15 +376,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -401,10 +403,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -414,8 +414,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_operations.py index 7ceb85c149ee..865b2eb89e84 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_table_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._table_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +102,163 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum27], parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :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: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum27], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum27], + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties 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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +266,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum27], **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +334,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_operations.py index 1e104d6d03cf..1c4a437cf6e3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,42 +57,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2019_06_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -85,14 +98,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -109,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -122,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/__init__.py index c297898e38e9..b004f2ba80b7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/__init__.py @@ -125,229 +125,229 @@ from ._models_py3 import UsageName from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountStatus, - BlobInventoryPolicyName, - BlobRestoreProgressStatus, - Bypass, - CorsRuleAllowedMethodsItem, - CreatedByType, - DefaultAction, - DirectoryServiceOptions, - EnabledProtocols, - EncryptionScopeSource, - EncryptionScopeState, - GeoReplicationStatus, - HttpProtocol, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - InventoryRuleType, - KeyPermission, - KeySource, - KeyType, - Kind, - LargeFileSharesState, - LeaseContainerRequestAction, - LeaseDuration, - LeaseState, - LeaseStatus, - ListContainersInclude, - ManagementPolicyName, - MinimumTlsVersion, - Name, - Permissions, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisioningState, - PublicAccess, - Reason, - ReasonCode, - RootSquashType, - RoutingChoice, - RuleType, - Services, - ShareAccessTier, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - StorageAccountExpand, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import BlobInventoryPolicyName +from ._storage_management_client_enums import BlobRestoreProgressStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CorsRuleAllowedMethodsItem +from ._storage_management_client_enums import CreatedByType +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import EnabledProtocols +from ._storage_management_client_enums import EncryptionScopeSource +from ._storage_management_client_enums import EncryptionScopeState +from ._storage_management_client_enums import Enum27 +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import InventoryRuleType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import KeyType +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ListContainersInclude +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Name +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._storage_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RootSquashType +from ._storage_management_client_enums import RoutingChoice +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import ShareAccessTier +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import StorageAccountExpand +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'ActiveDirectoryProperties', - 'AzureEntityResource', - 'AzureFilesIdentityBasedAuthentication', - 'BlobContainer', - 'BlobInventoryPolicy', - 'BlobInventoryPolicyDefinition', - 'BlobInventoryPolicyFilter', - 'BlobInventoryPolicyRule', - 'BlobInventoryPolicySchema', - 'BlobRestoreParameters', - 'BlobRestoreRange', - 'BlobRestoreStatus', - 'BlobServiceItems', - 'BlobServiceProperties', - 'ChangeFeed', - 'CheckNameAvailabilityResult', - 'CloudErrorBody', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DateAfterCreation', - 'DateAfterModification', - 'DeleteRetentionPolicy', - 'DeletedShare', - 'Dimension', - 'Encryption', - 'EncryptionScope', - 'EncryptionScopeKeyVaultProperties', - 'EncryptionScopeListResult', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'ErrorResponse', - 'ErrorResponseBody', - 'FileServiceItems', - 'FileServiceProperties', - 'FileShare', - 'FileShareItem', - 'FileShareItems', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'KeyVaultProperties', - 'LastAccessTimeTrackingPolicy', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListBlobInventoryPolicy', - 'ListContainerItem', - 'ListContainerItems', - 'ListQueue', - 'ListQueueResource', - 'ListQueueServices', - 'ListServiceSasResponse', - 'ListTableResource', - 'ListTableServices', - 'ManagementPolicy', - 'ManagementPolicyAction', - 'ManagementPolicyBaseBlob', - 'ManagementPolicyDefinition', - 'ManagementPolicyFilter', - 'ManagementPolicyRule', - 'ManagementPolicySchema', - 'ManagementPolicySnapShot', - 'ManagementPolicyVersion', - 'MetricSpecification', - 'NetworkRuleSet', - 'ObjectReplicationPolicies', - 'ObjectReplicationPolicy', - 'ObjectReplicationPolicyFilter', - 'ObjectReplicationPolicyRule', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'QueueServiceProperties', - 'Resource', - 'RestorePolicyProperties', - 'Restriction', - 'RoutingPreference', - 'SKUCapability', - 'ServiceSasParameters', - 'ServiceSpecification', - 'Sku', - 'SkuInformation', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountInternetEndpoints', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountMicrosoftEndpoints', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageQueue', - 'StorageSkuListResult', - 'SystemData', - 'Table', - 'TableServiceProperties', - 'TagFilter', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'BlobInventoryPolicyName', - 'BlobRestoreProgressStatus', - 'Bypass', - 'CorsRuleAllowedMethodsItem', - 'CreatedByType', - 'DefaultAction', - 'DirectoryServiceOptions', - 'EnabledProtocols', - 'EncryptionScopeSource', - 'EncryptionScopeState', - 'GeoReplicationStatus', - 'HttpProtocol', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'InventoryRuleType', - 'KeyPermission', - 'KeySource', - 'KeyType', - 'Kind', - 'LargeFileSharesState', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseState', - 'LeaseStatus', - 'ListContainersInclude', - 'ManagementPolicyName', - 'MinimumTlsVersion', - 'Name', - 'Permissions', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'ProvisioningState', - 'PublicAccess', - 'Reason', - 'ReasonCode', - 'RootSquashType', - 'RoutingChoice', - 'RuleType', - 'Services', - 'ShareAccessTier', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'StorageAccountExpand', - 'UsageUnit', + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobInventoryPolicy", + "BlobInventoryPolicyDefinition", + "BlobInventoryPolicyFilter", + "BlobInventoryPolicyRule", + "BlobInventoryPolicySchema", + "BlobRestoreParameters", + "BlobRestoreRange", + "BlobRestoreStatus", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorBody", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "DeletedShare", + "Dimension", + "Encryption", + "EncryptionScope", + "EncryptionScopeKeyVaultProperties", + "EncryptionScopeListResult", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ErrorResponse", + "ErrorResponseBody", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "KeyVaultProperties", + "LastAccessTimeTrackingPolicy", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListBlobInventoryPolicy", + "ListContainerItem", + "ListContainerItems", + "ListQueue", + "ListQueueResource", + "ListQueueServices", + "ListServiceSasResponse", + "ListTableResource", + "ListTableServices", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "ManagementPolicyVersion", + "MetricSpecification", + "NetworkRuleSet", + "ObjectReplicationPolicies", + "ObjectReplicationPolicy", + "ObjectReplicationPolicyFilter", + "ObjectReplicationPolicyRule", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "QueueServiceProperties", + "Resource", + "RestorePolicyProperties", + "Restriction", + "RoutingPreference", + "SKUCapability", + "ServiceSasParameters", + "ServiceSpecification", + "Sku", + "SkuInformation", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountInternetEndpoints", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountMicrosoftEndpoints", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageQueue", + "StorageSkuListResult", + "SystemData", + "Table", + "TableServiceProperties", + "TagFilter", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "BlobInventoryPolicyName", + "BlobRestoreProgressStatus", + "Bypass", + "CorsRuleAllowedMethodsItem", + "CreatedByType", + "DefaultAction", + "DirectoryServiceOptions", + "EnabledProtocols", + "EncryptionScopeSource", + "EncryptionScopeState", + "Enum27", + "GeoReplicationStatus", + "HttpProtocol", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "InventoryRuleType", + "KeyPermission", + "KeySource", + "KeyType", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseState", + "LeaseStatus", + "ListContainersInclude", + "ManagementPolicyName", + "MinimumTlsVersion", + "Name", + "Permissions", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicAccess", + "Reason", + "ReasonCode", + "RootSquashType", + "RoutingChoice", + "RuleType", + "Services", + "ShareAccessTier", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "StorageAccountExpand", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py index 308c14a67347..1e664ecb4bb4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,64 +8,69 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2019_06_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2019_06_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2019_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2019_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -81,33 +87,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2019_06_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2019_06_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2019_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2019_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -118,42 +125,42 @@ def __init__( self.key_to_sign = key_to_sign -class ActiveDirectoryProperties(msrest.serialization.Model): +class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). All required parameters must be populated in order to send to Azure. - :ivar domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :vartype domain_name: str - :ivar net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. Required. :vartype net_bios_domain_name: str - :ivar forest_name: Required. Specifies the Active Directory forest to get. + :ivar forest_name: Specifies the Active Directory forest to get. Required. :vartype forest_name: str - :ivar domain_guid: Required. Specifies the domain GUID. + :ivar domain_guid: Specifies the domain GUID. Required. :vartype domain_guid: str - :ivar domain_sid: Required. Specifies the security identifier (SID). + :ivar domain_sid: Specifies the security identifier (SID). Required. :vartype domain_sid: str - :ivar azure_storage_sid: Required. Specifies the security identifier (SID) for Azure Storage. + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. Required. :vartype azure_storage_sid: str """ _validation = { - 'domain_name': {'required': True}, - 'net_bios_domain_name': {'required': True}, - 'forest_name': {'required': True}, - 'domain_guid': {'required': True}, - 'domain_sid': {'required': True}, - 'azure_storage_sid': {'required': True}, + "domain_name": {"required": True}, + "net_bios_domain_name": {"required": True}, + "forest_name": {"required": True}, + "domain_guid": {"required": True}, + "domain_sid": {"required": True}, + "azure_storage_sid": {"required": True}, } _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'net_bios_domain_name': {'key': 'netBiosDomainName', 'type': 'str'}, - 'forest_name': {'key': 'forestName', 'type': 'str'}, - 'domain_guid': {'key': 'domainGuid', 'type': 'str'}, - 'domain_sid': {'key': 'domainSid', 'type': 'str'}, - 'azure_storage_sid': {'key': 'azureStorageSid', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, } def __init__( @@ -168,22 +175,22 @@ def __init__( **kwargs ): """ - :keyword domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :paramtype domain_name: str - :keyword net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. Required. :paramtype net_bios_domain_name: str - :keyword forest_name: Required. Specifies the Active Directory forest to get. + :keyword forest_name: Specifies the Active Directory forest to get. Required. :paramtype forest_name: str - :keyword domain_guid: Required. Specifies the domain GUID. + :keyword domain_guid: Specifies the domain GUID. Required. :paramtype domain_guid: str - :keyword domain_sid: Required. Specifies the security identifier (SID). + :keyword domain_sid: Specifies the security identifier (SID). Required. :paramtype domain_sid: str - :keyword azure_storage_sid: Required. Specifies the security identifier (SID) for Azure - Storage. + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + Required. :paramtype azure_storage_sid: str """ - super(ActiveDirectoryProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.net_bios_domain_name = net_bios_domain_name self.forest_name = forest_name @@ -192,7 +199,7 @@ def __init__( self.azure_storage_sid = azure_storage_sid -class Resource(msrest.serialization.Model): +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. @@ -208,24 +215,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -249,36 +252,32 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): +class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Known values - are: "None", "AADDS", "AD". + :ivar directory_service_options: Indicates the directory service used. Required. Known values + are: "None", "AADDS", and "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2019_06_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -287,12 +286,12 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): """ _validation = { - 'directory_service_options': {'required': True}, + "directory_service_options": {"required": True}, } _attribute_map = { - 'directory_service_options': {'key': 'directoryServiceOptions', 'type': 'str'}, - 'active_directory_properties': {'key': 'activeDirectoryProperties', 'type': 'ActiveDirectoryProperties'}, + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, } def __init__( @@ -303,20 +302,20 @@ def __init__( **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Known - values are: "None", "AADDS", "AD". + :keyword directory_service_options: Indicates the directory service used. Required. Known + values are: "None", "AADDS", and "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2019_06_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. :paramtype active_directory_properties: ~azure.mgmt.storage.v2019_06_01.models.ActiveDirectoryProperties """ - super(AzureFilesIdentityBasedAuthentication, self).__init__(**kwargs) + super().__init__(**kwargs) self.directory_service_options = directory_service_options self.active_directory_properties = active_directory_properties -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -346,17 +345,18 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2019_06_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -377,45 +377,45 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -435,12 +435,12 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2019_06_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -481,79 +481,69 @@ class BlobInventoryPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified_time": {"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'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'BlobInventoryPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "BlobInventoryPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.BlobInventoryPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs): """ :keyword policy: The storage account blob inventory policy object. It is composed of policy rules. :paramtype policy: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicySchema """ - super(BlobInventoryPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.last_modified_time = None self.policy = policy -class BlobInventoryPolicyDefinition(msrest.serialization.Model): +class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. Each definition consists of a set of filters. All required parameters must be populated in order to send to Azure. - :ivar filters: Required. An object that defines the filter set. + :ivar filters: An object that defines the filter set. Required. :vartype filters: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyFilter """ _validation = { - 'filters': {'required': True}, + "filters": {"required": True}, } _attribute_map = { - 'filters': {'key': 'filters', 'type': 'BlobInventoryPolicyFilter'}, + "filters": {"key": "filters", "type": "BlobInventoryPolicyFilter"}, } - def __init__( - self, - *, - filters: "_models.BlobInventoryPolicyFilter", - **kwargs - ): + def __init__(self, *, filters: "_models.BlobInventoryPolicyFilter", **kwargs): """ - :keyword filters: Required. An object that defines the filter set. + :keyword filters: An object that defines the filter set. Required. :paramtype filters: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyFilter """ - super(BlobInventoryPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.filters = filters -class BlobInventoryPolicyFilter(msrest.serialization.Model): +class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for blob prefixes to be matched. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Valid values include blockBlob, - appendBlob, pageBlob. Hns accounts does not support pageBlobs. + :ivar blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. Required. :vartype blob_types: list[str] :ivar include_blob_versions: Includes blob versions in blob inventory when value set to true. :vartype include_blob_versions: bool @@ -562,14 +552,14 @@ class BlobInventoryPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'include_blob_versions': {'key': 'includeBlobVersions', 'type': 'bool'}, - 'include_snapshots': {'key': 'includeSnapshots', 'type': 'bool'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "include_blob_versions": {"key": "includeBlobVersions", "type": "bool"}, + "include_snapshots": {"key": "includeSnapshots", "type": "bool"}, } def __init__( @@ -584,8 +574,8 @@ def __init__( """ :keyword prefix_match: An array of strings for blob prefixes to be matched. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Valid values include - blockBlob, appendBlob, pageBlob. Hns accounts does not support pageBlobs. + :keyword blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. Required. :paramtype blob_types: list[str] :keyword include_blob_versions: Includes blob versions in blob inventory when value set to true. @@ -593,91 +583,84 @@ def __init__( :keyword include_snapshots: Includes blob snapshots in blob inventory when value set to true. :paramtype include_snapshots: bool """ - super(BlobInventoryPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.include_blob_versions = include_blob_versions self.include_snapshots = include_snapshots -class BlobInventoryPolicyRule(msrest.serialization.Model): +class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Rule is enabled when set to true. + :ivar enabled: Rule is enabled when set to true. Required. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar definition: Required. An object that defines the blob inventory policy rule. + :ivar definition: An object that defines the blob inventory policy rule. Required. :vartype definition: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyDefinition """ _validation = { - 'enabled': {'required': True}, - 'name': {'required': True}, - 'definition': {'required': True}, + "enabled": {"required": True}, + "name": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'BlobInventoryPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "definition": {"key": "definition", "type": "BlobInventoryPolicyDefinition"}, } - def __init__( - self, - *, - enabled: bool, - name: str, - definition: "_models.BlobInventoryPolicyDefinition", - **kwargs - ): + def __init__(self, *, enabled: bool, name: str, definition: "_models.BlobInventoryPolicyDefinition", **kwargs): """ - :keyword enabled: Required. Rule is enabled when set to true. + :keyword enabled: Rule is enabled when set to true. Required. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword definition: Required. An object that defines the blob inventory policy rule. + :keyword definition: An object that defines the blob inventory policy rule. Required. :paramtype definition: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyDefinition """ - super(BlobInventoryPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.definition = definition -class BlobInventoryPolicySchema(msrest.serialization.Model): +class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Policy is enabled if set to true. + :ivar enabled: Policy is enabled if set to true. Required. :vartype enabled: bool - :ivar destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :ivar destination: Container name where blob inventory files are stored. Must be pre-created. + Required. :vartype destination: str - :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". + :ivar type: The valid value is Inventory. Required. "Inventory" :vartype type: str or ~azure.mgmt.storage.v2019_06_01.models.InventoryRuleType - :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :ivar rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :vartype rules: list[~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyRule] """ _validation = { - 'enabled': {'required': True}, - 'destination': {'required': True}, - 'type': {'required': True}, - 'rules': {'required': True}, + "enabled": {"required": True}, + "destination": {"required": True}, + "type": {"required": True}, + "rules": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'destination': {'key': 'destination', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rules': {'key': 'rules', 'type': '[BlobInventoryPolicyRule]'}, + "enabled": {"key": "enabled", "type": "bool"}, + "destination": {"key": "destination", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rules": {"key": "rules", "type": "[BlobInventoryPolicyRule]"}, } def __init__( @@ -690,103 +673,91 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Policy is enabled if set to true. + :keyword enabled: Policy is enabled if set to true. Required. :paramtype enabled: bool - :keyword destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :keyword destination: Container name where blob inventory files are stored. Must be + pre-created. Required. :paramtype destination: str - :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". + :keyword type: The valid value is Inventory. Required. "Inventory" :paramtype type: str or ~azure.mgmt.storage.v2019_06_01.models.InventoryRuleType - :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :keyword rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :paramtype rules: list[~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyRule] """ - super(BlobInventoryPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.destination = destination self.type = type self.rules = rules -class BlobRestoreParameters(msrest.serialization.Model): +class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. All required parameters must be populated in order to send to Azure. - :ivar time_to_restore: Required. Restore blob to the specified time. + :ivar time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime - :ivar blob_ranges: Required. Blob ranges to restore. + :ivar blob_ranges: Blob ranges to restore. Required. :vartype blob_ranges: list[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreRange] """ _validation = { - 'time_to_restore': {'required': True}, - 'blob_ranges': {'required': True}, + "time_to_restore": {"required": True}, + "blob_ranges": {"required": True}, } _attribute_map = { - 'time_to_restore': {'key': 'timeToRestore', 'type': 'iso-8601'}, - 'blob_ranges': {'key': 'blobRanges', 'type': '[BlobRestoreRange]'}, + "time_to_restore": {"key": "timeToRestore", "type": "iso-8601"}, + "blob_ranges": {"key": "blobRanges", "type": "[BlobRestoreRange]"}, } - def __init__( - self, - *, - time_to_restore: datetime.datetime, - blob_ranges: List["_models.BlobRestoreRange"], - **kwargs - ): + def __init__(self, *, time_to_restore: datetime.datetime, blob_ranges: List["_models.BlobRestoreRange"], **kwargs): """ - :keyword time_to_restore: Required. Restore blob to the specified time. + :keyword time_to_restore: Restore blob to the specified time. Required. :paramtype time_to_restore: ~datetime.datetime - :keyword blob_ranges: Required. Blob ranges to restore. + :keyword blob_ranges: Blob ranges to restore. Required. :paramtype blob_ranges: list[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreRange] """ - super(BlobRestoreParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_to_restore = time_to_restore self.blob_ranges = blob_ranges -class BlobRestoreRange(msrest.serialization.Model): +class BlobRestoreRange(_serialization.Model): """Blob range. All required parameters must be populated in order to send to Azure. - :ivar start_range: Required. Blob start range. This is inclusive. Empty means account start. + :ivar start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str - :ivar end_range: Required. Blob end range. This is exclusive. Empty means account end. + :ivar end_range: Blob end range. This is exclusive. Empty means account end. Required. :vartype end_range: str """ _validation = { - 'start_range': {'required': True}, - 'end_range': {'required': True}, + "start_range": {"required": True}, + "end_range": {"required": True}, } _attribute_map = { - 'start_range': {'key': 'startRange', 'type': 'str'}, - 'end_range': {'key': 'endRange', 'type': 'str'}, + "start_range": {"key": "startRange", "type": "str"}, + "end_range": {"key": "endRange", "type": "str"}, } - def __init__( - self, - *, - start_range: str, - end_range: str, - **kwargs - ): + def __init__(self, *, start_range: str, end_range: str, **kwargs): """ - :keyword start_range: Required. Blob start range. This is inclusive. Empty means account start. + :keyword start_range: Blob start range. This is inclusive. Empty means account start. Required. :paramtype start_range: str - :keyword end_range: Required. Blob end range. This is exclusive. Empty means account end. + :keyword end_range: Blob end range. This is exclusive. Empty means account end. Required. :paramtype end_range: str """ - super(BlobRestoreRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_range = start_range self.end_range = end_range -class BlobRestoreStatus(msrest.serialization.Model): +class BlobRestoreStatus(_serialization.Model): """Blob restore status. Variables are only populated by the server, and will be ignored when sending a request. @@ -794,7 +765,7 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", - "Complete", "Failed". + "Complete", and "Failed". :vartype status: str or ~azure.mgmt.storage.v2019_06_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -805,33 +776,29 @@ class BlobRestoreStatus(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'restore_id': {'readonly': True}, - 'parameters': {'readonly': True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "restore_id": {"readonly": True}, + "parameters": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'restore_id': {'key': 'restoreId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'BlobRestoreParameters'}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "restore_id": {"key": "restoreId", "type": "str"}, + "parameters": {"key": "parameters", "type": "BlobRestoreParameters"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobRestoreStatus, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.failure_reason = None self.restore_id = None self.parameters = None -class BlobServiceItems(msrest.serialization.Model): +class BlobServiceItems(_serialization.Model): """BlobServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -841,24 +808,20 @@ class BlobServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobServiceProperties]'}, + "value": {"key": "value", "type": "[BlobServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class BlobServiceProperties(Resource): +class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attributes """The properties of a storage account’s Blob service. Variables are only populated by the server, and will be ignored when sending a request. @@ -901,26 +864,32 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'is_versioning_enabled': {'key': 'properties.isVersioningEnabled', 'type': 'bool'}, - 'automatic_snapshot_policy_enabled': {'key': 'properties.automaticSnapshotPolicyEnabled', 'type': 'bool'}, - 'change_feed': {'key': 'properties.changeFeed', 'type': 'ChangeFeed'}, - 'restore_policy': {'key': 'properties.restorePolicy', 'type': 'RestorePolicyProperties'}, - 'container_delete_retention_policy': {'key': 'properties.containerDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'last_access_time_tracking_policy': {'key': 'properties.lastAccessTimeTrackingPolicy', 'type': 'LastAccessTimeTrackingPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "is_versioning_enabled": {"key": "properties.isVersioningEnabled", "type": "bool"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, + "restore_policy": {"key": "properties.restorePolicy", "type": "RestorePolicyProperties"}, + "container_delete_retention_policy": { + "key": "properties.containerDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "last_access_time_tracking_policy": { + "key": "properties.lastAccessTimeTrackingPolicy", + "type": "LastAccessTimeTrackingPolicy", + }, } def __init__( @@ -967,7 +936,7 @@ def __init__( :paramtype last_access_time_tracking_policy: ~azure.mgmt.storage.v2019_06_01.models.LastAccessTimeTrackingPolicy """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.default_service_version = default_service_version @@ -980,7 +949,7 @@ def __init__( self.last_access_time_tracking_policy = last_access_time_tracking_policy -class ChangeFeed(msrest.serialization.Model): +class ChangeFeed(_serialization.Model): """The blob service properties for change feed events. :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. @@ -992,21 +961,15 @@ class ChangeFeed(msrest.serialization.Model): """ _validation = { - 'retention_in_days': {'maximum': 146000, 'minimum': 1}, + "retention_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_in_days': {'key': 'retentionInDays', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_in_days": {"key": "retentionInDays", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - retention_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, retention_in_days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. :paramtype enabled: bool @@ -1015,12 +978,12 @@ def __init__( retention of the change feed. :paramtype retention_in_days: int """ - super(ChangeFeed, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.retention_in_days = retention_in_days -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1030,7 +993,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2019_06_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1038,30 +1001,26 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1078,10 +1037,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -1106,50 +1065,50 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2019_06_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2019_06_01.models.CorsRuleAllowedMethodsItem] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -1163,24 +1122,24 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2019_06_01.models.CorsRuleAllowedMethodsItem] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -1188,7 +1147,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -1197,31 +1156,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2019_06_01.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -1229,68 +1183,57 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DateAfterCreation(msrest.serialization.Model): +class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. All required parameters must be populated in order to send to Azure. - :ivar days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :vartype days_after_creation_greater_than: float """ _validation = { - 'days_after_creation_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, } - def __init__( - self, - *, - days_after_creation_greater_than: float, - **kwargs - ): + def __init__(self, *, days_after_creation_greater_than: float, **kwargs): """ - :keyword days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :paramtype days_after_creation_greater_than: float """ - super(DateAfterCreation, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_creation_greater_than = days_after_creation_greater_than -class DateAfterModification(msrest.serialization.Model): +class DateAfterModification(_serialization.Model): """Object to define the number of days after object last modification Or last access. Properties daysAfterModificationGreaterThan and daysAfterLastAccessTimeGreaterThan are mutually exclusive. :ivar days_after_modification_greater_than: Value indicating the age in days after last @@ -1303,13 +1246,13 @@ class DateAfterModification(msrest.serialization.Model): """ _validation = { - 'days_after_modification_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_last_access_time_greater_than': {'minimum': 0, 'multiple': 1}, + "days_after_modification_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_access_time_greater_than": {"minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'float'}, - 'days_after_last_access_time_greater_than': {'key': 'daysAfterLastAccessTimeGreaterThan', 'type': 'float'}, + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, + "days_after_last_access_time_greater_than": {"key": "daysAfterLastAccessTimeGreaterThan", "type": "float"}, } def __init__( @@ -1328,55 +1271,49 @@ def __init__( policy. :paramtype days_after_last_access_time_greater_than: float """ - super(DateAfterModification, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_modification_greater_than = days_after_modification_greater_than self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than -class DeletedShare(msrest.serialization.Model): +class DeletedShare(_serialization.Model): """The deleted share to be restored. All required parameters must be populated in order to send to Azure. - :ivar deleted_share_name: Required. Required. Identify the name of the deleted share that will - be restored. + :ivar deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :vartype deleted_share_name: str - :ivar deleted_share_version: Required. Required. Identify the version of the deleted share that - will be restored. + :ivar deleted_share_version: Required. Identify the version of the deleted share that will be + restored. Required. :vartype deleted_share_version: str """ _validation = { - 'deleted_share_name': {'required': True}, - 'deleted_share_version': {'required': True}, + "deleted_share_name": {"required": True}, + "deleted_share_version": {"required": True}, } _attribute_map = { - 'deleted_share_name': {'key': 'deletedShareName', 'type': 'str'}, - 'deleted_share_version': {'key': 'deletedShareVersion', 'type': 'str'}, + "deleted_share_name": {"key": "deletedShareName", "type": "str"}, + "deleted_share_version": {"key": "deletedShareVersion", "type": "str"}, } - def __init__( - self, - *, - deleted_share_name: str, - deleted_share_version: str, - **kwargs - ): + def __init__(self, *, deleted_share_name: str, deleted_share_version: str, **kwargs): """ - :keyword deleted_share_name: Required. Required. Identify the name of the deleted share that - will be restored. + :keyword deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :paramtype deleted_share_name: str - :keyword deleted_share_version: Required. Required. Identify the version of the deleted share - that will be restored. + :keyword deleted_share_version: Required. Identify the version of the deleted share that will + be restored. Required. :paramtype deleted_share_version: str """ - super(DeletedShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.deleted_share_name = deleted_share_name self.deleted_share_version = deleted_share_version -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. @@ -1387,21 +1324,15 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled. :paramtype enabled: bool @@ -1409,12 +1340,12 @@ def __init__( minimum specified value can be 1 and the maximum value can be 365. :paramtype days: int """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -1424,38 +1355,32 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2019_06_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2019_06_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1465,14 +1390,14 @@ class Encryption(msrest.serialization.Model): """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, } def __init__( @@ -1487,9 +1412,9 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2019_06_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2019_06_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1497,7 +1422,7 @@ def __init__( :keyword key_vault_properties: Properties provided by key vault. :paramtype key_vault_properties: ~azure.mgmt.storage.v2019_06_01.models.KeyVaultProperties """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption @@ -1518,11 +1443,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Known values are: "Enabled", "Disabled". + Disabled. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1536,22 +1461,22 @@ class EncryptionScope(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'EncryptionScopeKeyVaultProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "EncryptionScopeKeyVaultProperties"}, } def __init__( @@ -1564,18 +1489,18 @@ def __init__( ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Known values are: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. :paramtype key_vault_properties: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeKeyVaultProperties """ - super(EncryptionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.state = state self.creation_time = None @@ -1583,7 +1508,7 @@ def __init__( self.key_vault_properties = key_vault_properties -class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): +class EncryptionScopeKeyVaultProperties(_serialization.Model): """The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. :ivar key_uri: The object identifier for a key vault key object. When applied, the encryption @@ -1593,26 +1518,21 @@ class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_uri': {'key': 'keyUri', 'type': 'str'}, + "key_uri": {"key": "keyUri", "type": "str"}, } - def __init__( - self, - *, - key_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_uri: Optional[str] = None, **kwargs): """ :keyword key_uri: The object identifier for a key vault key object. When applied, the encryption scope will use the key referenced by the identifier to enable customer-managed key support on this encryption scope. :paramtype key_uri: str """ - super(EncryptionScopeKeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_uri = key_uri -class EncryptionScopeListResult(msrest.serialization.Model): +class EncryptionScopeListResult(_serialization.Model): """List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. Variables are only populated by the server, and will be ignored when sending a request. @@ -1625,27 +1545,23 @@ class EncryptionScopeListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EncryptionScope]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EncryptionScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(EncryptionScopeListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -1659,26 +1575,22 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Known values are: "Service", "Account". + default service key is used. Known values are: "Service" and "Account". :vartype key_type: str or ~azure.mgmt.storage.v2019_06_01.models.KeyType """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'key_type': {'key': 'keyType', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "key_type": {"key": "keyType", "type": "str"}, } def __init__( - self, - *, - enabled: Optional[bool] = None, - key_type: Optional[Union[str, "_models.KeyType"]] = None, - **kwargs + self, *, enabled: Optional[bool] = None, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is @@ -1686,16 +1598,16 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Known values are: "Service", "Account". + that a default service key is used. Known values are: "Service" and "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2019_06_01.models.KeyType """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None self.key_type = key_type -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. :ivar blob: The encryption function of the blob storage service. @@ -1709,10 +1621,10 @@ class EncryptionServices(msrest.serialization.Model): """ _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -1734,14 +1646,14 @@ def __init__( :keyword queue: The encryption function of the queue storage service. :paramtype queue: ~azure.mgmt.storage.v2019_06_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = table self.queue = queue -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1767,23 +1679,23 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, - 'microsoft_endpoints': {'key': 'microsoftEndpoints', 'type': 'StorageAccountMicrosoftEndpoints'}, - 'internet_endpoints': {'key': 'internetEndpoints', 'type': 'StorageAccountInternetEndpoints'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + "microsoft_endpoints": {"key": "microsoftEndpoints", "type": "StorageAccountMicrosoftEndpoints"}, + "internet_endpoints": {"key": "internetEndpoints", "type": "StorageAccountInternetEndpoints"}, } def __init__( @@ -1801,7 +1713,7 @@ def __init__( :paramtype internet_endpoints: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountInternetEndpoints """ - super(Endpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -1812,7 +1724,7 @@ def __init__( self.internet_endpoints = internet_endpoints -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the storage resource provider. :ivar error: Azure Storage Resource Provider error response body. @@ -1820,24 +1732,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure Storage Resource Provider error response body. :paramtype error: ~azure.mgmt.storage.v2019_06_01.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """Error response body contract. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1849,17 +1756,11 @@ class ErrorResponseBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. @@ -1868,12 +1769,12 @@ def __init__( interface. :paramtype message: str """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class FileServiceItems(msrest.serialization.Model): +class FileServiceItems(_serialization.Model): """FileServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -1883,20 +1784,16 @@ class FileServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileServiceProperties]'}, + "value": {"key": "value", "type": "[FileServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -1925,19 +1822,22 @@ class FileServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'share_delete_retention_policy': {'key': 'properties.shareDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "share_delete_retention_policy": { + "key": "properties.shareDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, } def __init__( @@ -1956,13 +1856,13 @@ def __init__( :paramtype share_delete_retention_policy: ~azure.mgmt.storage.v2019_06_01.models.DeleteRetentionPolicy """ - super(FileServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.share_delete_retention_policy = share_delete_retention_policy -class FileShare(AzureEntityResource): +class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the file share, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -1985,10 +1885,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2019_06_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2019_06_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2000,7 +1900,7 @@ class FileShare(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2008,43 +1908,43 @@ class FileShare(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long + :vartype share_usage_bytes: int """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, } def __init__( @@ -2064,17 +1964,17 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2019_06_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2019_06_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.ShareAccessTier """ - super(FileShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2090,7 +1990,7 @@ def __init__( self.share_usage_bytes = None -class FileShareItem(AzureEntityResource): +class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The file share properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -2113,10 +2013,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2019_06_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2019_06_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2128,7 +2028,7 @@ class FileShareItem(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2136,43 +2036,43 @@ class FileShareItem(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long + :vartype share_usage_bytes: int """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, } def __init__( @@ -2192,17 +2092,17 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2019_06_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2019_06_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.ShareAccessTier """ - super(FileShareItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2218,7 +2118,7 @@ def __init__( self.share_usage_bytes = None -class FileShareItems(msrest.serialization.Model): +class FileShareItems(_serialization.Model): """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. Variables are only populated by the server, and will be ignored when sending a request. @@ -2231,27 +2131,23 @@ class FileShareItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileShareItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileShareItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2260,7 +2156,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2019_06_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2273,30 +2169,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2307,31 +2199,27 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Has constant value: "SystemAssigned". + :ivar type: The identity type. Required. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True, 'constant': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "SystemAssigned" - def __init__( - self, - **kwargs - ): - """ - """ - super(Identity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -2355,7 +2243,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2366,21 +2254,24 @@ class ImmutabilityPolicy(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -2401,13 +2292,13 @@ def __init__( ExtendImmutabilityPolicy API. :paramtype allow_protected_append_writes: bool """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None self.allow_protected_append_writes = allow_protected_append_writes -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2420,7 +2311,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2431,17 +2322,20 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -2462,7 +2356,7 @@ def __init__( ExtendImmutabilityPolicy API. :paramtype allow_protected_append_writes: bool """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days @@ -2470,49 +2364,41 @@ def __init__( self.allow_protected_append_writes = allow_protected_append_writes -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. Variables are only populated by the server, and will be ignored when sending a request. @@ -2531,16 +2417,16 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } def __init__( @@ -2559,7 +2445,7 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri @@ -2567,15 +2453,15 @@ def __init__( self.last_key_rotation_timestamp = None -class LastAccessTimeTrackingPolicy(msrest.serialization.Model): +class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. All required parameters must be populated in order to send to Azure. - :ivar enable: Required. When set to true last access time based tracking is enabled. + :ivar enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Known values are: "AccessTimeTracking". + read only. "AccessTimeTracking" :vartype name: str or ~azure.mgmt.storage.v2019_06_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2587,14 +2473,14 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): """ _validation = { - 'enable': {'required': True}, + "enable": {"required": True}, } _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tracking_granularity_in_days': {'key': 'trackingGranularityInDays', 'type': 'int'}, - 'blob_type': {'key': 'blobType', 'type': '[str]'}, + "enable": {"key": "enable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "tracking_granularity_in_days": {"key": "trackingGranularityInDays", "type": "int"}, + "blob_type": {"key": "blobType", "type": "[str]"}, } def __init__( @@ -2607,10 +2493,10 @@ def __init__( **kwargs ): """ - :keyword enable: Required. When set to true last access time based tracking is enabled. + :keyword enable: When set to true last access time based tracking is enabled. Required. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Known values are: "AccessTimeTracking". + currently read only. "AccessTimeTracking" :paramtype name: str or ~azure.mgmt.storage.v2019_06_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2620,20 +2506,20 @@ def __init__( supported value. This field is currently read only. :paramtype blob_type: list[str] """ - super(LastAccessTimeTrackingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enable = enable self.name = name self.tracking_granularity_in_days = tracking_granularity_in_days self.blob_type = blob_type -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -2649,15 +2535,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -2671,8 +2557,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -2686,7 +2572,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -2694,7 +2580,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -2705,17 +2591,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -2723,12 +2603,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2740,38 +2620,33 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, } - def __init__( - self, - *, - tags: List[str], - **kwargs - ): + def __init__(self, *, tags: List[str], **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2781,35 +2656,30 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2019_06_01.models.TagProperty] """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, } - def __init__( - self, - *, - tags: Optional[List["_models.TagProperty"]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[List["_models.TagProperty"]] = None, **kwargs): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2019_06_01.models.TagProperty] """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -2819,24 +2689,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListBlobInventoryPolicy(msrest.serialization.Model): +class ListBlobInventoryPolicy(_serialization.Model): """List of blob inventory policies returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -2846,24 +2712,20 @@ class ListBlobInventoryPolicy(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobInventoryPolicy]'}, + "value": {"key": "value", "type": "[BlobInventoryPolicy]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListBlobInventoryPolicy, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -2893,17 +2755,18 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2019_06_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2019_06_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -2924,45 +2787,45 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -2982,12 +2845,12 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2019_06_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -3006,7 +2869,7 @@ def __init__( self.has_immutability_policy = None -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. Variables are only populated by the server, and will be ignored when sending a request. @@ -3019,22 +2882,18 @@ class ListContainerItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListContainerItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3057,33 +2916,28 @@ class ListQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(ListQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata -class ListQueueResource(msrest.serialization.Model): +class ListQueueResource(_serialization.Model): """Response schema. Contains list of queues returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3095,27 +2949,23 @@ class ListQueueResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListQueueServices(msrest.serialization.Model): +class ListQueueServices(_serialization.Model): """ListQueueServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -3125,24 +2975,20 @@ class ListQueueServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueServiceProperties]'}, + "value": {"key": "value", "type": "[QueueServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3152,24 +2998,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class ListTableResource(msrest.serialization.Model): +class ListTableResource(_serialization.Model): """Response schema. Contains list of tables returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3181,27 +3023,23 @@ class ListTableResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Table]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Table]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListTableServices(msrest.serialization.Model): +class ListTableServices(_serialization.Model): """ListTableServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -3211,20 +3049,16 @@ class ListTableServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TableServiceProperties]'}, + "value": {"key": "value", "type": "[TableServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -3249,37 +3083,32 @@ class ManagementPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.ManagementPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :paramtype policy: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicySchema """ - super(ManagementPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.policy = policy -class ManagementPolicyAction(msrest.serialization.Model): +class ManagementPolicyAction(_serialization.Model): """Actions are applied to the filtered blobs when the execution condition is met. :ivar base_blob: The management policy action for base blob. @@ -3291,9 +3120,9 @@ class ManagementPolicyAction(msrest.serialization.Model): """ _attribute_map = { - 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, - 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, - 'version': {'key': 'version', 'type': 'ManagementPolicyVersion'}, + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, + "version": {"key": "version", "type": "ManagementPolicyVersion"}, } def __init__( @@ -3312,13 +3141,13 @@ def __init__( :keyword version: The management policy action for version. :paramtype version: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyVersion """ - super(ManagementPolicyAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_blob = base_blob self.snapshot = snapshot self.version = version -class ManagementPolicyBaseBlob(msrest.serialization.Model): +class ManagementPolicyBaseBlob(_serialization.Model): """Management policy action for base blob. :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot @@ -3335,10 +3164,10 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, - 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, - 'enable_auto_tier_to_hot_from_cool': {'key': 'enableAutoTierToHotFromCool', 'type': 'bool'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, + "enable_auto_tier_to_hot_from_cool": {"key": "enableAutoTierToHotFromCool", "type": "bool"}, } def __init__( @@ -3364,31 +3193,31 @@ def __init__( tierToCool.daysAfterLastAccessTimeGreaterThan. :paramtype enable_auto_tier_to_hot_from_cool: bool """ - super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool -class ManagementPolicyDefinition(msrest.serialization.Model): +class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. All required parameters must be populated in order to send to Azure. - :ivar actions: Required. An object that defines the action set. + :ivar actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyAction :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyFilter """ _validation = { - 'actions': {'required': True}, + "actions": {"required": True}, } _attribute_map = { - 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, - 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, } def __init__( @@ -3399,25 +3228,25 @@ def __init__( **kwargs ): """ - :keyword actions: Required. An object that defines the action set. + :keyword actions: An object that defines the action set. Required. :paramtype actions: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyAction :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyFilter """ - super(ManagementPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.filters = filters -class ManagementPolicyFilter(msrest.serialization.Model): +class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :ivar blob_types: An array of predefined enum values. Currently blockBlob supports all tiering + and delete actions. Only delete actions are supported for appendBlob. Required. :vartype blob_types: list[str] :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. @@ -3425,13 +3254,13 @@ class ManagementPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'blob_index_match': {'key': 'blobIndexMatch', 'type': '[TagFilter]'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "blob_index_match": {"key": "blobIndexMatch", "type": "[TagFilter]"}, } def __init__( @@ -3445,46 +3274,46 @@ def __init__( """ :keyword prefix_match: An array of strings for prefixes to be match. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :keyword blob_types: An array of predefined enum values. Currently blockBlob supports all + tiering and delete actions. Only delete actions are supported for appendBlob. Required. :paramtype blob_types: list[str] :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. :paramtype blob_index_match: list[~azure.mgmt.storage.v2019_06_01.models.TagFilter] """ - super(ManagementPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.blob_index_match = blob_index_match -class ManagementPolicyRule(msrest.serialization.Model): +class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. :ivar enabled: Rule is enabled if set to true. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" :vartype type: str or ~azure.mgmt.storage.v2019_06_01.models.RuleType - :ivar definition: Required. An object that defines the Lifecycle rule. + :ivar definition: An object that defines the Lifecycle rule. Required. :vartype definition: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyDefinition """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - 'definition': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, } def __init__( @@ -3499,55 +3328,52 @@ def __init__( """ :keyword enabled: Rule is enabled if set to true. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" :paramtype type: str or ~azure.mgmt.storage.v2019_06_01.models.RuleType - :keyword definition: Required. An object that defines the Lifecycle rule. + :keyword definition: An object that defines the Lifecycle rule. Required. :paramtype definition: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyDefinition """ - super(ManagementPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.type = type self.definition = definition -class ManagementPolicySchema(msrest.serialization.Model): +class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. All required parameters must be populated in order to send to Azure. - :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :vartype rules: list[~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyRule] """ _validation = { - 'rules': {'required': True}, + "rules": {"required": True}, } _attribute_map = { - 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, } - def __init__( - self, - *, - rules: List["_models.ManagementPolicyRule"], - **kwargs - ): + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): """ - :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :paramtype rules: list[~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyRule] """ - super(ManagementPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.rules = rules -class ManagementPolicySnapShot(msrest.serialization.Model): +class ManagementPolicySnapShot(_serialization.Model): """Management policy action for snapshot. :ivar tier_to_cool: The function to tier blob snapshot to cool storage. Support blob snapshot @@ -3561,9 +3387,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -3584,13 +3410,13 @@ def __init__( :keyword delete: The function to delete the blob snapshot. :paramtype delete: ~azure.mgmt.storage.v2019_06_01.models.DateAfterCreation """ - super(ManagementPolicySnapShot, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class ManagementPolicyVersion(msrest.serialization.Model): +class ManagementPolicyVersion(_serialization.Model): """Management policy action for blob version. :ivar tier_to_cool: The function to tier blob version to cool storage. Support blob version @@ -3604,9 +3430,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -3627,13 +3453,13 @@ def __init__( :keyword delete: The function to delete the blob version. :paramtype delete: ~azure.mgmt.storage.v2019_06_01.models.DateAfterCreation """ - super(ManagementPolicyVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -3657,15 +3483,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -3702,7 +3528,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -3714,41 +3540,41 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2019_06_01.models.Bypass :ivar virtual_network_rules: Sets the virtual network rules. :vartype virtual_network_rules: list[~azure.mgmt.storage.v2019_06_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2019_06_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2019_06_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, **kwargs @@ -3757,25 +3583,25 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2019_06_01.models.Bypass :keyword virtual_network_rules: Sets the virtual network rules. :paramtype virtual_network_rules: list[~azure.mgmt.storage.v2019_06_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2019_06_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2019_06_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.virtual_network_rules = virtual_network_rules self.ip_rules = ip_rules self.default_action = default_action -class ObjectReplicationPolicies(msrest.serialization.Model): +class ObjectReplicationPolicies(_serialization.Model): """List storage account object replication policies. :ivar value: The replication policy between two storage accounts. @@ -3783,20 +3609,15 @@ class ObjectReplicationPolicies(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ObjectReplicationPolicy]'}, + "value": {"key": "value", "type": "[ObjectReplicationPolicy]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ObjectReplicationPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs): """ :keyword value: The replication policy between two storage accounts. :paramtype value: list[~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy] """ - super(ObjectReplicationPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -3826,22 +3647,22 @@ class ObjectReplicationPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_id': {'readonly': True}, - 'enabled_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_id": {"readonly": True}, + "enabled_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, - 'enabled_time': {'key': 'properties.enabledTime', 'type': 'iso-8601'}, - 'source_account': {'key': 'properties.sourceAccount', 'type': 'str'}, - 'destination_account': {'key': 'properties.destinationAccount', 'type': 'str'}, - 'rules': {'key': 'properties.rules', 'type': '[ObjectReplicationPolicyRule]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "enabled_time": {"key": "properties.enabledTime", "type": "iso-8601"}, + "source_account": {"key": "properties.sourceAccount", "type": "str"}, + "destination_account": {"key": "properties.destinationAccount", "type": "str"}, + "rules": {"key": "properties.rules", "type": "[ObjectReplicationPolicyRule]"}, } def __init__( @@ -3860,7 +3681,7 @@ def __init__( :keyword rules: The storage account object replication rules. :paramtype rules: list[~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicyRule] """ - super(ObjectReplicationPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_id = None self.enabled_time = None self.source_account = source_account @@ -3868,7 +3689,7 @@ def __init__( self.rules = rules -class ObjectReplicationPolicyFilter(msrest.serialization.Model): +class ObjectReplicationPolicyFilter(_serialization.Model): """Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the filter. If multiple filters are defined, a logical AND is performed on all filters. :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin @@ -3880,17 +3701,11 @@ class ObjectReplicationPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'min_creation_time': {'key': 'minCreationTime', 'type': 'str'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "min_creation_time": {"key": "minCreationTime", "type": "str"}, } - def __init__( - self, - *, - prefix_match: Optional[List[str]] = None, - min_creation_time: Optional[str] = None, - **kwargs - ): + def __init__(self, *, prefix_match: Optional[List[str]] = None, min_creation_time: Optional[str] = None, **kwargs): """ :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. @@ -3899,12 +3714,12 @@ def __init__( It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. :paramtype min_creation_time: str """ - super(ObjectReplicationPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.min_creation_time = min_creation_time -class ObjectReplicationPolicyRule(msrest.serialization.Model): +class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. All required parameters must be populated in order to send to Azure. @@ -3912,24 +3727,24 @@ class ObjectReplicationPolicyRule(msrest.serialization.Model): :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :vartype rule_id: str - :ivar source_container: Required. Required. Source container name. + :ivar source_container: Required. Source container name. Required. :vartype source_container: str - :ivar destination_container: Required. Required. Destination container name. + :ivar destination_container: Required. Destination container name. Required. :vartype destination_container: str :ivar filters: Optional. An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicyFilter """ _validation = { - 'source_container': {'required': True}, - 'destination_container': {'required': True}, + "source_container": {"required": True}, + "destination_container": {"required": True}, } _attribute_map = { - 'rule_id': {'key': 'ruleId', 'type': 'str'}, - 'source_container': {'key': 'sourceContainer', 'type': 'str'}, - 'destination_container': {'key': 'destinationContainer', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': 'ObjectReplicationPolicyFilter'}, + "rule_id": {"key": "ruleId", "type": "str"}, + "source_container": {"key": "sourceContainer", "type": "str"}, + "destination_container": {"key": "destinationContainer", "type": "str"}, + "filters": {"key": "filters", "type": "ObjectReplicationPolicyFilter"}, } def __init__( @@ -3945,21 +3760,21 @@ def __init__( :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :paramtype rule_id: str - :keyword source_container: Required. Required. Source container name. + :keyword source_container: Required. Source container name. Required. :paramtype source_container: str - :keyword destination_container: Required. Required. Destination container name. + :keyword destination_container: Required. Destination container name. Required. :paramtype destination_container: str :keyword filters: Optional. An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicyFilter """ - super(ObjectReplicationPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.rule_id = rule_id self.source_container = source_container self.destination_container = destination_container self.filters = filters -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -3973,10 +3788,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -3998,14 +3813,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2019_06_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -4019,10 +3834,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -4044,14 +3859,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -4059,24 +3874,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2019_06_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4086,20 +3896,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -4123,25 +3929,28 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2019_06_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -4159,13 +3968,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.storage.v2019_06_01.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """List of private endpoint connection associated with the specified storage account. :ivar value: Array of private endpoint connections. @@ -4173,20 +3982,15 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4212,39 +4016,34 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "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, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): """ :keyword required_zone_names: The private link resource Private link DNS zone name. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. @@ -4252,28 +4051,23 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.storage.v2019_06_01.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", and "Rejected". :vartype status: str or ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -4284,9 +4078,9 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'action_required': {'key': 'actionRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "action_required": {"key": "actionRequired", "type": "str"}, } def __init__( @@ -4299,7 +4093,7 @@ def __init__( ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", and "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -4308,7 +4102,7 @@ def __init__( updates on the consumer. :paramtype action_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.action_required = action_required @@ -4334,42 +4128,37 @@ class QueueServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Queue service. :paramtype cors: ~azure.mgmt.storage.v2019_06_01.models.CorsRules """ - super(QueueServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class RestorePolicyProperties(msrest.serialization.Model): +class RestorePolicyProperties(_serialization.Model): """The blob service properties for blob restore policy. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Blob restore is enabled if set to true. + :ivar enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool :ivar days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. @@ -4381,41 +4170,35 @@ class RestorePolicyProperties(msrest.serialization.Model): """ _validation = { - 'enabled': {'required': True}, - 'days': {'maximum': 365, 'minimum': 1}, - 'last_enabled_time': {'readonly': True}, - 'min_restore_time': {'readonly': True}, + "enabled": {"required": True}, + "days": {"maximum": 365, "minimum": 1}, + "last_enabled_time": {"readonly": True}, + "min_restore_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'min_restore_time': {'key': 'minRestoreTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "min_restore_time": {"key": "minRestoreTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: bool, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: bool, days: Optional[int] = None, **kwargs): """ - :keyword enabled: Required. Blob restore is enabled if set to true. + :keyword enabled: Blob restore is enabled if set to true. Required. :paramtype enabled: bool :keyword days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. :paramtype days: int """ - super(RestorePolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days self.last_enabled_time = None self.min_restore_time = None -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -4428,45 +4211,40 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2019_06_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2019_06_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class RoutingPreference(msrest.serialization.Model): +class RoutingPreference(_serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2019_06_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4477,9 +4255,9 @@ class RoutingPreference(msrest.serialization.Model): """ _attribute_map = { - 'routing_choice': {'key': 'routingChoice', 'type': 'str'}, - 'publish_microsoft_endpoints': {'key': 'publishMicrosoftEndpoints', 'type': 'bool'}, - 'publish_internet_endpoints': {'key': 'publishInternetEndpoints', 'type': 'bool'}, + "routing_choice": {"key": "routingChoice", "type": "str"}, + "publish_microsoft_endpoints": {"key": "publishMicrosoftEndpoints", "type": "bool"}, + "publish_internet_endpoints": {"key": "publishInternetEndpoints", "type": "bool"}, } def __init__( @@ -4492,7 +4270,7 @@ def __init__( ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2019_06_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4501,31 +4279,31 @@ def __init__( storage endpoints are to be published. :paramtype publish_internet_endpoints: bool """ - super(RoutingPreference, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_choice = routing_choice self.publish_microsoft_endpoints = publish_microsoft_endpoints self.publish_internet_endpoints = publish_internet_endpoints -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2019_06_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2019_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2019_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -4557,29 +4335,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, } _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -4606,20 +4384,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2019_06_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2019_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2019_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -4650,7 +4429,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -4671,7 +4450,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -4680,70 +4459,60 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2019_06_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2019_06_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2019_06_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2019_06_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -4756,45 +4525,41 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Storage SKU and its properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2019_06_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2019_06_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -4808,22 +4573,22 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -4834,16 +4599,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2019_06_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2019_06_01.models.Restriction] """ - super(SkuInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -4868,46 +4633,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -4922,19 +4681,19 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2019_06_01.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2019_06_01.models.Identity :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2019_06_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -4943,7 +4702,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2019_06_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -4955,7 +4714,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2019_06_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -4969,7 +4728,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2019_06_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -4987,7 +4746,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -5004,7 +4763,7 @@ class StorageAccount(TrackedResource): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5014,68 +4773,74 @@ class StorageAccount(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'blob_restore_status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "blob_restore_status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'blob_restore_status': {'key': 'properties.blobRestoreStatus', 'type': 'BlobRestoreStatus'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "blob_restore_status": {"key": "properties.blobRestoreStatus", "type": "BlobRestoreStatus"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -5092,9 +4857,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2019_06_01.models.Identity @@ -5108,7 +4873,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5119,7 +4884,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5127,7 +4892,7 @@ def __init__( default value is null, which is equivalent to true. :paramtype allow_shared_key_access: bool """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -5158,65 +4923,60 @@ def __init__( self.allow_shared_key_access = allow_shared_key_access -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2019_06_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2019_06_01.models.Identity @@ -5230,7 +4990,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2019_06_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5242,7 +5002,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -5253,7 +5013,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5263,29 +5023,32 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, } _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, } def __init__( @@ -5311,20 +5074,20 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2019_06_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2019_06_01.models.Identity @@ -5338,7 +5101,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2019_06_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5350,7 +5113,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5361,7 +5124,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5369,7 +5132,7 @@ def __init__( default value is null, which is equivalent to true. :paramtype allow_shared_key_access: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -5389,7 +5152,7 @@ def __init__( self.allow_shared_key_access = allow_shared_key_access -class StorageAccountInternetEndpoints(msrest.serialization.Model): +class StorageAccountInternetEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -5405,33 +5168,29 @@ class StorageAccountInternetEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountInternetEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.file = None self.web = None self.dfs = None -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -5441,35 +5200,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2019_06_01.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -5480,24 +5235,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -5510,27 +5261,23 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): +class StorageAccountMicrosoftEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -5550,30 +5297,26 @@ class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountMicrosoftEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -5582,55 +5325,50 @@ def __init__( self.dfs = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2, kerb1, kerb2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2, kerb1, kerb2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2019_06_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2019_06_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -5640,7 +5378,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2019_06_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5651,7 +5389,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2019_06_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -5662,7 +5400,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5672,21 +5410,24 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, } def __init__( @@ -5714,16 +5455,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2019_06_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2019_06_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2019_06_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -5733,7 +5474,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2019_06_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2019_06_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5745,7 +5486,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2019_06_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2019_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5756,7 +5497,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2019_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5764,7 +5505,7 @@ def __init__( default value is null, which is equivalent to true. :paramtype allow_shared_key_access: bool """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -5804,36 +5545,31 @@ class StorageQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'approximate_message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "approximate_message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'approximate_message_count': {'key': 'properties.approximateMessageCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "approximate_message_count": {"key": "properties.approximateMessageCount", "type": "int"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(StorageQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata self.approximate_message_count = None -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -5843,49 +5579,45 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuInformation]'}, + "value": {"key": "value", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2019_06_01.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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2019_06_01.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'}, + "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__( @@ -5903,19 +5635,19 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2019_06_01.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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2019_06_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -5942,26 +5674,22 @@ class Table(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'table_name': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "table_name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Table, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.table_name = None @@ -5985,86 +5713,74 @@ class TableServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Table service. :paramtype cors: ~azure.mgmt.storage.v2019_06_01.models.CorsRules """ - super(TableServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class TagFilter(msrest.serialization.Model): +class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. All required parameters must be populated in order to send to Azure. - :ivar name: Required. This is the filter tag name, it can have 1 - 128 characters. + :ivar name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str - :ivar op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :ivar op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :vartype op: str - :ivar value: Required. This is the filter tag value field used for tag based filtering, it can - have 0 - 256 characters. + :ivar value: This is the filter tag value field used for tag based filtering, it can have 0 - + 256 characters. Required. :vartype value: str """ _validation = { - 'name': {'required': True, 'max_length': 128, 'min_length': 1}, - 'op': {'required': True}, - 'value': {'required': True, 'max_length': 256, 'min_length': 0}, + "name": {"required": True, "max_length": 128, "min_length": 1}, + "op": {"required": True}, + "value": {"required": True, "max_length": 256}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'op': {'key': 'op', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "op": {"key": "op", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - op: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, op: str, value: str, **kwargs): """ - :keyword name: Required. This is the filter tag name, it can have 1 - 128 characters. + :keyword name: This is the filter tag name, it can have 1 - 128 characters. Required. :paramtype name: str - :keyword op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :keyword op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :paramtype op: str - :keyword value: Required. This is the filter tag value field used for tag based filtering, it - can have 0 - 256 characters. + :keyword value: This is the filter tag value field used for tag based filtering, it can have 0 + - 256 characters. Required. :paramtype value: str """ - super(TagFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.op = op self.value = value -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -6082,28 +5798,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -6111,13 +5823,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -6134,30 +5846,26 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -6166,13 +5874,13 @@ def __init__( self.upn = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2019_06_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -6183,33 +5891,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -6217,24 +5921,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2019_06_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -6246,72 +5945,68 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2019_06_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2019_06_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py index 0e02de120250..efec6a0326e5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,10 +25,13 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobInventoryPolicyName.""" DEFAULT = "default" + class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - @@ -39,6 +42,7 @@ class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): COMPLETE = "Complete" FAILED = "Failed" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -50,7 +54,9 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CorsRuleAllowedMethodsItem.""" DELETE = "DELETE" GET = "GET" @@ -60,30 +66,31 @@ class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): OPTIONS = "OPTIONS" PUT = "PUT" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the directory service used. - """ + """Indicates the directory service used.""" NONE = "None" AADDS = "AADDS" AD = "AD" + class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. @@ -92,6 +99,7 @@ class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): SMB = "SMB" NFS = "NFS" + class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. @@ -100,13 +108,20 @@ class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. - """ + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + +class Enum27(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum27.""" + + DEFAULT = "default" + + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -119,20 +134,21 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -142,27 +158,29 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Inventory - """ + """The valid value is Inventory.""" INVENTORY = "Inventory" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service @@ -172,9 +190,9 @@ class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SERVICE = "Service" ACCOUNT = "Account" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -182,22 +200,23 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - """ + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -207,9 +226,9 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -217,21 +236,26 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListContainersInclude.""" DELETED = "deleted" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. @@ -241,12 +265,13 @@ class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" + class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only - """ + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only.""" ACCESS_TIME_TRACKING = "AccessTimeTracking" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -261,39 +286,40 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state. - """ + """The current provisioning state.""" SUCCEEDED = "Succeeded" CREATING = "Creating" DELETING = "Deleting" FAILED = "Failed" + class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status. - """ + """The private endpoint connection status.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -302,6 +328,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -312,27 +339,28 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The property is for NFS share only. The default is NoRootSquash. - """ + """The property is for NFS share only. The default is NoRootSquash.""" NO_ROOT_SQUASH = "NoRootSquash" ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" + class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Routing Choice defines the kind of network routing opted by the user. - """ + """Routing Choice defines the kind of network routing opted by the user.""" MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" + class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Lifecycle - """ + """The valid value is Lifecycle.""" LIFECYCLE = "Lifecycle" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -343,6 +371,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. @@ -353,6 +382,7 @@ class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): COOL = "Cool" PREMIUM = "Premium" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -363,6 +393,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -373,6 +404,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -387,16 +419,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SKU tier. This is based on the SKU name. - """ + """The SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "provisioning" DEPROVISIONING = "deprovisioning" @@ -404,14 +436,16 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" + class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountExpand.""" GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/__init__.py index 25083f1873e4..ffe96543da2a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/__init__.py @@ -28,25 +28,26 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_operations.py index 27a604458202..25b53d9df26c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_containers_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -34,361 +48,307 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum27], subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum27], subscription_id: str, *, if_match: Optional[str] = None, @@ -397,43 +357,42 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum27], subscription_id: str, *, if_match: str, @@ -442,36 +401,34 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -486,34 +443,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -523,93 +479,79 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class BlobContainersOperations: """ @@ -630,7 +572,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -638,18 +579,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> Iterable[_models.ListContainerItems]: + ) -> Iterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -658,35 +599,39 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2019_06_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -694,18 +639,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -722,10 +666,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -735,19 +677,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -755,37 +697,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -795,7 +824,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -803,10 +833,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -814,63 +843,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -880,7 +995,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -888,72 +1004,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -961,72 +1073,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1034,10 +1142,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1047,16 +1154,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1064,37 +1172,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1104,7 +1299,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1112,70 +1308,155 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2019_06_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -1185,7 +1466,8 @@ def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1193,51 +1475,55 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum27], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -1245,44 +1531,144 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum27], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum27], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1290,10 +1676,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1301,17 +1686,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1319,6 +1703,7 @@ def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum27], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1326,52 +1711,52 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1379,10 +1764,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1390,17 +1774,16 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( @@ -1408,6 +1791,7 @@ def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum27], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1417,52 +1801,52 @@ def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1470,10 +1854,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1481,71 +1864,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1553,10 +1932,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1564,19 +1942,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1584,6 +1961,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1591,56 +1970,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1648,10 +2126,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1659,65 +2136,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1727,7 +2290,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1735,22 +2299,20 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_operations.py index d868be289228..9acf0d88acb7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_inventory_policies_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,167 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - *, - json: Optional[_models.BlobInventoryPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobInventoryPoliciesOperations: """ @@ -207,52 +208,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -260,10 +262,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -271,68 +272,151 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy 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 - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -340,10 +424,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -351,61 +434,62 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -413,10 +497,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -427,51 +510,50 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -479,15 +561,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -504,10 +588,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -518,8 +600,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_operations.py index ea195d3467d3..9def9edb9962 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_blob_services_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,134 +27,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum27], subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum27], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -168,47 +170,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -216,15 +220,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -241,10 +247,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -254,66 +258,149 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum27], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum27], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum27], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -321,72 +408,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum27], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -394,22 +476,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_operations.py index fb22b1fcee7f..8ce8232b7510 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_encryption_scopes_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,181 +27,164 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_put_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EncryptionScopesOperations: """ @@ -215,14 +205,15 @@ def __init__(self, *args, **kwargs): 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 + @overload def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -230,47 +221,137 @@ def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -278,10 +359,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -290,73 +370,160 @@ def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace + @overload def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -364,10 +531,9 @@ def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,62 +541,59 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -438,10 +601,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,58 +611,54 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.EncryptionScopeListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -508,15 +666,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -533,10 +693,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -546,8 +704,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_operations.py index 626d3f93ef8f..c41ff1bd32f8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum27], subscription_id: str, - *, - json: Optional[_models.FileServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum27], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class FileServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +211,162 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum27], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum27], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum27], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +374,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum27], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +442,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_operations.py index 229b04dfc73d..093954c7c093 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_file_shares_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -34,138 +48,117 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[str] = "deleted", + expand: Literal["deleted"] = "deleted", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -174,127 +167,112 @@ def build_get_request( share_name: str, subscription_id: str, *, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_restore_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.DeletedShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class FileSharesOperations: """ @@ -315,7 +293,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -323,17 +300,17 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[str] = "deleted", + expand: Literal["deleted"] = "deleted", **kwargs: Any - ) -> Iterable[_models.FileShareItems]: + ) -> Iterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -342,35 +319,39 @@ def list( listed. Default value is None. :type filter: str :param expand: Optional, used to expand the properties within share's properties. Known values - are "deleted" or None. Default value is "deleted". + are "deleted" and None. Default value is "deleted". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -378,18 +359,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -406,10 +386,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -419,19 +397,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -439,37 +417,124 @@ def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, @@ -479,7 +544,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -487,10 +553,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -498,63 +563,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2019_06_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -564,7 +715,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -572,25 +724,23 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def get( @@ -598,51 +748,53 @@ def get( resource_group_name: str, account_name: str, share_name: str, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", **kwargs: Any ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Known values - are "stats" or None. Default value is "stats". + are "stats" and None. Default value is "stats". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -650,72 +802,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - share_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, share_name: str, **kwargs: Any ) -> None: """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -723,10 +871,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -736,52 +883,135 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace + @overload def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2019_06_01.models.DeletedShare + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2019_06_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -791,7 +1021,8 @@ def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -799,10 +1030,9 @@ def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -812,5 +1042,4 @@ def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_operations.py index a8efb7131602..ebd73d0b1732 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,130 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,52 +169,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -215,78 +223,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy 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 - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -294,71 +384,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2019_06_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -366,10 +456,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +468,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_operations.py index 3e6aefff36ee..34b58a4991da 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_object_replication_policies_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,161 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - *, - json: Optional[_models.ObjectReplicationPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ObjectReplicationPoliciesOperations: """ @@ -207,49 +202,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +252,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +279,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -296,56 +291,52 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -353,10 +344,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -364,68 +354,150 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy 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 - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -433,10 +505,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -444,60 +515,57 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -505,10 +573,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -519,5 +586,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_operations.py index 085290392da8..b0f36bb207ed 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_endpoint_connections_operations.py index 6a30f7b742c8..89225f45c935 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,173 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -207,49 +214,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +264,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +291,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,56 +302,52 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -352,10 +355,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,67 +365,148 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace + @overload def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection 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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -431,10 +514,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,60 +524,57 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -503,10 +582,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -517,5 +595,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_link_resources_operations.py index fc9f1ab7fc73..70e3ab69669c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,52 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_storage_account_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,46 +91,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -128,22 +136,20 @@ def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_operations.py index d5c31166467a..7604b54f7301 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,183 +27,188 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( @@ -211,36 +223,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueOperations: """ @@ -261,60 +273,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -322,79 +419,163 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -402,72 +583,66 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.StorageQueue: + def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -475,72 +650,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -548,10 +719,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -561,8 +731,7 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -572,15 +741,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.ListQueueResource]: + ) -> Iterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -589,31 +758,35 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -621,17 +794,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -648,10 +821,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -661,8 +832,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_operations.py index 81a54a901675..4642001c36c7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_queue_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum27], subscription_id: str, - *, - json: Optional[_models.QueueServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum27], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +211,163 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum27], parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :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: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum27], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum27], + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties 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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +375,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum27], **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +443,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_operations.py index 95e9d1e8701a..c92d305bc111 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_operations.py index ca3a6ad053fd..e4b81aaa3116 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +29,110 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,153 +140,129 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -304,280 +270,238 @@ def build_list_keys_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "kerb", + expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_restore_blob_ranges_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobRestoreParameters] = None, - content: Any = None, - **kwargs: Any +def build_restore_blob_ranges_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revoke_user_delegation_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: """ @@ -598,45 +522,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2019_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -644,55 +621,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -700,10 +685,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -712,22 +696,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -736,14 +721,17 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCreateParameters + :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 @@ -755,20 +743,98 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -776,79 +842,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -856,10 +917,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -869,15 +929,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -885,40 +944,43 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2019_06_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -926,32 +988,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -964,32 +1026,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountUpdateParameters + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -998,7 +1145,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1006,58 +1154,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1065,13 +1210,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1088,10 +1237,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1101,49 +1248,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1151,14 +1294,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1175,10 +1321,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1188,57 +1332,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1246,65 +1386,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2019_06_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1313,7 +1526,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1321,63 +1535,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1386,7 +1673,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1394,63 +1682,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1459,7 +1818,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1467,50 +1827,47 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1518,10 +1875,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1531,26 +1887,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1562,85 +1912,90 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1648,10 +2003,9 @@ def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1659,38 +2013,80 @@ def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace + @overload def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1702,20 +2098,54 @@ def begin_restore_blob_ranges( :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.BlobRestoreParameters 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. + :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2019_06_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1723,79 +2153,76 @@ def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1803,10 +2230,9 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1816,5 +2242,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_operations.py index 40a41d36533a..b8083a7a82ca 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,204 +27,194 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableOperations: """ @@ -238,52 +235,47 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def create(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -291,71 +283,65 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -363,71 +349,65 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -435,71 +415,67 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -507,10 +483,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -520,49 +495,47 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -570,15 +543,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -595,10 +570,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,8 +581,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_operations.py index bd44848a61ce..7382f69172e2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_table_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum27], subscription_id: str, - *, - json: Optional[_models.TableServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum27], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +211,163 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum27], parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :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: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum27], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum27], + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties 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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +375,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum27], **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2019_06_01.models.Enum27 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2019_06_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +443,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_operations.py index d05d3fed27dc..ee7dc2766ceb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2019_06_01/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,41 +87,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2019_06_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2019-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2019-06-01")) # type: Literal["2019-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -122,14 +128,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -146,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -159,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_configuration.py index e2e41142887d..08920313ede2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-08-01-preview". 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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-08-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-08-01-preview") # type: Literal["2020-08-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json index 10da1f8d0ba1..870cc0f8cdae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -117,4 +117,4 @@ "table_services": "TableServicesOperations", "table": "TableOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py index b368bd63bfe9..03196a3c70ec 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_storage_management_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -76,9 +96,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes azure.mgmt.storage.v2020_08_01_preview.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2020_08_01_preview.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -96,28 +116,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -136,37 +152,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -175,7 +170,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_configuration.py index 2a4f903adb09..afc34239b747 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2020-08-01-preview". 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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2020-08-01-preview") # type: str + api_version = kwargs.pop("api_version", "2020-08-01-preview") # type: Literal["2020-08-01-preview"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py index 2d630b1b84ed..4e7a99d39e9a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/_storage_management_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -77,9 +97,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes azure.mgmt.storage.v2020_08_01_preview.aio.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2020_08_01_preview.aio.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -97,28 +117,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -137,37 +153,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -176,7 +171,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/__init__.py index 9a63fd415725..a7c5747747ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/__init__.py @@ -29,26 +29,27 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_operations.py index d308435f573e..51e4b7471a41 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_containers_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -43,7 +72,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,18 +79,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListContainerItems]: + ) -> AsyncIterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -71,36 +99,42 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -108,18 +142,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -136,10 +169,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,19 +180,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -169,37 +200,126 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] - - _json = self._serialize.body(blob_container, 'BlobContainer') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -209,7 +329,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -217,10 +338,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -228,63 +348,151 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] - - _json = self._serialize.body(blob_container, 'BlobContainer') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -294,7 +502,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -302,72 +511,70 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -375,72 +582,70 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -448,10 +653,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -461,16 +665,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -478,37 +683,126 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - - _json = self._serialize.body(legal_hold, 'LegalHold') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -518,7 +812,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -526,70 +821,157 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - - _json = self._serialize.body(legal_hold, 'LegalHold') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -599,7 +981,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -607,51 +990,55 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum28], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -659,44 +1046,146 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum28], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum28], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] - - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -704,10 +1193,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -715,17 +1203,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -733,6 +1220,7 @@ async def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum28], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -740,52 +1228,54 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -793,10 +1283,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -804,17 +1293,16 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -822,6 +1310,7 @@ async def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum28], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -831,52 +1320,54 @@ async def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -884,10 +1375,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -895,71 +1385,69 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -967,10 +1455,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -978,19 +1465,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -998,6 +1484,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1005,56 +1493,157 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] - - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1062,10 +1651,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1073,65 +1661,153 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequest + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] - - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1141,7 +1817,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1149,22 +1826,20 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_operations.py index 8b689eac9a47..8b4d05d7a0f5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_inventory_policies_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_inventory_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._blob_inventory_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobInventoryPoliciesOperations: """ .. warning:: @@ -43,52 +63,55 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +119,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,68 +129,153 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy 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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -176,10 +283,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,61 +293,64 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -249,10 +358,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -263,51 +371,52 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -315,15 +424,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -340,10 +451,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -354,8 +463,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_operations.py index 99809800da5a..86ad29bd9ae9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_blob_services_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -43,48 +62,51 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +114,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +141,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,66 +152,151 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum28], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum28], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum28], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -197,72 +304,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum28], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -270,22 +374,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_operations.py index 6f9f9f9f1e8a..72b0b4861320 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_deleted_accounts_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DeletedAccountsOperations: """ .. warning:: @@ -43,38 +58,39 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) + :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -82,13 +98,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -105,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -119,48 +137,45 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async - async def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -168,10 +183,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,12 +193,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_operations.py index 9dc5546fe9c8..edd9471562c9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_encryption_scopes_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._encryption_scopes_operations import build_get_request, build_list_request, build_patch_request, build_put_request -T = TypeVar('T') +from ...operations._encryption_scopes_operations import ( + build_get_request, + build_list_request, + build_patch_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EncryptionScopesOperations: """ .. warning:: @@ -43,14 +63,15 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -58,47 +79,139 @@ async def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -106,10 +219,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -118,73 +230,162 @@ async def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace_async + @overload async def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +393,9 @@ async def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,62 +403,61 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -266,10 +465,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -277,58 +475,59 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EncryptionScopeListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) + :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -336,15 +535,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -361,10 +562,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -374,8 +573,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_operations.py index 680f393846df..be2f6a133b08 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileServicesOperations: """ .. warning:: @@ -41,46 +59,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +104,164 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum28], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum28], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum28], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +269,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum28], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +339,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_operations.py index 826ee9bb9a06..2b20e34aa9f4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_file_shares_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_shares_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_restore_request, build_update_request -T = TypeVar('T') +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_restore_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileSharesOperations: """ .. warning:: @@ -43,7 +65,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,17 +72,17 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, + expand: Optional[Union[str, _models.ListSharesExpand]] = None, **kwargs: Any - ) -> AsyncIterable[_models.FileShareItems]: + ) -> AsyncIterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -69,37 +90,43 @@ def list( :param filter: Optional. When specified, only share names starting with the filter will be listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. Default value - is None. + :param expand: Optional, used to expand the properties within share's properties. Known values + are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) + :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -107,18 +134,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -135,10 +161,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -148,20 +172,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, - expand: Optional[str] = "snapshots", + expand: Literal["snapshots"] = "snapshots", + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -169,51 +193,149 @@ async def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare - :param expand: Optional, used to create a snapshot. Known values are "snapshots" or None. + :param expand: Optional, used to create a snapshot. Known values are "snapshots" and None. + Default value is "snapshots". + :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Literal["snapshots"] = "snapshots", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to create a snapshot. Known values are "snapshots" and None. Default value is "snapshots". :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Literal["snapshots"] = "snapshots", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare or IO + :param expand: Optional, used to create a snapshot. Known values are "snapshots" and None. + Default value is "snapshots". + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -221,10 +343,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -232,63 +353,151 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -298,7 +507,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -306,25 +516,23 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def get( @@ -332,56 +540,60 @@ async def get( resource_group_name: str, account_name: str, share_name: str, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Known values - are "stats" or None. Default value is "stats". + are "stats" and None. Default value is "stats". :type expand: str :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -389,25 +601,23 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -421,44 +631,48 @@ async def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -466,10 +680,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -479,52 +692,137 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedShare + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -534,7 +832,8 @@ async def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -542,10 +841,9 @@ async def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -555,5 +853,4 @@ async def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_operations.py index 254236fae99a..547bdd7a6576 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,52 +59,55 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -94,78 +115,162 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy + :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: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -173,71 +278,73 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -245,10 +352,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -258,5 +364,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_operations.py index e019fe59c7de..6b30a89233e0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_object_replication_policies_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._object_replication_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._object_replication_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ObjectReplicationPoliciesOperations: """ .. warning:: @@ -43,49 +63,51 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +142,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,56 +154,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -189,10 +209,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -200,68 +219,152 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy 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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -269,10 +372,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,60 +382,59 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -341,10 +442,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -355,5 +455,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_operations.py index c0beaa620d09..b5317ab67133 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,38 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +96,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +134,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_endpoint_connections_operations.py index 84c98a37d040..4446161a15c8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request, build_get_request, build_list_request, build_put_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -43,49 +63,51 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +142,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +153,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +208,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +218,151 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection + :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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection 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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +370,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +380,59 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +440,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,5 +453,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_link_resources_operations.py index a45b623bf0a6..bb0c37412d60 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,46 +55,46 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -88,22 +102,20 @@ async def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_operations.py index 918f2765b9c7..316341728898 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._queue_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueOperations: """ .. warning:: @@ -43,60 +64,147 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue 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 - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -104,79 +212,165 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -184,72 +378,70 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -257,72 +449,70 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -330,10 +520,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -343,8 +532,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -354,15 +542,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListQueueResource]: + ) -> AsyncIterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -371,32 +559,38 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) + :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -404,17 +598,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -431,10 +625,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -444,8 +636,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_operations.py index 03c0b7fd1a6a..49cd846b27d2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_queue_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._queue_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueServicesOperations: """ .. warning:: @@ -41,46 +59,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +104,165 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum28], parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :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: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum28], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum28], + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties 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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +270,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum28], **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +340,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_operations.py index c527c7bf342c..14aef42c9e52 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,39 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) + :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +97,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +124,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +135,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_operations.py index 58ecdbb24035..0bb359e56702 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,31 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_restore_blob_ranges_request_initial, build_revoke_user_delegation_keys_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_restore_blob_ranges_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +75,101 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCheckNameAvailabilityParameters 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 - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +177,65 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] - - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') - - request = build_create_request_initial( + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +243,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +254,105 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def begin_create( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +361,19 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCreateParameters + 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 @@ -203,20 +386,19 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +406,76 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +483,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,15 +495,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -333,40 +510,45 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,32 +556,104 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async async def update( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountUpdateParameters, + parameters: Union[_models.StorageAccountUpdateParameters, IO], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -412,32 +666,48 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountUpdateParameters + 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -446,7 +716,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -454,58 +725,58 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -513,13 +784,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -536,10 +811,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,49 +822,50 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -599,14 +873,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -623,10 +900,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -636,57 +911,55 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -694,65 +967,140 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -761,7 +1109,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -769,63 +1118,138 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -834,7 +1258,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -842,63 +1267,136 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ServiceSasParameters 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 - :return: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -907,7 +1405,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -915,50 +1414,49 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -966,10 +1464,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -979,26 +1476,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1010,85 +1501,94 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - - _json = self._serialize.body(parameters, 'BlobRestoreParameters') - - request = build_restore_blob_ranges_request_initial( + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") + + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1096,10 +1596,9 @@ async def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1107,38 +1606,42 @@ async def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - @distributed_trace_async + @overload async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreParameters + :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 @@ -1151,20 +1654,96 @@ async def begin_restore_blob_ranges( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreParameters 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. + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1172,79 +1751,78 @@ async def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1252,10 +1830,9 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1265,5 +1842,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_operations.py index 8bd2073cb662..0c159cc63026 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._table_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableOperations: """ .. warning:: @@ -43,52 +64,51 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -96,71 +116,69 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -168,71 +186,67 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,71 +254,69 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -312,10 +324,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -325,50 +336,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) + :return: An iterator like instance of either Table or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -376,15 +387,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -401,10 +414,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -414,8 +425,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_operations.py index 9817b6eb6a49..c5e91c3b7203 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_table_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._table_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableServicesOperations: """ .. warning:: @@ -41,46 +59,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +104,165 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum28], parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :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: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum28], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum28], + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties 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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +270,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum28], **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +340,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_operations.py index b252cedde1a4..00b2aa870aed 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,42 +57,43 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) + :return: An iterator like instance of either Usage or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -85,14 +101,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -109,10 +128,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -122,8 +139,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/__init__.py index 706491a695d5..f07fee0a60f1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/__init__.py @@ -133,241 +133,241 @@ from ._models_py3 import UsageName from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountStatus, - BlobInventoryPolicyName, - BlobRestoreProgressStatus, - Bypass, - CorsRuleAllowedMethodsItem, - CreatedByType, - DefaultAction, - DirectoryServiceOptions, - EnabledProtocols, - EncryptionScopeSource, - EncryptionScopeState, - ExtendedLocationTypes, - GeoReplicationStatus, - HttpProtocol, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - InventoryRuleType, - KeyPermission, - KeySource, - KeyType, - Kind, - LargeFileSharesState, - LeaseContainerRequestAction, - LeaseDuration, - LeaseState, - LeaseStatus, - ListContainersInclude, - ListSharesExpand, - ManagementPolicyName, - MinimumTlsVersion, - Name, - Permissions, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisioningState, - PublicAccess, - Reason, - ReasonCode, - RootSquashType, - RoutingChoice, - RuleType, - Services, - ShareAccessTier, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - StorageAccountExpand, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import BlobInventoryPolicyName +from ._storage_management_client_enums import BlobRestoreProgressStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CorsRuleAllowedMethodsItem +from ._storage_management_client_enums import CreatedByType +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import EnabledProtocols +from ._storage_management_client_enums import EncryptionScopeSource +from ._storage_management_client_enums import EncryptionScopeState +from ._storage_management_client_enums import Enum28 +from ._storage_management_client_enums import ExtendedLocationTypes +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import InventoryRuleType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import KeyType +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ListContainersInclude +from ._storage_management_client_enums import ListSharesExpand +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Name +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._storage_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RootSquashType +from ._storage_management_client_enums import RoutingChoice +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import ShareAccessTier +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import StorageAccountExpand +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'ActiveDirectoryProperties', - 'AzureEntityResource', - 'AzureFilesIdentityBasedAuthentication', - 'BlobContainer', - 'BlobInventoryPolicy', - 'BlobInventoryPolicyDefinition', - 'BlobInventoryPolicyFilter', - 'BlobInventoryPolicyRule', - 'BlobInventoryPolicySchema', - 'BlobRestoreParameters', - 'BlobRestoreRange', - 'BlobRestoreStatus', - 'BlobServiceItems', - 'BlobServiceProperties', - 'ChangeFeed', - 'CheckNameAvailabilityResult', - 'CloudErrorBody', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DateAfterCreation', - 'DateAfterModification', - 'DeleteRetentionPolicy', - 'DeletedAccount', - 'DeletedAccountListResult', - 'DeletedShare', - 'Dimension', - 'Encryption', - 'EncryptionScope', - 'EncryptionScopeKeyVaultProperties', - 'EncryptionScopeListResult', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'ErrorResponse', - 'ErrorResponseBody', - 'ExtendedLocation', - 'FileServiceItems', - 'FileServiceProperties', - 'FileShare', - 'FileShareItem', - 'FileShareItems', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'KeyVaultProperties', - 'LastAccessTimeTrackingPolicy', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListBlobInventoryPolicy', - 'ListContainerItem', - 'ListContainerItems', - 'ListQueue', - 'ListQueueResource', - 'ListQueueServices', - 'ListServiceSasResponse', - 'ListTableResource', - 'ListTableServices', - 'ManagementPolicy', - 'ManagementPolicyAction', - 'ManagementPolicyBaseBlob', - 'ManagementPolicyDefinition', - 'ManagementPolicyFilter', - 'ManagementPolicyRule', - 'ManagementPolicySchema', - 'ManagementPolicySnapShot', - 'ManagementPolicyVersion', - 'MetricSpecification', - 'Multichannel', - 'NetworkRuleSet', - 'ObjectReplicationPolicies', - 'ObjectReplicationPolicy', - 'ObjectReplicationPolicyFilter', - 'ObjectReplicationPolicyRule', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProtocolSettings', - 'ProxyResource', - 'QueueServiceProperties', - 'Resource', - 'ResourceAccessRule', - 'RestorePolicyProperties', - 'Restriction', - 'RoutingPreference', - 'SKUCapability', - 'ServiceSasParameters', - 'ServiceSpecification', - 'Sku', - 'SkuInformation', - 'SmbSetting', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountInternetEndpoints', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountMicrosoftEndpoints', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageQueue', - 'StorageSkuListResult', - 'SystemData', - 'Table', - 'TableServiceProperties', - 'TagFilter', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'BlobInventoryPolicyName', - 'BlobRestoreProgressStatus', - 'Bypass', - 'CorsRuleAllowedMethodsItem', - 'CreatedByType', - 'DefaultAction', - 'DirectoryServiceOptions', - 'EnabledProtocols', - 'EncryptionScopeSource', - 'EncryptionScopeState', - 'ExtendedLocationTypes', - 'GeoReplicationStatus', - 'HttpProtocol', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'InventoryRuleType', - 'KeyPermission', - 'KeySource', - 'KeyType', - 'Kind', - 'LargeFileSharesState', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseState', - 'LeaseStatus', - 'ListContainersInclude', - 'ListSharesExpand', - 'ManagementPolicyName', - 'MinimumTlsVersion', - 'Name', - 'Permissions', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'ProvisioningState', - 'PublicAccess', - 'Reason', - 'ReasonCode', - 'RootSquashType', - 'RoutingChoice', - 'RuleType', - 'Services', - 'ShareAccessTier', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'StorageAccountExpand', - 'UsageUnit', + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobInventoryPolicy", + "BlobInventoryPolicyDefinition", + "BlobInventoryPolicyFilter", + "BlobInventoryPolicyRule", + "BlobInventoryPolicySchema", + "BlobRestoreParameters", + "BlobRestoreRange", + "BlobRestoreStatus", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorBody", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "DeletedAccount", + "DeletedAccountListResult", + "DeletedShare", + "Dimension", + "Encryption", + "EncryptionScope", + "EncryptionScopeKeyVaultProperties", + "EncryptionScopeListResult", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ErrorResponse", + "ErrorResponseBody", + "ExtendedLocation", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "KeyVaultProperties", + "LastAccessTimeTrackingPolicy", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListBlobInventoryPolicy", + "ListContainerItem", + "ListContainerItems", + "ListQueue", + "ListQueueResource", + "ListQueueServices", + "ListServiceSasResponse", + "ListTableResource", + "ListTableServices", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "ManagementPolicyVersion", + "MetricSpecification", + "Multichannel", + "NetworkRuleSet", + "ObjectReplicationPolicies", + "ObjectReplicationPolicy", + "ObjectReplicationPolicyFilter", + "ObjectReplicationPolicyRule", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProtocolSettings", + "ProxyResource", + "QueueServiceProperties", + "Resource", + "ResourceAccessRule", + "RestorePolicyProperties", + "Restriction", + "RoutingPreference", + "SKUCapability", + "ServiceSasParameters", + "ServiceSpecification", + "Sku", + "SkuInformation", + "SmbSetting", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountInternetEndpoints", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountMicrosoftEndpoints", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageQueue", + "StorageSkuListResult", + "SystemData", + "Table", + "TableServiceProperties", + "TagFilter", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "BlobInventoryPolicyName", + "BlobRestoreProgressStatus", + "Bypass", + "CorsRuleAllowedMethodsItem", + "CreatedByType", + "DefaultAction", + "DirectoryServiceOptions", + "EnabledProtocols", + "EncryptionScopeSource", + "EncryptionScopeState", + "Enum28", + "ExtendedLocationTypes", + "GeoReplicationStatus", + "HttpProtocol", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "InventoryRuleType", + "KeyPermission", + "KeySource", + "KeyType", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseState", + "LeaseStatus", + "ListContainersInclude", + "ListSharesExpand", + "ManagementPolicyName", + "MinimumTlsVersion", + "Name", + "Permissions", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicAccess", + "Reason", + "ReasonCode", + "RootSquashType", + "RoutingChoice", + "RuleType", + "Services", + "ShareAccessTier", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "StorageAccountExpand", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py index 652dca64d096..529fef4fa68f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,65 +8,70 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -82,34 +88,35 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -120,42 +127,42 @@ def __init__( self.key_to_sign = key_to_sign -class ActiveDirectoryProperties(msrest.serialization.Model): +class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). All required parameters must be populated in order to send to Azure. - :ivar domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :vartype domain_name: str - :ivar net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. Required. :vartype net_bios_domain_name: str - :ivar forest_name: Required. Specifies the Active Directory forest to get. + :ivar forest_name: Specifies the Active Directory forest to get. Required. :vartype forest_name: str - :ivar domain_guid: Required. Specifies the domain GUID. + :ivar domain_guid: Specifies the domain GUID. Required. :vartype domain_guid: str - :ivar domain_sid: Required. Specifies the security identifier (SID). + :ivar domain_sid: Specifies the security identifier (SID). Required. :vartype domain_sid: str - :ivar azure_storage_sid: Required. Specifies the security identifier (SID) for Azure Storage. + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. Required. :vartype azure_storage_sid: str """ _validation = { - 'domain_name': {'required': True}, - 'net_bios_domain_name': {'required': True}, - 'forest_name': {'required': True}, - 'domain_guid': {'required': True}, - 'domain_sid': {'required': True}, - 'azure_storage_sid': {'required': True}, + "domain_name": {"required": True}, + "net_bios_domain_name": {"required": True}, + "forest_name": {"required": True}, + "domain_guid": {"required": True}, + "domain_sid": {"required": True}, + "azure_storage_sid": {"required": True}, } _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'net_bios_domain_name': {'key': 'netBiosDomainName', 'type': 'str'}, - 'forest_name': {'key': 'forestName', 'type': 'str'}, - 'domain_guid': {'key': 'domainGuid', 'type': 'str'}, - 'domain_sid': {'key': 'domainSid', 'type': 'str'}, - 'azure_storage_sid': {'key': 'azureStorageSid', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, } def __init__( @@ -170,22 +177,22 @@ def __init__( **kwargs ): """ - :keyword domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :paramtype domain_name: str - :keyword net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. Required. :paramtype net_bios_domain_name: str - :keyword forest_name: Required. Specifies the Active Directory forest to get. + :keyword forest_name: Specifies the Active Directory forest to get. Required. :paramtype forest_name: str - :keyword domain_guid: Required. Specifies the domain GUID. + :keyword domain_guid: Specifies the domain GUID. Required. :paramtype domain_guid: str - :keyword domain_sid: Required. Specifies the security identifier (SID). + :keyword domain_sid: Specifies the security identifier (SID). Required. :paramtype domain_sid: str - :keyword azure_storage_sid: Required. Specifies the security identifier (SID) for Azure - Storage. + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + Required. :paramtype azure_storage_sid: str """ - super(ActiveDirectoryProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.net_bios_domain_name = net_bios_domain_name self.forest_name = forest_name @@ -194,7 +201,7 @@ def __init__( self.azure_storage_sid = azure_storage_sid -class Resource(msrest.serialization.Model): +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. @@ -210,24 +217,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -251,36 +254,32 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): +class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Known values - are: "None", "AADDS", "AD". + :ivar directory_service_options: Indicates the directory service used. Required. Known values + are: "None", "AADDS", and "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2020_08_01_preview.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -289,12 +288,12 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): """ _validation = { - 'directory_service_options': {'required': True}, + "directory_service_options": {"required": True}, } _attribute_map = { - 'directory_service_options': {'key': 'directoryServiceOptions', 'type': 'str'}, - 'active_directory_properties': {'key': 'activeDirectoryProperties', 'type': 'ActiveDirectoryProperties'}, + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, } def __init__( @@ -305,20 +304,20 @@ def __init__( **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Known - values are: "None", "AADDS", "AD". + :keyword directory_service_options: Indicates the directory service used. Required. Known + values are: "None", "AADDS", and "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2020_08_01_preview.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. :paramtype active_directory_properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ActiveDirectoryProperties """ - super(AzureFilesIdentityBasedAuthentication, self).__init__(**kwargs) + super().__init__(**kwargs) self.directory_service_options = directory_service_options self.active_directory_properties = active_directory_properties -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -348,17 +347,18 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -379,45 +379,45 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -437,12 +437,12 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -483,79 +483,69 @@ class BlobInventoryPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified_time": {"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'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'BlobInventoryPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "BlobInventoryPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.BlobInventoryPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs): """ :keyword policy: The storage account blob inventory policy object. It is composed of policy rules. :paramtype policy: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicySchema """ - super(BlobInventoryPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.last_modified_time = None self.policy = policy -class BlobInventoryPolicyDefinition(msrest.serialization.Model): +class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. Each definition consists of a set of filters. All required parameters must be populated in order to send to Azure. - :ivar filters: Required. An object that defines the filter set. + :ivar filters: An object that defines the filter set. Required. :vartype filters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyFilter """ _validation = { - 'filters': {'required': True}, + "filters": {"required": True}, } _attribute_map = { - 'filters': {'key': 'filters', 'type': 'BlobInventoryPolicyFilter'}, + "filters": {"key": "filters", "type": "BlobInventoryPolicyFilter"}, } - def __init__( - self, - *, - filters: "_models.BlobInventoryPolicyFilter", - **kwargs - ): + def __init__(self, *, filters: "_models.BlobInventoryPolicyFilter", **kwargs): """ - :keyword filters: Required. An object that defines the filter set. + :keyword filters: An object that defines the filter set. Required. :paramtype filters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyFilter """ - super(BlobInventoryPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.filters = filters -class BlobInventoryPolicyFilter(msrest.serialization.Model): +class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for blob prefixes to be matched. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Valid values include blockBlob, - appendBlob, pageBlob. Hns accounts does not support pageBlobs. + :ivar blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. Required. :vartype blob_types: list[str] :ivar include_blob_versions: Includes blob versions in blob inventory when value set to true. :vartype include_blob_versions: bool @@ -564,14 +554,14 @@ class BlobInventoryPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'include_blob_versions': {'key': 'includeBlobVersions', 'type': 'bool'}, - 'include_snapshots': {'key': 'includeSnapshots', 'type': 'bool'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "include_blob_versions": {"key": "includeBlobVersions", "type": "bool"}, + "include_snapshots": {"key": "includeSnapshots", "type": "bool"}, } def __init__( @@ -586,8 +576,8 @@ def __init__( """ :keyword prefix_match: An array of strings for blob prefixes to be matched. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Valid values include - blockBlob, appendBlob, pageBlob. Hns accounts does not support pageBlobs. + :keyword blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. Required. :paramtype blob_types: list[str] :keyword include_blob_versions: Includes blob versions in blob inventory when value set to true. @@ -595,93 +585,86 @@ def __init__( :keyword include_snapshots: Includes blob snapshots in blob inventory when value set to true. :paramtype include_snapshots: bool """ - super(BlobInventoryPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.include_blob_versions = include_blob_versions self.include_snapshots = include_snapshots -class BlobInventoryPolicyRule(msrest.serialization.Model): +class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Rule is enabled when set to true. + :ivar enabled: Rule is enabled when set to true. Required. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar definition: Required. An object that defines the blob inventory policy rule. + :ivar definition: An object that defines the blob inventory policy rule. Required. :vartype definition: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyDefinition """ _validation = { - 'enabled': {'required': True}, - 'name': {'required': True}, - 'definition': {'required': True}, + "enabled": {"required": True}, + "name": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'BlobInventoryPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "definition": {"key": "definition", "type": "BlobInventoryPolicyDefinition"}, } - def __init__( - self, - *, - enabled: bool, - name: str, - definition: "_models.BlobInventoryPolicyDefinition", - **kwargs - ): + def __init__(self, *, enabled: bool, name: str, definition: "_models.BlobInventoryPolicyDefinition", **kwargs): """ - :keyword enabled: Required. Rule is enabled when set to true. + :keyword enabled: Rule is enabled when set to true. Required. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword definition: Required. An object that defines the blob inventory policy rule. + :keyword definition: An object that defines the blob inventory policy rule. Required. :paramtype definition: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyDefinition """ - super(BlobInventoryPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.definition = definition -class BlobInventoryPolicySchema(msrest.serialization.Model): +class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Policy is enabled if set to true. + :ivar enabled: Policy is enabled if set to true. Required. :vartype enabled: bool - :ivar destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :ivar destination: Container name where blob inventory files are stored. Must be pre-created. + Required. :vartype destination: str - :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". + :ivar type: The valid value is Inventory. Required. "Inventory" :vartype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.InventoryRuleType - :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :ivar rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :vartype rules: list[~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyRule] """ _validation = { - 'enabled': {'required': True}, - 'destination': {'required': True}, - 'type': {'required': True}, - 'rules': {'required': True}, + "enabled": {"required": True}, + "destination": {"required": True}, + "type": {"required": True}, + "rules": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'destination': {'key': 'destination', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rules': {'key': 'rules', 'type': '[BlobInventoryPolicyRule]'}, + "enabled": {"key": "enabled", "type": "bool"}, + "destination": {"key": "destination", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rules": {"key": "rules", "type": "[BlobInventoryPolicyRule]"}, } def __init__( @@ -694,103 +677,91 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Policy is enabled if set to true. + :keyword enabled: Policy is enabled if set to true. Required. :paramtype enabled: bool - :keyword destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :keyword destination: Container name where blob inventory files are stored. Must be + pre-created. Required. :paramtype destination: str - :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". + :keyword type: The valid value is Inventory. Required. "Inventory" :paramtype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.InventoryRuleType - :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :keyword rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :paramtype rules: list[~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyRule] """ - super(BlobInventoryPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.destination = destination self.type = type self.rules = rules -class BlobRestoreParameters(msrest.serialization.Model): +class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. All required parameters must be populated in order to send to Azure. - :ivar time_to_restore: Required. Restore blob to the specified time. + :ivar time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime - :ivar blob_ranges: Required. Blob ranges to restore. + :ivar blob_ranges: Blob ranges to restore. Required. :vartype blob_ranges: list[~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreRange] """ _validation = { - 'time_to_restore': {'required': True}, - 'blob_ranges': {'required': True}, + "time_to_restore": {"required": True}, + "blob_ranges": {"required": True}, } _attribute_map = { - 'time_to_restore': {'key': 'timeToRestore', 'type': 'iso-8601'}, - 'blob_ranges': {'key': 'blobRanges', 'type': '[BlobRestoreRange]'}, + "time_to_restore": {"key": "timeToRestore", "type": "iso-8601"}, + "blob_ranges": {"key": "blobRanges", "type": "[BlobRestoreRange]"}, } - def __init__( - self, - *, - time_to_restore: datetime.datetime, - blob_ranges: List["_models.BlobRestoreRange"], - **kwargs - ): + def __init__(self, *, time_to_restore: datetime.datetime, blob_ranges: List["_models.BlobRestoreRange"], **kwargs): """ - :keyword time_to_restore: Required. Restore blob to the specified time. + :keyword time_to_restore: Restore blob to the specified time. Required. :paramtype time_to_restore: ~datetime.datetime - :keyword blob_ranges: Required. Blob ranges to restore. + :keyword blob_ranges: Blob ranges to restore. Required. :paramtype blob_ranges: list[~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreRange] """ - super(BlobRestoreParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_to_restore = time_to_restore self.blob_ranges = blob_ranges -class BlobRestoreRange(msrest.serialization.Model): +class BlobRestoreRange(_serialization.Model): """Blob range. All required parameters must be populated in order to send to Azure. - :ivar start_range: Required. Blob start range. This is inclusive. Empty means account start. + :ivar start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str - :ivar end_range: Required. Blob end range. This is exclusive. Empty means account end. + :ivar end_range: Blob end range. This is exclusive. Empty means account end. Required. :vartype end_range: str """ _validation = { - 'start_range': {'required': True}, - 'end_range': {'required': True}, + "start_range": {"required": True}, + "end_range": {"required": True}, } _attribute_map = { - 'start_range': {'key': 'startRange', 'type': 'str'}, - 'end_range': {'key': 'endRange', 'type': 'str'}, + "start_range": {"key": "startRange", "type": "str"}, + "end_range": {"key": "endRange", "type": "str"}, } - def __init__( - self, - *, - start_range: str, - end_range: str, - **kwargs - ): + def __init__(self, *, start_range: str, end_range: str, **kwargs): """ - :keyword start_range: Required. Blob start range. This is inclusive. Empty means account start. + :keyword start_range: Blob start range. This is inclusive. Empty means account start. Required. :paramtype start_range: str - :keyword end_range: Required. Blob end range. This is exclusive. Empty means account end. + :keyword end_range: Blob end range. This is exclusive. Empty means account end. Required. :paramtype end_range: str """ - super(BlobRestoreRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_range = start_range self.end_range = end_range -class BlobRestoreStatus(msrest.serialization.Model): +class BlobRestoreStatus(_serialization.Model): """Blob restore status. Variables are only populated by the server, and will be ignored when sending a request. @@ -798,7 +769,7 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", - "Complete", "Failed". + "Complete", and "Failed". :vartype status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. @@ -810,33 +781,29 @@ class BlobRestoreStatus(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'restore_id': {'readonly': True}, - 'parameters': {'readonly': True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "restore_id": {"readonly": True}, + "parameters": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'restore_id': {'key': 'restoreId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'BlobRestoreParameters'}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "restore_id": {"key": "restoreId", "type": "str"}, + "parameters": {"key": "parameters", "type": "BlobRestoreParameters"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobRestoreStatus, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.failure_reason = None self.restore_id = None self.parameters = None -class BlobServiceItems(msrest.serialization.Model): +class BlobServiceItems(_serialization.Model): """BlobServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -846,24 +813,20 @@ class BlobServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobServiceProperties]'}, + "value": {"key": "value", "type": "[BlobServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class BlobServiceProperties(Resource): +class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attributes """The properties of a storage account’s Blob service. Variables are only populated by the server, and will be ignored when sending a request. @@ -907,26 +870,32 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'is_versioning_enabled': {'key': 'properties.isVersioningEnabled', 'type': 'bool'}, - 'automatic_snapshot_policy_enabled': {'key': 'properties.automaticSnapshotPolicyEnabled', 'type': 'bool'}, - 'change_feed': {'key': 'properties.changeFeed', 'type': 'ChangeFeed'}, - 'restore_policy': {'key': 'properties.restorePolicy', 'type': 'RestorePolicyProperties'}, - 'container_delete_retention_policy': {'key': 'properties.containerDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'last_access_time_tracking_policy': {'key': 'properties.lastAccessTimeTrackingPolicy', 'type': 'LastAccessTimeTrackingPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "is_versioning_enabled": {"key": "properties.isVersioningEnabled", "type": "bool"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, + "restore_policy": {"key": "properties.restorePolicy", "type": "RestorePolicyProperties"}, + "container_delete_retention_policy": { + "key": "properties.containerDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "last_access_time_tracking_policy": { + "key": "properties.lastAccessTimeTrackingPolicy", + "type": "LastAccessTimeTrackingPolicy", + }, } def __init__( @@ -974,7 +943,7 @@ def __init__( :paramtype last_access_time_tracking_policy: ~azure.mgmt.storage.v2020_08_01_preview.models.LastAccessTimeTrackingPolicy """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.default_service_version = default_service_version @@ -987,7 +956,7 @@ def __init__( self.last_access_time_tracking_policy = last_access_time_tracking_policy -class ChangeFeed(msrest.serialization.Model): +class ChangeFeed(_serialization.Model): """The blob service properties for change feed events. :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. @@ -999,21 +968,15 @@ class ChangeFeed(msrest.serialization.Model): """ _validation = { - 'retention_in_days': {'maximum': 146000, 'minimum': 1}, + "retention_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_in_days': {'key': 'retentionInDays', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_in_days": {"key": "retentionInDays", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - retention_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, retention_in_days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. :paramtype enabled: bool @@ -1022,12 +985,12 @@ def __init__( retention of the change feed. :paramtype retention_in_days: int """ - super(ChangeFeed, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.retention_in_days = retention_in_days -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1037,7 +1000,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1045,30 +1008,26 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1085,10 +1044,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -1113,50 +1072,50 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2020_08_01_preview.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2020_08_01_preview.models.CorsRuleAllowedMethodsItem] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -1170,24 +1129,24 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2020_08_01_preview.models.CorsRuleAllowedMethodsItem] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -1195,7 +1154,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -1204,31 +1163,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2020_08_01_preview.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -1236,68 +1190,57 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DateAfterCreation(msrest.serialization.Model): +class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. All required parameters must be populated in order to send to Azure. - :ivar days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :vartype days_after_creation_greater_than: float """ _validation = { - 'days_after_creation_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, } - def __init__( - self, - *, - days_after_creation_greater_than: float, - **kwargs - ): + def __init__(self, *, days_after_creation_greater_than: float, **kwargs): """ - :keyword days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :paramtype days_after_creation_greater_than: float """ - super(DateAfterCreation, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_creation_greater_than = days_after_creation_greater_than -class DateAfterModification(msrest.serialization.Model): +class DateAfterModification(_serialization.Model): """Object to define the number of days after object last modification Or last access. Properties daysAfterModificationGreaterThan and daysAfterLastAccessTimeGreaterThan are mutually exclusive. :ivar days_after_modification_greater_than: Value indicating the age in days after last @@ -1310,13 +1253,13 @@ class DateAfterModification(msrest.serialization.Model): """ _validation = { - 'days_after_modification_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_last_access_time_greater_than': {'minimum': 0, 'multiple': 1}, + "days_after_modification_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_access_time_greater_than": {"minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'float'}, - 'days_after_last_access_time_greater_than': {'key': 'daysAfterLastAccessTimeGreaterThan', 'type': 'float'}, + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, + "days_after_last_access_time_greater_than": {"key": "daysAfterLastAccessTimeGreaterThan", "type": "float"}, } def __init__( @@ -1335,7 +1278,7 @@ def __init__( policy. :paramtype days_after_last_access_time_greater_than: float """ - super(DateAfterModification, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_modification_greater_than = days_after_modification_greater_than self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than @@ -1356,24 +1299,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class DeletedAccount(ProxyResource): @@ -1403,34 +1342,30 @@ class DeletedAccount(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'storage_account_resource_id': {'readonly': True}, - 'location': {'readonly': True}, - 'restore_reference': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'deletion_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "storage_account_resource_id": {"readonly": True}, + "location": {"readonly": True}, + "restore_reference": {"readonly": True}, + "creation_time": {"readonly": True}, + "deletion_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'location': {'key': 'properties.location', 'type': 'str'}, - 'restore_reference': {'key': 'properties.restoreReference', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, - 'deletion_time': {'key': 'properties.deletionTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccount, self).__init__(**kwargs) + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "location": {"key": "properties.location", "type": "str"}, + "restore_reference": {"key": "properties.restoreReference", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "str"}, + "deletion_time": {"key": "properties.deletionTime", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_account_resource_id = None self.location = None self.restore_reference = None @@ -1438,7 +1373,7 @@ def __init__( self.deletion_time = None -class DeletedAccountListResult(msrest.serialization.Model): +class DeletedAccountListResult(_serialization.Model): """The response from the List Deleted Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1451,70 +1386,60 @@ class DeletedAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeletedAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeletedAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DeletedShare(msrest.serialization.Model): +class DeletedShare(_serialization.Model): """The deleted share to be restored. All required parameters must be populated in order to send to Azure. - :ivar deleted_share_name: Required. Required. Identify the name of the deleted share that will - be restored. + :ivar deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :vartype deleted_share_name: str - :ivar deleted_share_version: Required. Required. Identify the version of the deleted share that - will be restored. + :ivar deleted_share_version: Required. Identify the version of the deleted share that will be + restored. Required. :vartype deleted_share_version: str """ _validation = { - 'deleted_share_name': {'required': True}, - 'deleted_share_version': {'required': True}, + "deleted_share_name": {"required": True}, + "deleted_share_version": {"required": True}, } _attribute_map = { - 'deleted_share_name': {'key': 'deletedShareName', 'type': 'str'}, - 'deleted_share_version': {'key': 'deletedShareVersion', 'type': 'str'}, + "deleted_share_name": {"key": "deletedShareName", "type": "str"}, + "deleted_share_version": {"key": "deletedShareVersion", "type": "str"}, } - def __init__( - self, - *, - deleted_share_name: str, - deleted_share_version: str, - **kwargs - ): + def __init__(self, *, deleted_share_name: str, deleted_share_version: str, **kwargs): """ - :keyword deleted_share_name: Required. Required. Identify the name of the deleted share that - will be restored. + :keyword deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :paramtype deleted_share_name: str - :keyword deleted_share_version: Required. Required. Identify the version of the deleted share - that will be restored. + :keyword deleted_share_version: Required. Identify the version of the deleted share that will + be restored. Required. :paramtype deleted_share_version: str """ - super(DeletedShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.deleted_share_name = deleted_share_name self.deleted_share_version = deleted_share_version -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. @@ -1525,21 +1450,15 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled. :paramtype enabled: bool @@ -1547,12 +1466,12 @@ def __init__( minimum specified value can be 1 and the maximum value can be 365. :paramtype days: int """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -1562,38 +1481,32 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2020_08_01_preview.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1604,14 +1517,14 @@ class Encryption(msrest.serialization.Model): """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, } def __init__( @@ -1626,9 +1539,9 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2020_08_01_preview.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1637,7 +1550,7 @@ def __init__( :paramtype key_vault_properties: ~azure.mgmt.storage.v2020_08_01_preview.models.KeyVaultProperties """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption @@ -1658,11 +1571,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Known values are: "Enabled", "Disabled". + Disabled. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1676,22 +1589,22 @@ class EncryptionScope(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'EncryptionScopeKeyVaultProperties'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "EncryptionScopeKeyVaultProperties"}, } def __init__( @@ -1704,18 +1617,18 @@ def __init__( ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Known values are: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. :paramtype key_vault_properties: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeKeyVaultProperties """ - super(EncryptionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.state = state self.creation_time = None @@ -1723,7 +1636,7 @@ def __init__( self.key_vault_properties = key_vault_properties -class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): +class EncryptionScopeKeyVaultProperties(_serialization.Model): """The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. :ivar key_uri: The object identifier for a key vault key object. When applied, the encryption @@ -1733,26 +1646,21 @@ class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): """ _attribute_map = { - 'key_uri': {'key': 'keyUri', 'type': 'str'}, + "key_uri": {"key": "keyUri", "type": "str"}, } - def __init__( - self, - *, - key_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_uri: Optional[str] = None, **kwargs): """ :keyword key_uri: The object identifier for a key vault key object. When applied, the encryption scope will use the key referenced by the identifier to enable customer-managed key support on this encryption scope. :paramtype key_uri: str """ - super(EncryptionScopeKeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_uri = key_uri -class EncryptionScopeListResult(msrest.serialization.Model): +class EncryptionScopeListResult(_serialization.Model): """List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. Variables are only populated by the server, and will be ignored when sending a request. @@ -1765,27 +1673,23 @@ class EncryptionScopeListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EncryptionScope]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EncryptionScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(EncryptionScopeListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -1799,26 +1703,22 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Known values are: "Service", "Account". + default service key is used. Known values are: "Service" and "Account". :vartype key_type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.KeyType """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'key_type': {'key': 'keyType', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "key_type": {"key": "keyType", "type": "str"}, } def __init__( - self, - *, - enabled: Optional[bool] = None, - key_type: Optional[Union[str, "_models.KeyType"]] = None, - **kwargs + self, *, enabled: Optional[bool] = None, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is @@ -1826,16 +1726,16 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Known values are: "Service", "Account". + that a default service key is used. Known values are: "Service" and "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.KeyType """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None self.key_type = key_type -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. :ivar blob: The encryption function of the blob storage service. @@ -1849,10 +1749,10 @@ class EncryptionServices(msrest.serialization.Model): """ _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -1874,14 +1774,14 @@ def __init__( :keyword queue: The encryption function of the queue storage service. :paramtype queue: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = table self.queue = queue -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1907,23 +1807,23 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, - 'microsoft_endpoints': {'key': 'microsoftEndpoints', 'type': 'StorageAccountMicrosoftEndpoints'}, - 'internet_endpoints': {'key': 'internetEndpoints', 'type': 'StorageAccountInternetEndpoints'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + "microsoft_endpoints": {"key": "microsoftEndpoints", "type": "StorageAccountMicrosoftEndpoints"}, + "internet_endpoints": {"key": "internetEndpoints", "type": "StorageAccountInternetEndpoints"}, } def __init__( @@ -1941,7 +1841,7 @@ def __init__( :paramtype internet_endpoints: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountInternetEndpoints """ - super(Endpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -1952,7 +1852,7 @@ def __init__( self.internet_endpoints = internet_endpoints -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the storage resource provider. :ivar error: Azure Storage Resource Provider error response body. @@ -1960,24 +1860,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure Storage Resource Provider error response body. :paramtype error: ~azure.mgmt.storage.v2020_08_01_preview.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """Error response body contract. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1989,17 +1884,11 @@ class ErrorResponseBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. @@ -2008,23 +1897,23 @@ def __init__( interface. :paramtype message: str """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ExtendedLocation(msrest.serialization.Model): +class ExtendedLocation(_serialization.Model): """The complex type of the extended location. :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Known values are: "EdgeZone". + :ivar type: The type of the extended location. "EdgeZone" :vartype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ExtendedLocationTypes """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -2037,15 +1926,15 @@ def __init__( """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Known values are: "EdgeZone". + :keyword type: The type of the extended location. "EdgeZone" :paramtype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ExtendedLocationTypes """ - super(ExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class FileServiceItems(msrest.serialization.Model): +class FileServiceItems(_serialization.Model): """FileServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -2055,20 +1944,16 @@ class FileServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileServiceProperties]'}, + "value": {"key": "value", "type": "[FileServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -2099,20 +1984,23 @@ class FileServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'share_delete_retention_policy': {'key': 'properties.shareDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'protocol_settings': {'key': 'properties.protocolSettings', 'type': 'ProtocolSettings'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "share_delete_retention_policy": { + "key": "properties.shareDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "protocol_settings": {"key": "properties.protocolSettings", "type": "ProtocolSettings"}, } def __init__( @@ -2134,14 +2022,14 @@ def __init__( :keyword protocol_settings: Protocol settings for file service. :paramtype protocol_settings: ~azure.mgmt.storage.v2020_08_01_preview.models.ProtocolSettings """ - super(FileServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.share_delete_retention_policy = share_delete_retention_policy self.protocol_settings = protocol_settings -class FileShare(AzureEntityResource): +class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the file share, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -2164,11 +2052,11 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2180,7 +2068,7 @@ class FileShare(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2188,48 +2076,48 @@ class FileShare(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long + :vartype share_usage_bytes: int :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares with expand param "snapshots". :vartype snapshot_time: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'snapshot_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "snapshot_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2249,18 +2137,18 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ShareAccessTier """ - super(FileShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2277,7 +2165,7 @@ def __init__( self.snapshot_time = None -class FileShareItem(AzureEntityResource): +class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The file share properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -2300,11 +2188,11 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2316,7 +2204,7 @@ class FileShareItem(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2324,48 +2212,48 @@ class FileShareItem(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long + :vartype share_usage_bytes: int :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares with expand param "snapshots". :vartype snapshot_time: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'snapshot_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "snapshot_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2385,18 +2273,18 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ShareAccessTier """ - super(FileShareItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2413,7 +2301,7 @@ def __init__( self.snapshot_time = None -class FileShareItems(msrest.serialization.Model): +class FileShareItems(_serialization.Model): """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. Variables are only populated by the server, and will be ignored when sending a request. @@ -2426,27 +2314,23 @@ class FileShareItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileShareItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileShareItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2455,7 +2339,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2468,30 +2352,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2502,31 +2382,27 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: The identity type. Has constant value: "SystemAssigned". + :ivar type: The identity type. Required. Default value is "SystemAssigned". :vartype type: str """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True, 'constant': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "SystemAssigned" - def __init__( - self, - **kwargs - ): - """ - """ - super(Identity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -2550,7 +2426,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2561,21 +2437,24 @@ class ImmutabilityPolicy(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -2596,13 +2475,13 @@ def __init__( ExtendImmutabilityPolicy API. :paramtype allow_protected_append_writes: bool """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None self.allow_protected_append_writes = allow_protected_append_writes -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2616,7 +2495,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2627,17 +2506,20 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -2658,7 +2540,7 @@ def __init__( ExtendImmutabilityPolicy API. :paramtype allow_protected_append_writes: bool """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days @@ -2666,49 +2548,41 @@ def __init__( self.allow_protected_append_writes = allow_protected_append_writes -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. Variables are only populated by the server, and will be ignored when sending a request. @@ -2727,16 +2601,16 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } def __init__( @@ -2755,7 +2629,7 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri @@ -2763,15 +2637,15 @@ def __init__( self.last_key_rotation_timestamp = None -class LastAccessTimeTrackingPolicy(msrest.serialization.Model): +class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. All required parameters must be populated in order to send to Azure. - :ivar enable: Required. When set to true last access time based tracking is enabled. + :ivar enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Known values are: "AccessTimeTracking". + read only. "AccessTimeTracking" :vartype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2783,14 +2657,14 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): """ _validation = { - 'enable': {'required': True}, + "enable": {"required": True}, } _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tracking_granularity_in_days': {'key': 'trackingGranularityInDays', 'type': 'int'}, - 'blob_type': {'key': 'blobType', 'type': '[str]'}, + "enable": {"key": "enable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "tracking_granularity_in_days": {"key": "trackingGranularityInDays", "type": "int"}, + "blob_type": {"key": "blobType", "type": "[str]"}, } def __init__( @@ -2803,10 +2677,10 @@ def __init__( **kwargs ): """ - :keyword enable: Required. When set to true last access time based tracking is enabled. + :keyword enable: When set to true last access time based tracking is enabled. Required. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Known values are: "AccessTimeTracking". + currently read only. "AccessTimeTracking" :paramtype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2816,20 +2690,20 @@ def __init__( supported value. This field is currently read only. :paramtype blob_type: list[str] """ - super(LastAccessTimeTrackingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enable = enable self.name = name self.tracking_granularity_in_days = tracking_granularity_in_days self.blob_type = blob_type -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -2846,15 +2720,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -2868,8 +2742,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. @@ -2884,7 +2758,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -2892,7 +2766,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -2903,17 +2777,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -2921,12 +2789,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2938,38 +2806,33 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, } - def __init__( - self, - *, - tags: List[str], - **kwargs - ): + def __init__(self, *, tags: List[str], **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2979,35 +2842,30 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2020_08_01_preview.models.TagProperty] """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, } - def __init__( - self, - *, - tags: Optional[List["_models.TagProperty"]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[List["_models.TagProperty"]] = None, **kwargs): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2020_08_01_preview.models.TagProperty] """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3017,24 +2875,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListBlobInventoryPolicy(msrest.serialization.Model): +class ListBlobInventoryPolicy(_serialization.Model): """List of blob inventory policies returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3044,24 +2898,20 @@ class ListBlobInventoryPolicy(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobInventoryPolicy]'}, + "value": {"key": "value", "type": "[BlobInventoryPolicy]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListBlobInventoryPolicy, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -3091,17 +2941,18 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3122,45 +2973,45 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -3180,12 +3031,12 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -3204,7 +3055,7 @@ def __init__( self.has_immutability_policy = None -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. Variables are only populated by the server, and will be ignored when sending a request. @@ -3217,22 +3068,18 @@ class ListContainerItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListContainerItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3255,33 +3102,28 @@ class ListQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(ListQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata -class ListQueueResource(msrest.serialization.Model): +class ListQueueResource(_serialization.Model): """Response schema. Contains list of queues returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3293,27 +3135,23 @@ class ListQueueResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListQueueServices(msrest.serialization.Model): +class ListQueueServices(_serialization.Model): """ListQueueServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -3323,24 +3161,20 @@ class ListQueueServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueServiceProperties]'}, + "value": {"key": "value", "type": "[QueueServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3350,24 +3184,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class ListTableResource(msrest.serialization.Model): +class ListTableResource(_serialization.Model): """Response schema. Contains list of tables returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3379,27 +3209,23 @@ class ListTableResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Table]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Table]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListTableServices(msrest.serialization.Model): +class ListTableServices(_serialization.Model): """ListTableServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -3409,20 +3235,16 @@ class ListTableServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TableServiceProperties]'}, + "value": {"key": "value", "type": "[TableServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -3447,37 +3269,32 @@ class ManagementPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.ManagementPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :paramtype policy: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicySchema """ - super(ManagementPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.policy = policy -class ManagementPolicyAction(msrest.serialization.Model): +class ManagementPolicyAction(_serialization.Model): """Actions are applied to the filtered blobs when the execution condition is met. :ivar base_blob: The management policy action for base blob. @@ -3489,9 +3306,9 @@ class ManagementPolicyAction(msrest.serialization.Model): """ _attribute_map = { - 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, - 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, - 'version': {'key': 'version', 'type': 'ManagementPolicyVersion'}, + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, + "version": {"key": "version", "type": "ManagementPolicyVersion"}, } def __init__( @@ -3510,13 +3327,13 @@ def __init__( :keyword version: The management policy action for version. :paramtype version: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyVersion """ - super(ManagementPolicyAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_blob = base_blob self.snapshot = snapshot self.version = version -class ManagementPolicyBaseBlob(msrest.serialization.Model): +class ManagementPolicyBaseBlob(_serialization.Model): """Management policy action for base blob. :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot @@ -3533,10 +3350,10 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, - 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, - 'enable_auto_tier_to_hot_from_cool': {'key': 'enableAutoTierToHotFromCool', 'type': 'bool'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, + "enable_auto_tier_to_hot_from_cool": {"key": "enableAutoTierToHotFromCool", "type": "bool"}, } def __init__( @@ -3563,31 +3380,31 @@ def __init__( tierToCool.daysAfterLastAccessTimeGreaterThan. :paramtype enable_auto_tier_to_hot_from_cool: bool """ - super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool -class ManagementPolicyDefinition(msrest.serialization.Model): +class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. All required parameters must be populated in order to send to Azure. - :ivar actions: Required. An object that defines the action set. + :ivar actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyAction :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyFilter """ _validation = { - 'actions': {'required': True}, + "actions": {"required": True}, } _attribute_map = { - 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, - 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, } def __init__( @@ -3598,25 +3415,25 @@ def __init__( **kwargs ): """ - :keyword actions: Required. An object that defines the action set. + :keyword actions: An object that defines the action set. Required. :paramtype actions: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyAction :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyFilter """ - super(ManagementPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.filters = filters -class ManagementPolicyFilter(msrest.serialization.Model): +class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :ivar blob_types: An array of predefined enum values. Currently blockBlob supports all tiering + and delete actions. Only delete actions are supported for appendBlob. Required. :vartype blob_types: list[str] :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. @@ -3624,13 +3441,13 @@ class ManagementPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'blob_index_match': {'key': 'blobIndexMatch', 'type': '[TagFilter]'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "blob_index_match": {"key": "blobIndexMatch", "type": "[TagFilter]"}, } def __init__( @@ -3644,46 +3461,46 @@ def __init__( """ :keyword prefix_match: An array of strings for prefixes to be match. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :keyword blob_types: An array of predefined enum values. Currently blockBlob supports all + tiering and delete actions. Only delete actions are supported for appendBlob. Required. :paramtype blob_types: list[str] :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. :paramtype blob_index_match: list[~azure.mgmt.storage.v2020_08_01_preview.models.TagFilter] """ - super(ManagementPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.blob_index_match = blob_index_match -class ManagementPolicyRule(msrest.serialization.Model): +class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. :ivar enabled: Rule is enabled if set to true. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" :vartype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RuleType - :ivar definition: Required. An object that defines the Lifecycle rule. + :ivar definition: An object that defines the Lifecycle rule. Required. :vartype definition: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyDefinition """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - 'definition': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, } def __init__( @@ -3698,56 +3515,53 @@ def __init__( """ :keyword enabled: Rule is enabled if set to true. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" :paramtype type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RuleType - :keyword definition: Required. An object that defines the Lifecycle rule. + :keyword definition: An object that defines the Lifecycle rule. Required. :paramtype definition: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyDefinition """ - super(ManagementPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.type = type self.definition = definition -class ManagementPolicySchema(msrest.serialization.Model): +class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. All required parameters must be populated in order to send to Azure. - :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :vartype rules: list[~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyRule] """ _validation = { - 'rules': {'required': True}, + "rules": {"required": True}, } _attribute_map = { - 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, } - def __init__( - self, - *, - rules: List["_models.ManagementPolicyRule"], - **kwargs - ): + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): """ - :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :paramtype rules: list[~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyRule] """ - super(ManagementPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.rules = rules -class ManagementPolicySnapShot(msrest.serialization.Model): +class ManagementPolicySnapShot(_serialization.Model): """Management policy action for snapshot. :ivar tier_to_cool: The function to tier blob snapshot to cool storage. Support blob snapshot @@ -3761,9 +3575,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -3784,13 +3598,13 @@ def __init__( :keyword delete: The function to delete the blob snapshot. :paramtype delete: ~azure.mgmt.storage.v2020_08_01_preview.models.DateAfterCreation """ - super(ManagementPolicySnapShot, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class ManagementPolicyVersion(msrest.serialization.Model): +class ManagementPolicyVersion(_serialization.Model): """Management policy action for blob version. :ivar tier_to_cool: The function to tier blob version to cool storage. Support blob version @@ -3804,9 +3618,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -3827,13 +3641,13 @@ def __init__( :keyword delete: The function to delete the blob version. :paramtype delete: ~azure.mgmt.storage.v2020_08_01_preview.models.DateAfterCreation """ - super(ManagementPolicyVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -3857,15 +3671,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -3902,7 +3716,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -3914,7 +3728,7 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class Multichannel(msrest.serialization.Model): +class Multichannel(_serialization.Model): """Multichannel setting. Applies to Premium FileStorage only. :ivar enabled: Indicates whether multichannel is enabled. @@ -3922,32 +3736,27 @@ class Multichannel(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Indicates whether multichannel is enabled. :paramtype enabled: bool """ - super(Multichannel, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Bypass :ivar resource_access_rules: :vartype resource_access_rules: @@ -3957,28 +3766,28 @@ class NetworkRuleSet(msrest.serialization.Model): list[~azure.mgmt.storage.v2020_08_01_preview.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2020_08_01_preview.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2020_08_01_preview.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'resource_access_rules': {'key': 'resourceAccessRules', 'type': '[ResourceAccessRule]'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "resource_access_rules": {"key": "resourceAccessRules", "type": "[ResourceAccessRule]"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, @@ -3988,7 +3797,7 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Bypass :keyword resource_access_rules: :paramtype resource_access_rules: @@ -3998,11 +3807,11 @@ def __init__( list[~azure.mgmt.storage.v2020_08_01_preview.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2020_08_01_preview.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2020_08_01_preview.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.resource_access_rules = resource_access_rules self.virtual_network_rules = virtual_network_rules @@ -4010,7 +3819,7 @@ def __init__( self.default_action = default_action -class ObjectReplicationPolicies(msrest.serialization.Model): +class ObjectReplicationPolicies(_serialization.Model): """List storage account object replication policies. :ivar value: The replication policy between two storage accounts. @@ -4018,20 +3827,15 @@ class ObjectReplicationPolicies(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ObjectReplicationPolicy]'}, + "value": {"key": "value", "type": "[ObjectReplicationPolicy]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ObjectReplicationPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs): """ :keyword value: The replication policy between two storage accounts. :paramtype value: list[~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy] """ - super(ObjectReplicationPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4062,22 +3866,22 @@ class ObjectReplicationPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_id': {'readonly': True}, - 'enabled_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_id": {"readonly": True}, + "enabled_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, - 'enabled_time': {'key': 'properties.enabledTime', 'type': 'iso-8601'}, - 'source_account': {'key': 'properties.sourceAccount', 'type': 'str'}, - 'destination_account': {'key': 'properties.destinationAccount', 'type': 'str'}, - 'rules': {'key': 'properties.rules', 'type': '[ObjectReplicationPolicyRule]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "enabled_time": {"key": "properties.enabledTime", "type": "iso-8601"}, + "source_account": {"key": "properties.sourceAccount", "type": "str"}, + "destination_account": {"key": "properties.destinationAccount", "type": "str"}, + "rules": {"key": "properties.rules", "type": "[ObjectReplicationPolicyRule]"}, } def __init__( @@ -4097,7 +3901,7 @@ def __init__( :paramtype rules: list[~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicyRule] """ - super(ObjectReplicationPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_id = None self.enabled_time = None self.source_account = source_account @@ -4105,7 +3909,7 @@ def __init__( self.rules = rules -class ObjectReplicationPolicyFilter(msrest.serialization.Model): +class ObjectReplicationPolicyFilter(_serialization.Model): """Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the filter. If multiple filters are defined, a logical AND is performed on all filters. :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin @@ -4117,17 +3921,11 @@ class ObjectReplicationPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'min_creation_time': {'key': 'minCreationTime', 'type': 'str'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "min_creation_time": {"key": "minCreationTime", "type": "str"}, } - def __init__( - self, - *, - prefix_match: Optional[List[str]] = None, - min_creation_time: Optional[str] = None, - **kwargs - ): + def __init__(self, *, prefix_match: Optional[List[str]] = None, min_creation_time: Optional[str] = None, **kwargs): """ :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. @@ -4136,12 +3934,12 @@ def __init__( It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. :paramtype min_creation_time: str """ - super(ObjectReplicationPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.min_creation_time = min_creation_time -class ObjectReplicationPolicyRule(msrest.serialization.Model): +class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. All required parameters must be populated in order to send to Azure. @@ -4149,24 +3947,24 @@ class ObjectReplicationPolicyRule(msrest.serialization.Model): :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :vartype rule_id: str - :ivar source_container: Required. Required. Source container name. + :ivar source_container: Required. Source container name. Required. :vartype source_container: str - :ivar destination_container: Required. Required. Destination container name. + :ivar destination_container: Required. Destination container name. Required. :vartype destination_container: str :ivar filters: Optional. An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicyFilter """ _validation = { - 'source_container': {'required': True}, - 'destination_container': {'required': True}, + "source_container": {"required": True}, + "destination_container": {"required": True}, } _attribute_map = { - 'rule_id': {'key': 'ruleId', 'type': 'str'}, - 'source_container': {'key': 'sourceContainer', 'type': 'str'}, - 'destination_container': {'key': 'destinationContainer', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': 'ObjectReplicationPolicyFilter'}, + "rule_id": {"key": "ruleId", "type": "str"}, + "source_container": {"key": "sourceContainer", "type": "str"}, + "destination_container": {"key": "destinationContainer", "type": "str"}, + "filters": {"key": "filters", "type": "ObjectReplicationPolicyFilter"}, } def __init__( @@ -4182,22 +3980,22 @@ def __init__( :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :paramtype rule_id: str - :keyword source_container: Required. Required. Source container name. + :keyword source_container: Required. Source container name. Required. :paramtype source_container: str - :keyword destination_container: Required. Required. Destination container name. + :keyword destination_container: Required. Destination container name. Required. :paramtype destination_container: str :keyword filters: Optional. An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicyFilter """ - super(ObjectReplicationPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.rule_id = rule_id self.source_container = source_container self.destination_container = destination_container self.filters = filters -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -4212,10 +4010,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -4238,14 +4036,14 @@ def __init__( :paramtype service_specification: ~azure.mgmt.storage.v2020_08_01_preview.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -4259,10 +4057,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -4284,14 +4082,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -4299,24 +4097,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2020_08_01_preview.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4326,20 +4119,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -4363,25 +4152,28 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -4399,13 +4191,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """List of private endpoint connection associated with the specified storage account. :ivar value: Array of private endpoint connections. @@ -4413,21 +4205,16 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4453,39 +4240,34 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "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, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): """ :keyword required_zone_names: The private link resource Private link DNS zone name. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. @@ -4493,28 +4275,23 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.storage.v2020_08_01_preview.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", and "Rejected". :vartype status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -4525,9 +4302,9 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'action_required': {'key': 'actionRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "action_required": {"key": "actionRequired", "type": "str"}, } def __init__( @@ -4540,7 +4317,7 @@ def __init__( ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", and "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -4549,13 +4326,13 @@ def __init__( updates on the consumer. :paramtype action_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.action_required = action_required -class ProtocolSettings(msrest.serialization.Model): +class ProtocolSettings(_serialization.Model): """Protocol settings for file service. :ivar smb: Setting for SMB protocol. @@ -4563,20 +4340,15 @@ class ProtocolSettings(msrest.serialization.Model): """ _attribute_map = { - 'smb': {'key': 'smb', 'type': 'SmbSetting'}, + "smb": {"key": "smb", "type": "SmbSetting"}, } - def __init__( - self, - *, - smb: Optional["_models.SmbSetting"] = None, - **kwargs - ): + def __init__(self, *, smb: Optional["_models.SmbSetting"] = None, **kwargs): """ :keyword smb: Setting for SMB protocol. :paramtype smb: ~azure.mgmt.storage.v2020_08_01_preview.models.SmbSetting """ - super(ProtocolSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.smb = smb @@ -4600,35 +4372,30 @@ class QueueServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Queue service. :paramtype cors: ~azure.mgmt.storage.v2020_08_01_preview.models.CorsRules """ - super(QueueServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class ResourceAccessRule(msrest.serialization.Model): +class ResourceAccessRule(_serialization.Model): """Resource Access Rule. :ivar tenant_id: Tenant Id. @@ -4638,36 +4405,30 @@ class ResourceAccessRule(msrest.serialization.Model): """ _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__( - self, - *, - tenant_id: Optional[str] = None, - resource_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tenant_id: Optional[str] = None, resource_id: Optional[str] = None, **kwargs): """ :keyword tenant_id: Tenant Id. :paramtype tenant_id: str :keyword resource_id: Resource Id. :paramtype resource_id: str """ - super(ResourceAccessRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.tenant_id = tenant_id self.resource_id = resource_id -class RestorePolicyProperties(msrest.serialization.Model): +class RestorePolicyProperties(_serialization.Model): """The blob service properties for blob restore policy. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Blob restore is enabled if set to true. + :ivar enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool :ivar days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. @@ -4679,41 +4440,35 @@ class RestorePolicyProperties(msrest.serialization.Model): """ _validation = { - 'enabled': {'required': True}, - 'days': {'maximum': 365, 'minimum': 1}, - 'last_enabled_time': {'readonly': True}, - 'min_restore_time': {'readonly': True}, + "enabled": {"required": True}, + "days": {"maximum": 365, "minimum": 1}, + "last_enabled_time": {"readonly": True}, + "min_restore_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'min_restore_time': {'key': 'minRestoreTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "min_restore_time": {"key": "minRestoreTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: bool, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: bool, days: Optional[int] = None, **kwargs): """ - :keyword enabled: Required. Blob restore is enabled if set to true. + :keyword enabled: Blob restore is enabled if set to true. Required. :paramtype enabled: bool :keyword days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. :paramtype days: int """ - super(RestorePolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days self.last_enabled_time = None self.min_restore_time = None -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -4726,45 +4481,40 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class RoutingPreference(msrest.serialization.Model): +class RoutingPreference(_serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4775,9 +4525,9 @@ class RoutingPreference(msrest.serialization.Model): """ _attribute_map = { - 'routing_choice': {'key': 'routingChoice', 'type': 'str'}, - 'publish_microsoft_endpoints': {'key': 'publishMicrosoftEndpoints', 'type': 'bool'}, - 'publish_internet_endpoints': {'key': 'publishInternetEndpoints', 'type': 'bool'}, + "routing_choice": {"key": "routingChoice", "type": "str"}, + "publish_microsoft_endpoints": {"key": "publishMicrosoftEndpoints", "type": "bool"}, + "publish_internet_endpoints": {"key": "publishInternetEndpoints", "type": "bool"}, } def __init__( @@ -4790,7 +4540,7 @@ def __init__( ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2020_08_01_preview.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4799,31 +4549,31 @@ def __init__( storage endpoints are to be published. :paramtype publish_internet_endpoints: bool """ - super(RoutingPreference, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_choice = routing_choice self.publish_microsoft_endpoints = publish_microsoft_endpoints self.publish_internet_endpoints = publish_internet_endpoints -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -4855,29 +4605,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, } _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -4904,20 +4654,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2020_08_01_preview.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -4948,7 +4699,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -4969,7 +4720,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -4978,70 +4729,60 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2020_08_01_preview.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -5054,45 +4795,41 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Storage SKU and its properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -5106,22 +4843,22 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -5132,16 +4869,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2020_08_01_preview.models.Restriction] """ - super(SkuInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -5151,7 +4888,7 @@ def __init__( self.restrictions = restrictions -class SmbSetting(msrest.serialization.Model): +class SmbSetting(_serialization.Model): """Setting for SMB protocol. :ivar multichannel: Multichannel setting. Applies to Premium FileStorage only. @@ -5159,20 +4896,15 @@ class SmbSetting(msrest.serialization.Model): """ _attribute_map = { - 'multichannel': {'key': 'multichannel', 'type': 'Multichannel'}, + "multichannel": {"key": "multichannel", "type": "Multichannel"}, } - def __init__( - self, - *, - multichannel: Optional["_models.Multichannel"] = None, - **kwargs - ): + def __init__(self, *, multichannel: Optional["_models.Multichannel"] = None, **kwargs): """ :keyword multichannel: Multichannel setting. Applies to Premium FileStorage only. :paramtype multichannel: ~azure.mgmt.storage.v2020_08_01_preview.models.Multichannel """ - super(SmbSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.multichannel = multichannel @@ -5191,46 +4923,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -5245,21 +4971,21 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2020_08_01_preview.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2020_08_01_preview.models.Identity :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2020_08_01_preview.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, @@ -5269,7 +4995,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -5281,7 +5007,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. @@ -5296,7 +5022,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2020_08_01_preview.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5315,7 +5041,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -5332,7 +5058,7 @@ class StorageAccount(TrackedResource): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -5343,69 +5069,75 @@ class StorageAccount(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'blob_restore_status': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "blob_restore_status": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'blob_restore_status': {'key': 'properties.blobRestoreStatus', 'type': 'BlobRestoreStatus'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - } - - def __init__( + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "blob_restore_status": {"key": "properties.blobRestoreStatus", "type": "BlobRestoreStatus"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -5423,9 +5155,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2020_08_01_preview.models.Identity @@ -5441,7 +5173,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5452,7 +5184,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -5461,7 +5193,7 @@ def __init__( default value is null, which is equivalent to true. :paramtype allow_shared_key_access: bool """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -5493,69 +5225,64 @@ def __init__( self.allow_shared_key_access = allow_shared_key_access -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2020_08_01_preview.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str :ivar extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :vartype extended_location: ~azure.mgmt.storage.v2020_08_01_preview.models.ExtendedLocation - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2020_08_01_preview.models.Identity @@ -5569,7 +5296,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2020_08_01_preview.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5581,7 +5308,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -5592,7 +5319,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -5603,30 +5330,33 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, } _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, } def __init__( @@ -5653,24 +5383,24 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2020_08_01_preview.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str :keyword extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :paramtype extended_location: ~azure.mgmt.storage.v2020_08_01_preview.models.ExtendedLocation - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2020_08_01_preview.models.Identity @@ -5684,7 +5414,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2020_08_01_preview.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5696,7 +5426,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5707,7 +5437,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -5716,7 +5446,7 @@ def __init__( default value is null, which is equivalent to true. :paramtype allow_shared_key_access: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -5737,7 +5467,7 @@ def __init__( self.allow_shared_key_access = allow_shared_key_access -class StorageAccountInternetEndpoints(msrest.serialization.Model): +class StorageAccountInternetEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -5753,33 +5483,29 @@ class StorageAccountInternetEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountInternetEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.file = None self.web = None self.dfs = None -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -5789,35 +5515,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2020_08_01_preview.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -5828,24 +5550,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -5858,27 +5576,23 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): +class StorageAccountMicrosoftEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -5898,30 +5612,26 @@ class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountMicrosoftEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -5930,55 +5640,50 @@ def __init__( self.dfs = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2, kerb1, kerb2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2, kerb1, kerb2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2020_08_01_preview.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2020_08_01_preview.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -5988,7 +5693,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2020_08_01_preview.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5999,7 +5704,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2020_08_01_preview.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6010,7 +5715,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -6021,21 +5726,24 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, } def __init__( @@ -6063,16 +5771,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2020_08_01_preview.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2020_08_01_preview.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6082,7 +5790,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2020_08_01_preview.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2020_08_01_preview.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6094,7 +5802,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2020_08_01_preview.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6105,7 +5813,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2020_08_01_preview.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be @@ -6114,7 +5822,7 @@ def __init__( default value is null, which is equivalent to true. :paramtype allow_shared_key_access: bool """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -6154,36 +5862,31 @@ class StorageQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'approximate_message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "approximate_message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'approximate_message_count': {'key': 'properties.approximateMessageCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "approximate_message_count": {"key": "properties.approximateMessageCount", "type": "int"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(StorageQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata self.approximate_message_count = None -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -6193,37 +5896,33 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuInformation]'}, + "value": {"key": "value", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2020_08_01_preview.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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.CreatedByType :ivar last_modified_at: The timestamp of resource last modification (UTC). @@ -6231,12 +5930,12 @@ class SystemData(msrest.serialization.Model): """ _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'}, + "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__( @@ -6254,20 +5953,20 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2020_08_01_preview.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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2020_08_01_preview.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -6294,26 +5993,22 @@ class Table(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'table_name': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "table_name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Table, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.table_name = None @@ -6337,86 +6032,74 @@ class TableServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Table service. :paramtype cors: ~azure.mgmt.storage.v2020_08_01_preview.models.CorsRules """ - super(TableServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class TagFilter(msrest.serialization.Model): +class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. All required parameters must be populated in order to send to Azure. - :ivar name: Required. This is the filter tag name, it can have 1 - 128 characters. + :ivar name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str - :ivar op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :ivar op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :vartype op: str - :ivar value: Required. This is the filter tag value field used for tag based filtering, it can - have 0 - 256 characters. + :ivar value: This is the filter tag value field used for tag based filtering, it can have 0 - + 256 characters. Required. :vartype value: str """ _validation = { - 'name': {'required': True, 'max_length': 128, 'min_length': 1}, - 'op': {'required': True}, - 'value': {'required': True, 'max_length': 256, 'min_length': 0}, + "name": {"required": True, "max_length": 128, "min_length": 1}, + "op": {"required": True}, + "value": {"required": True, "max_length": 256}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'op': {'key': 'op', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "op": {"key": "op", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - op: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, op: str, value: str, **kwargs): """ - :keyword name: Required. This is the filter tag name, it can have 1 - 128 characters. + :keyword name: This is the filter tag name, it can have 1 - 128 characters. Required. :paramtype name: str - :keyword op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :keyword op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :paramtype op: str - :keyword value: Required. This is the filter tag value field used for tag based filtering, it - can have 0 - 256 characters. + :keyword value: This is the filter tag value field used for tag based filtering, it can have 0 + - 256 characters. Required. :paramtype value: str """ - super(TagFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.op = op self.value = value -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -6434,28 +6117,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -6463,13 +6142,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the @@ -6487,30 +6166,26 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -6519,13 +6194,13 @@ def __init__( self.upn = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2020_08_01_preview.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -6536,33 +6211,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -6570,24 +6241,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2020_08_01_preview.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -6599,72 +6265,68 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2020_08_01_preview.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py index 40b46e1d43b1..f066e0f39e0c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,10 +25,13 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobInventoryPolicyName.""" DEFAULT = "default" + class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - @@ -39,6 +42,7 @@ class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): COMPLETE = "Complete" FAILED = "Failed" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -50,7 +54,9 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CorsRuleAllowedMethodsItem.""" DELETE = "DELETE" GET = "GET" @@ -60,30 +66,31 @@ class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): OPTIONS = "OPTIONS" PUT = "PUT" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the directory service used. - """ + """Indicates the directory service used.""" NONE = "None" AADDS = "AADDS" AD = "AD" + class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. @@ -92,6 +99,7 @@ class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): SMB = "SMB" NFS = "NFS" + class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. @@ -100,19 +108,26 @@ class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. - """ + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + +class Enum28(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum28.""" + + DEFAULT = "default" + + class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation. - """ + """The type of extendedLocation.""" EDGE_ZONE = "EdgeZone" + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -125,20 +140,21 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -148,27 +164,29 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Inventory - """ + """The valid value is Inventory.""" INVENTORY = "Inventory" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service @@ -178,9 +196,9 @@ class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SERVICE = "Service" ACCOUNT = "Account" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -188,22 +206,23 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - """ + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -213,9 +232,9 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -223,26 +242,33 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListContainersInclude.""" DELETED = "deleted" + class ListSharesExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListSharesExpand.""" DELETED = "deleted" SNAPSHOTS = "snapshots" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. @@ -252,12 +278,13 @@ class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" + class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only - """ + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only.""" ACCESS_TIME_TRACKING = "AccessTimeTracking" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -272,39 +299,40 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state. - """ + """The current provisioning state.""" SUCCEEDED = "Succeeded" CREATING = "Creating" DELETING = "Deleting" FAILED = "Failed" + class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status. - """ + """The private endpoint connection status.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -313,6 +341,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -323,27 +352,28 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The property is for NFS share only. The default is NoRootSquash. - """ + """The property is for NFS share only. The default is NoRootSquash.""" NO_ROOT_SQUASH = "NoRootSquash" ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" + class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Routing Choice defines the kind of network routing opted by the user. - """ + """Routing Choice defines the kind of network routing opted by the user.""" MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" + class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Lifecycle - """ + """The valid value is Lifecycle.""" LIFECYCLE = "Lifecycle" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -354,6 +384,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. @@ -364,6 +395,7 @@ class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): COOL = "Cool" PREMIUM = "Premium" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -374,6 +406,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -384,6 +417,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -398,16 +432,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SKU tier. This is based on the SKU name. - """ + """The SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "provisioning" DEPROVISIONING = "deprovisioning" @@ -415,14 +449,16 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" + class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountExpand.""" GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/__init__.py index 9a63fd415725..a7c5747747ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/__init__.py @@ -29,26 +29,27 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_operations.py index 4da4ab4869de..e71de2c9a6b1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_containers_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -34,361 +48,323 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum28], subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum28], subscription_id: str, *, if_match: Optional[str] = None, @@ -397,43 +373,44 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum28], subscription_id: str, *, if_match: str, @@ -442,36 +419,36 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -486,34 +463,35 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -523,93 +501,83 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class BlobContainersOperations: """ @@ -630,7 +598,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -638,18 +605,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> Iterable[_models.ListContainerItems]: + ) -> Iterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -658,36 +625,42 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -695,18 +668,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -723,10 +695,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -736,19 +706,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -756,37 +726,126 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] - - _json = self._serialize.body(blob_container, 'BlobContainer') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -796,7 +855,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -804,10 +864,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -815,63 +874,151 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] - - _json = self._serialize.body(blob_container, 'BlobContainer') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -881,7 +1028,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -889,72 +1037,70 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -962,72 +1108,70 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1035,10 +1179,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1048,16 +1191,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1065,37 +1209,126 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - - _json = self._serialize.body(legal_hold, 'LegalHold') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1105,7 +1338,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1113,70 +1347,157 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - - _json = self._serialize.body(legal_hold, 'LegalHold') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -1186,7 +1507,8 @@ def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1194,51 +1516,55 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum28], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -1246,44 +1572,146 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum28], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum28], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] - - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1291,10 +1719,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1302,17 +1729,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1320,6 +1746,7 @@ def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum28], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1327,52 +1754,54 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1380,10 +1809,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1391,17 +1819,16 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( @@ -1409,6 +1836,7 @@ def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum28], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1418,52 +1846,54 @@ def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1471,10 +1901,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1482,71 +1911,69 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1554,10 +1981,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1565,19 +1991,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1585,6 +2010,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1592,56 +2019,157 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] - - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1649,10 +2177,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1660,65 +2187,153 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequest + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] - - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1728,7 +2343,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1736,22 +2352,20 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_operations.py index 0e4efe2056a6..98d4a0f2299d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_inventory_policies_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,175 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - *, - json: Optional[_models.BlobInventoryPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobInventoryPoliciesOperations: """ @@ -207,52 +216,55 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -260,10 +272,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -271,68 +282,153 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy 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 - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -340,10 +436,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -351,61 +446,64 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -413,10 +511,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -427,51 +524,52 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -479,15 +577,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -504,10 +604,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -518,8 +616,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_operations.py index b2b54762cd27..3fb5ae2068a8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_blob_services_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,134 +27,135 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum28], subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum28], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -168,48 +176,51 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -217,15 +228,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -242,10 +255,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -255,66 +266,151 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum28], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum28], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum28], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -322,72 +418,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum28], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -395,22 +488,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_operations.py index c6fd55924a57..dac4bf0fe27c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_deleted_accounts_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,81 +27,78 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_get_request( - deleted_account_name: str, - location: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(deleted_account_name: str, location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), - "location": _SERIALIZER.url("location", location, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "deletedAccountName": _SERIALIZER.url( + "deleted_account_name", deleted_account_name, "str", max_length=24, min_length=3 + ), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DeletedAccountsOperations: """ @@ -115,38 +119,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) + :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -154,13 +159,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -177,10 +186,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -191,48 +198,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace - def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,10 +244,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,12 +254,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_operations.py index 0bb3cd0629fe..729b812c883d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_encryption_scopes_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,181 +27,172 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_put_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EncryptionScopesOperations: """ @@ -215,14 +213,15 @@ def __init__(self, *args, **kwargs): 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 + @overload def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -230,47 +229,139 @@ def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -278,10 +369,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -290,73 +380,162 @@ def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace + @overload def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -364,10 +543,9 @@ def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,62 +553,61 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -438,10 +615,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,58 +625,57 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.EncryptionScopeListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) + :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -508,15 +683,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -533,10 +710,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -546,8 +721,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_operations.py index 2903fbb1f680..74f19cdf2fa5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,135 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum28], subscription_id: str, - *, - json: Optional[_models.FileServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum28], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class FileServicesOperations: """ @@ -167,46 +174,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +219,164 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum28], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum28], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum28], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +384,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum28], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +454,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_operations.py index 442232f9d6e1..3f5d2ded1069 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_file_shares_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -34,44 +48,45 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, + expand: Optional[Union[str, _models.ListSharesExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( @@ -80,95 +95,84 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: Optional[_models.FileShare] = None, - content: Any = None, - expand: Optional[str] = "snapshots", + expand: Literal["snapshots"] = "snapshots", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -177,44 +181,45 @@ def build_get_request( share_name: str, subscription_id: str, *, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -229,82 +234,76 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_restore_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.DeletedShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class FileSharesOperations: """ @@ -325,7 +324,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -333,17 +331,17 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, + expand: Optional[Union[str, _models.ListSharesExpand]] = None, **kwargs: Any - ) -> Iterable[_models.FileShareItems]: + ) -> Iterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -351,37 +349,43 @@ def list( :param filter: Optional. When specified, only share names starting with the filter will be listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. Default value - is None. + :param expand: Optional, used to expand the properties within share's properties. Known values + are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) + :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -389,18 +393,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -417,10 +420,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -430,20 +431,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, - expand: Optional[str] = "snapshots", + expand: Literal["snapshots"] = "snapshots", + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -451,51 +452,149 @@ def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare - :param expand: Optional, used to create a snapshot. Known values are "snapshots" or None. + :param expand: Optional, used to create a snapshot. Known values are "snapshots" and None. + Default value is "snapshots". + :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Literal["snapshots"] = "snapshots", + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to create a snapshot. Known values are "snapshots" and None. + Default value is "snapshots". + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Literal["snapshots"] = "snapshots", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare or IO + :param expand: Optional, used to create a snapshot. Known values are "snapshots" and None. Default value is "snapshots". :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -503,10 +602,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -514,63 +612,151 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -580,7 +766,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -588,25 +775,23 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def get( @@ -614,56 +799,60 @@ def get( resource_group_name: str, account_name: str, share_name: str, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Known values - are "stats" or None. Default value is "stats". + are "stats" and None. Default value is "stats". :type expand: str :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -671,25 +860,23 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -703,44 +890,48 @@ def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -748,10 +939,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -761,52 +951,137 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace + @overload def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedShare + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2020_08_01_preview.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -816,7 +1091,8 @@ def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -824,10 +1100,9 @@ def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -837,5 +1112,4 @@ def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_operations.py index acc5b6835ada..c5d48c6e30e4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,136 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,52 +175,55 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -215,78 +231,162 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy 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 - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -294,71 +394,73 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -366,10 +468,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +480,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_operations.py index 120b84daeb94..dbe2414c9b95 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_object_replication_policies_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,169 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - *, - json: Optional[_models.ObjectReplicationPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ObjectReplicationPoliciesOperations: """ @@ -207,49 +210,51 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +262,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +289,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -296,56 +301,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -353,10 +356,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -364,68 +366,152 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy 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 - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -433,10 +519,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -444,60 +529,59 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -505,10 +589,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -519,5 +602,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_operations.py index 4ce62cdbb25f..abeb8c3f87d3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,40 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +81,37 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +119,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +146,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +157,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_endpoint_connections_operations.py index 8001e195baaf..7c2365b26137 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,181 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -207,49 +222,51 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +274,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +301,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,56 +312,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -352,10 +367,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,67 +377,151 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace + @overload def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection 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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -431,10 +529,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,60 +539,59 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -503,10 +599,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -517,5 +612,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_link_resources_operations.py index 6002e71c78d0..cb40e7612204 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,54 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_storage_account_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,46 +93,46 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -128,22 +140,20 @@ def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_operations.py index df8456c8f55e..8d15b542e7c1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,183 +27,196 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( @@ -211,36 +231,38 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueOperations: """ @@ -261,60 +283,147 @@ def __init__(self, *args, **kwargs): 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 + @overload def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -322,79 +431,165 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -402,72 +597,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.StorageQueue: + def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -475,72 +666,70 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -548,10 +737,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -561,8 +749,7 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -572,15 +759,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.ListQueueResource]: + ) -> Iterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -589,32 +776,37 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -622,17 +814,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -649,10 +841,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -662,8 +852,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_operations.py index ecb724300810..bf0f4695d6fe 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_queue_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,135 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum28], subscription_id: str, - *, - json: Optional[_models.QueueServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum28], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueServicesOperations: """ @@ -167,46 +174,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +219,165 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum28], parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :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: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum28], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum28], + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties 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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +385,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum28], **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +455,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_operations.py index 3f722df6ba7c..3126944f415a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,45 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +86,39 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) + :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +126,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +153,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +164,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_operations.py index 37c88bbf96ea..2e022b6a6a77 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +29,116 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,153 +146,137 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -304,280 +284,252 @@ def build_list_keys_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "kerb", + expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_restore_blob_ranges_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobRestoreParameters] = None, - content: Any = None, - **kwargs: Any +def build_restore_blob_ranges_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revoke_user_delegation_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: """ @@ -598,45 +550,101 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCheckNameAvailabilityParameters 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 - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -644,55 +652,65 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] - - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') - - request = build_create_request_initial( + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") + + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -700,10 +718,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -712,22 +729,105 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def begin_create( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -736,14 +836,19 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountCreateParameters + 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 @@ -756,20 +861,19 @@ def begin_create( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -777,79 +881,76 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -857,10 +958,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -870,15 +970,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -886,40 +985,45 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -927,32 +1031,104 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace def update( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountUpdateParameters, + parameters: Union[_models.StorageAccountUpdateParameters, IO], **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -965,32 +1141,48 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountUpdateParameters + 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -999,7 +1191,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1007,58 +1200,58 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1066,13 +1259,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1089,10 +1286,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1102,49 +1297,48 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1152,14 +1346,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1176,10 +1373,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1189,57 +1384,55 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1247,65 +1440,140 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1314,7 +1582,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1322,63 +1591,138 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.AccountSasParameters 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 - :return: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1387,7 +1731,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1395,63 +1740,136 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ServiceSasParameters + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1460,7 +1878,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1468,50 +1887,49 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1519,10 +1937,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1532,26 +1949,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1563,85 +1974,94 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - - _json = self._serialize.body(parameters, 'BlobRestoreParameters') - - request = build_restore_blob_ranges_request_initial( + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") + + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1649,10 +2069,9 @@ def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1660,38 +2079,42 @@ def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace + @overload def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreParameters + :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 @@ -1704,20 +2127,96 @@ def begin_restore_blob_ranges( cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreParameters 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. + :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2020_08_01_preview.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1725,79 +2224,78 @@ def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1805,10 +2303,9 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1818,5 +2315,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_operations.py index 8e1d4a009ca0..e42f6309764d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,204 +27,204 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableOperations: """ @@ -238,52 +245,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def create(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -291,71 +295,67 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -363,71 +363,67 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -435,71 +431,69 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -507,10 +501,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -520,50 +513,49 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -571,15 +563,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -596,10 +590,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -609,8 +601,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_operations.py index bf33eb91921c..25d50e52585b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_table_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,135 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum28], subscription_id: str, - *, - json: Optional[_models.TableServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum28], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableServicesOperations: """ @@ -167,46 +174,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +219,165 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum28], parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :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: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum28], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum28], + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties 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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +385,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum28], **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2020_08_01_preview.models.Enum28 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2020_08_01_preview.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +455,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_operations.py index fa91cfeb9609..cc9c3561a767 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2020_08_01_preview/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,48 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,42 +89,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2020_08_01_preview.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2020-08-01-preview")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop( + "api_version", _params.pop("api-version", "2020-08-01-preview") + ) # type: Literal["2020-08-01-preview"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -123,14 +132,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -147,10 +159,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -160,8 +170,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_configuration.py index 0686be5dee06..1742899c41b2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-01-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", "2021-01-01") # type: Literal["2021-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json index 1131ce60c15e..f0d90dcea883 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -117,4 +117,4 @@ "table_services": "TableServicesOperations", "table": "TableOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py index a2a784f61f2d..8e14fb32c2a8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_storage_management_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -69,9 +89,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_01_01.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_01_01.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -89,28 +109,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -129,37 +145,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -168,7 +163,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_configuration.py index e1f9b184ecc8..86f62d63359b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-01-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-01-01") # type: str + api_version = kwargs.pop("api_version", "2021-01-01") # type: Literal["2021-01-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py index 414125d4b7a3..f9104597b77b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/_storage_management_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -72,9 +92,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_01_01.aio.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_01_01.aio.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -92,28 +112,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -132,37 +148,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -171,7 +166,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/__init__.py index 9a63fd415725..a7c5747747ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/__init__.py @@ -29,26 +29,27 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_operations.py index 9355bbce2770..7831249a8ceb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_containers_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -43,7 +72,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,18 +79,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListContainerItems]: + ) -> AsyncIterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -71,36 +99,40 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_01_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -108,18 +140,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -136,10 +167,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,19 +178,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -169,37 +198,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -209,7 +325,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -217,10 +334,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -228,63 +344,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -294,7 +496,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -302,72 +505,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -375,72 +574,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -448,10 +643,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -461,16 +655,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -478,37 +673,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -518,7 +800,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -526,70 +809,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -599,7 +967,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -607,51 +976,55 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum30], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -659,44 +1032,144 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum30], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum30], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -704,10 +1177,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -715,17 +1187,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -733,6 +1204,7 @@ async def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum30], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -740,52 +1212,52 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -793,10 +1265,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -804,17 +1275,16 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -822,6 +1292,7 @@ async def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum30], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -831,52 +1302,52 @@ async def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -884,10 +1355,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -895,71 +1365,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -967,10 +1433,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -978,19 +1443,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -998,6 +1462,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1005,56 +1471,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1062,10 +1627,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1073,65 +1637,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1141,7 +1791,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1149,22 +1800,20 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_operations.py index b20197d1060a..3c7a51672d39 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_inventory_policies_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_inventory_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._blob_inventory_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobInventoryPoliciesOperations: """ .. warning:: @@ -43,52 +63,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +117,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,68 +127,151 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy 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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -176,10 +279,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,61 +289,62 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -249,10 +352,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -263,51 +365,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -315,15 +416,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -340,10 +443,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -354,8 +455,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_operations.py index 153be82df899..3146d79ff29c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_blob_services_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -43,48 +62,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,66 +150,149 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum30], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum30], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum30], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -197,72 +300,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum30], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -270,22 +368,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_operations.py index 27225e2b022f..8f3e529d00c4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_deleted_accounts_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DeletedAccountsOperations: """ .. warning:: @@ -43,38 +58,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) + :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -82,13 +96,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -105,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -119,48 +135,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async - async def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -168,10 +179,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,12 +189,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_operations.py index 4057e0a146e6..1f0beb61d06f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_encryption_scopes_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._encryption_scopes_operations import build_get_request, build_list_request, build_patch_request, build_put_request -T = TypeVar('T') +from ...operations._encryption_scopes_operations import ( + build_get_request, + build_list_request, + build_patch_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EncryptionScopesOperations: """ .. warning:: @@ -43,14 +63,15 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -58,47 +79,137 @@ async def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -106,10 +217,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -118,73 +228,160 @@ async def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace_async + @overload async def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +389,9 @@ async def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,62 +399,59 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -266,10 +459,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -277,58 +469,57 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EncryptionScopeListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) + :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -336,15 +527,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -361,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -374,8 +565,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_operations.py index 5f1ba0bbbfee..a19429b5a81a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +102,162 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum30], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum30], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum30], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +265,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum30], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +333,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_operations.py index 5f12ea03c6be..49e789635d95 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_file_shares_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_shares_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_restore_request, build_update_request -T = TypeVar('T') +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_restore_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileSharesOperations: """ .. warning:: @@ -43,7 +65,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,17 +72,17 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, + expand: Optional[Union[str, _models.ListSharesExpand]] = None, **kwargs: Any - ) -> AsyncIterable[_models.FileShareItems]: + ) -> AsyncIterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -69,37 +90,41 @@ def list( :param filter: Optional. When specified, only share names starting with the filter will be listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. Default value - is None. + :param expand: Optional, used to expand the properties within share's properties. Known values + are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) + :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -107,18 +132,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -135,10 +159,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -148,20 +170,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, - expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -169,50 +191,144 @@ async def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare - :param expand: Optional, used to create a snapshot. Default value is None. + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. + :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare or IO + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. + :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -220,10 +336,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -231,63 +346,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -297,7 +498,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -305,25 +507,23 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def get( @@ -331,56 +531,58 @@ async def get( resource_group_name: str, account_name: str, share_name: str, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Known values - are "stats" or None. Default value is "stats". + are "stats" and None. Default value is "stats". :type expand: str :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -388,25 +590,23 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -420,44 +620,46 @@ async def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -465,10 +667,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -478,52 +679,135 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_01_01.models.DeletedShare + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_01_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -533,7 +817,8 @@ async def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -541,10 +826,9 @@ async def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -554,5 +838,4 @@ async def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_operations.py index 75e79d302932..ca5f01ce242e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,52 +59,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -94,78 +113,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy + :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: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -173,71 +274,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -245,10 +346,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -258,5 +358,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_operations.py index 1acb9a27f80a..cba153ff7314 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_object_replication_policies_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._object_replication_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._object_replication_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ObjectReplicationPoliciesOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,56 +152,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -189,10 +205,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -200,68 +215,150 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy 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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -269,10 +366,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,60 +376,57 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -341,10 +434,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -355,5 +447,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_operations.py index 087e97ae221e..cd4ae9099ca2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_endpoint_connections_operations.py index d55a7f714237..1f144d7267a9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request, build_get_request, build_list_request, build_put_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +151,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +204,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +214,148 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection 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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +363,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +373,57 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +431,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,5 +444,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_link_resources_operations.py index 0aa1ade8ea09..8daf725ce8ee 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,46 +55,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -88,22 +100,20 @@ async def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_operations.py index ee6984a278d1..31eecf30f212 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._queue_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueOperations: """ .. warning:: @@ -43,60 +64,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue 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 - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -104,79 +210,163 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -184,72 +374,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -257,72 +443,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -330,10 +512,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -343,8 +524,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -354,15 +534,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListQueueResource]: + ) -> AsyncIterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -371,32 +551,36 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) + :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -404,17 +588,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -431,10 +615,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -444,8 +626,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_operations.py index 0f6f837411bc..0225b98e3c10 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_queue_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._queue_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +102,163 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum30], parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :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: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum30], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum30], + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties 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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +266,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum30], **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +334,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_operations.py index 68ff83d1a9f9..5cb3bcadbb72 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) + :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +95,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +133,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_operations.py index 2e3a8bd19b9e..37a1dcd99725 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,31 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_restore_blob_ranges_request_initial, build_revoke_user_delegation_keys_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_restore_blob_ranges_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +75,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2021_01_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2021_01_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCheckNameAvailabilityParameters 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 - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +174,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +238,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +249,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +274,17 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCreateParameters + :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 @@ -203,20 +297,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCreateParameters 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. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +398,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +473,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,15 +485,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -333,40 +500,43 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,32 +544,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -412,32 +582,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -446,7 +701,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -454,58 +710,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -513,13 +767,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -536,10 +794,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,49 +805,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -599,14 +854,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -623,10 +881,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -636,57 +892,53 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -694,65 +946,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_01_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -761,7 +1086,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -769,63 +1095,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -834,7 +1233,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -842,63 +1242,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -907,7 +1378,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -915,50 +1387,47 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -966,10 +1435,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -979,26 +1447,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1010,85 +1472,90 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1096,10 +1563,9 @@ async def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1107,38 +1573,81 @@ async def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - @distributed_trace_async + @overload async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1151,20 +1660,55 @@ async def begin_restore_blob_ranges( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobRestoreParameters 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. + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1172,79 +1716,76 @@ async def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1252,10 +1793,9 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1265,5 +1805,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_operations.py index 0df9183bf029..6a4e5b1d6c9d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._table_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableOperations: """ .. warning:: @@ -43,52 +64,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -96,71 +114,67 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -168,71 +182,65 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,71 +248,67 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -312,10 +316,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -325,50 +328,47 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -376,15 +376,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -401,10 +403,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -414,8 +414,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_operations.py index 658ee759a499..36932d3ee0ec 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_table_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._table_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +102,163 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum30], parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :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: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum30], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum30], + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties 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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +266,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum30], **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +334,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_operations.py index 9826f267f3d2..f1731ebd7b0b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,42 +57,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_01_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -85,14 +98,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -109,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -122,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/__init__.py index e50226e9eb1d..ce0272f5121b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/__init__.py @@ -135,247 +135,247 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountStatus, - BlobInventoryPolicyName, - BlobRestoreProgressStatus, - Bypass, - CorsRuleAllowedMethodsItem, - CreatedByType, - DefaultAction, - DirectoryServiceOptions, - EnabledProtocols, - EncryptionScopeSource, - EncryptionScopeState, - ExtendedLocationTypes, - GeoReplicationStatus, - HttpProtocol, - IdentityType, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - InventoryRuleType, - KeyPermission, - KeySource, - KeyType, - Kind, - LargeFileSharesState, - LeaseContainerRequestAction, - LeaseDuration, - LeaseState, - LeaseStatus, - ListContainersInclude, - ListSharesExpand, - ManagementPolicyName, - MinimumTlsVersion, - Name, - Permissions, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisioningState, - PublicAccess, - PutSharesExpand, - Reason, - ReasonCode, - RootSquashType, - RoutingChoice, - RuleType, - Services, - ShareAccessTier, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - StorageAccountExpand, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import BlobInventoryPolicyName +from ._storage_management_client_enums import BlobRestoreProgressStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CorsRuleAllowedMethodsItem +from ._storage_management_client_enums import CreatedByType +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import EnabledProtocols +from ._storage_management_client_enums import EncryptionScopeSource +from ._storage_management_client_enums import EncryptionScopeState +from ._storage_management_client_enums import Enum30 +from ._storage_management_client_enums import ExtendedLocationTypes +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import IdentityType +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import InventoryRuleType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import KeyType +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ListContainersInclude +from ._storage_management_client_enums import ListSharesExpand +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Name +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._storage_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import PutSharesExpand +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RootSquashType +from ._storage_management_client_enums import RoutingChoice +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import ShareAccessTier +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import StorageAccountExpand +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'ActiveDirectoryProperties', - 'AzureEntityResource', - 'AzureFilesIdentityBasedAuthentication', - 'BlobContainer', - 'BlobInventoryPolicy', - 'BlobInventoryPolicyDefinition', - 'BlobInventoryPolicyFilter', - 'BlobInventoryPolicyRule', - 'BlobInventoryPolicySchema', - 'BlobRestoreParameters', - 'BlobRestoreRange', - 'BlobRestoreStatus', - 'BlobServiceItems', - 'BlobServiceProperties', - 'ChangeFeed', - 'CheckNameAvailabilityResult', - 'CloudErrorBody', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DateAfterCreation', - 'DateAfterModification', - 'DeleteRetentionPolicy', - 'DeletedAccount', - 'DeletedAccountListResult', - 'DeletedShare', - 'Dimension', - 'Encryption', - 'EncryptionIdentity', - 'EncryptionScope', - 'EncryptionScopeKeyVaultProperties', - 'EncryptionScopeListResult', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'ErrorResponse', - 'ErrorResponseBody', - 'ExtendedLocation', - 'FileServiceItems', - 'FileServiceProperties', - 'FileShare', - 'FileShareItem', - 'FileShareItems', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'KeyVaultProperties', - 'LastAccessTimeTrackingPolicy', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListBlobInventoryPolicy', - 'ListContainerItem', - 'ListContainerItems', - 'ListQueue', - 'ListQueueResource', - 'ListQueueServices', - 'ListServiceSasResponse', - 'ListTableResource', - 'ListTableServices', - 'ManagementPolicy', - 'ManagementPolicyAction', - 'ManagementPolicyBaseBlob', - 'ManagementPolicyDefinition', - 'ManagementPolicyFilter', - 'ManagementPolicyRule', - 'ManagementPolicySchema', - 'ManagementPolicySnapShot', - 'ManagementPolicyVersion', - 'MetricSpecification', - 'Multichannel', - 'NetworkRuleSet', - 'ObjectReplicationPolicies', - 'ObjectReplicationPolicy', - 'ObjectReplicationPolicyFilter', - 'ObjectReplicationPolicyRule', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProtocolSettings', - 'ProxyResource', - 'QueueServiceProperties', - 'Resource', - 'ResourceAccessRule', - 'RestorePolicyProperties', - 'Restriction', - 'RoutingPreference', - 'SKUCapability', - 'ServiceSasParameters', - 'ServiceSpecification', - 'Sku', - 'SkuInformation', - 'SmbSetting', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountInternetEndpoints', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountMicrosoftEndpoints', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageQueue', - 'StorageSkuListResult', - 'SystemData', - 'Table', - 'TableServiceProperties', - 'TagFilter', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'UserAssignedIdentity', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'BlobInventoryPolicyName', - 'BlobRestoreProgressStatus', - 'Bypass', - 'CorsRuleAllowedMethodsItem', - 'CreatedByType', - 'DefaultAction', - 'DirectoryServiceOptions', - 'EnabledProtocols', - 'EncryptionScopeSource', - 'EncryptionScopeState', - 'ExtendedLocationTypes', - 'GeoReplicationStatus', - 'HttpProtocol', - 'IdentityType', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'InventoryRuleType', - 'KeyPermission', - 'KeySource', - 'KeyType', - 'Kind', - 'LargeFileSharesState', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseState', - 'LeaseStatus', - 'ListContainersInclude', - 'ListSharesExpand', - 'ManagementPolicyName', - 'MinimumTlsVersion', - 'Name', - 'Permissions', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'ProvisioningState', - 'PublicAccess', - 'PutSharesExpand', - 'Reason', - 'ReasonCode', - 'RootSquashType', - 'RoutingChoice', - 'RuleType', - 'Services', - 'ShareAccessTier', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'StorageAccountExpand', - 'UsageUnit', + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobInventoryPolicy", + "BlobInventoryPolicyDefinition", + "BlobInventoryPolicyFilter", + "BlobInventoryPolicyRule", + "BlobInventoryPolicySchema", + "BlobRestoreParameters", + "BlobRestoreRange", + "BlobRestoreStatus", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorBody", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "DeletedAccount", + "DeletedAccountListResult", + "DeletedShare", + "Dimension", + "Encryption", + "EncryptionIdentity", + "EncryptionScope", + "EncryptionScopeKeyVaultProperties", + "EncryptionScopeListResult", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ErrorResponse", + "ErrorResponseBody", + "ExtendedLocation", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "KeyVaultProperties", + "LastAccessTimeTrackingPolicy", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListBlobInventoryPolicy", + "ListContainerItem", + "ListContainerItems", + "ListQueue", + "ListQueueResource", + "ListQueueServices", + "ListServiceSasResponse", + "ListTableResource", + "ListTableServices", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "ManagementPolicyVersion", + "MetricSpecification", + "Multichannel", + "NetworkRuleSet", + "ObjectReplicationPolicies", + "ObjectReplicationPolicy", + "ObjectReplicationPolicyFilter", + "ObjectReplicationPolicyRule", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProtocolSettings", + "ProxyResource", + "QueueServiceProperties", + "Resource", + "ResourceAccessRule", + "RestorePolicyProperties", + "Restriction", + "RoutingPreference", + "SKUCapability", + "ServiceSasParameters", + "ServiceSpecification", + "Sku", + "SkuInformation", + "SmbSetting", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountInternetEndpoints", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountMicrosoftEndpoints", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageQueue", + "StorageSkuListResult", + "SystemData", + "Table", + "TableServiceProperties", + "TagFilter", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "UserAssignedIdentity", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "BlobInventoryPolicyName", + "BlobRestoreProgressStatus", + "Bypass", + "CorsRuleAllowedMethodsItem", + "CreatedByType", + "DefaultAction", + "DirectoryServiceOptions", + "EnabledProtocols", + "EncryptionScopeSource", + "EncryptionScopeState", + "Enum30", + "ExtendedLocationTypes", + "GeoReplicationStatus", + "HttpProtocol", + "IdentityType", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "InventoryRuleType", + "KeyPermission", + "KeySource", + "KeyType", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseState", + "LeaseStatus", + "ListContainersInclude", + "ListSharesExpand", + "ManagementPolicyName", + "MinimumTlsVersion", + "Name", + "Permissions", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicAccess", + "PutSharesExpand", + "Reason", + "ReasonCode", + "RootSquashType", + "RoutingChoice", + "RuleType", + "Services", + "ShareAccessTier", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "StorageAccountExpand", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py index fa18d76b9aba..501485b5c565 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,64 +8,69 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2021_01_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_01_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_01_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_01_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -81,33 +87,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2021_01_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_01_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_01_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_01_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -118,42 +125,42 @@ def __init__( self.key_to_sign = key_to_sign -class ActiveDirectoryProperties(msrest.serialization.Model): +class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). All required parameters must be populated in order to send to Azure. - :ivar domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :vartype domain_name: str - :ivar net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. Required. :vartype net_bios_domain_name: str - :ivar forest_name: Required. Specifies the Active Directory forest to get. + :ivar forest_name: Specifies the Active Directory forest to get. Required. :vartype forest_name: str - :ivar domain_guid: Required. Specifies the domain GUID. + :ivar domain_guid: Specifies the domain GUID. Required. :vartype domain_guid: str - :ivar domain_sid: Required. Specifies the security identifier (SID). + :ivar domain_sid: Specifies the security identifier (SID). Required. :vartype domain_sid: str - :ivar azure_storage_sid: Required. Specifies the security identifier (SID) for Azure Storage. + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. Required. :vartype azure_storage_sid: str """ _validation = { - 'domain_name': {'required': True}, - 'net_bios_domain_name': {'required': True}, - 'forest_name': {'required': True}, - 'domain_guid': {'required': True}, - 'domain_sid': {'required': True}, - 'azure_storage_sid': {'required': True}, + "domain_name": {"required": True}, + "net_bios_domain_name": {"required": True}, + "forest_name": {"required": True}, + "domain_guid": {"required": True}, + "domain_sid": {"required": True}, + "azure_storage_sid": {"required": True}, } _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'net_bios_domain_name': {'key': 'netBiosDomainName', 'type': 'str'}, - 'forest_name': {'key': 'forestName', 'type': 'str'}, - 'domain_guid': {'key': 'domainGuid', 'type': 'str'}, - 'domain_sid': {'key': 'domainSid', 'type': 'str'}, - 'azure_storage_sid': {'key': 'azureStorageSid', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, } def __init__( @@ -168,22 +175,22 @@ def __init__( **kwargs ): """ - :keyword domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :paramtype domain_name: str - :keyword net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. Required. :paramtype net_bios_domain_name: str - :keyword forest_name: Required. Specifies the Active Directory forest to get. + :keyword forest_name: Specifies the Active Directory forest to get. Required. :paramtype forest_name: str - :keyword domain_guid: Required. Specifies the domain GUID. + :keyword domain_guid: Specifies the domain GUID. Required. :paramtype domain_guid: str - :keyword domain_sid: Required. Specifies the security identifier (SID). + :keyword domain_sid: Specifies the security identifier (SID). Required. :paramtype domain_sid: str - :keyword azure_storage_sid: Required. Specifies the security identifier (SID) for Azure - Storage. + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + Required. :paramtype azure_storage_sid: str """ - super(ActiveDirectoryProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.net_bios_domain_name = net_bios_domain_name self.forest_name = forest_name @@ -192,7 +199,7 @@ def __init__( self.azure_storage_sid = azure_storage_sid -class Resource(msrest.serialization.Model): +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. @@ -208,24 +215,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -249,36 +252,32 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): +class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Known values - are: "None", "AADDS", "AD". + :ivar directory_service_options: Indicates the directory service used. Required. Known values + are: "None", "AADDS", and "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_01_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -287,12 +286,12 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): """ _validation = { - 'directory_service_options': {'required': True}, + "directory_service_options": {"required": True}, } _attribute_map = { - 'directory_service_options': {'key': 'directoryServiceOptions', 'type': 'str'}, - 'active_directory_properties': {'key': 'activeDirectoryProperties', 'type': 'ActiveDirectoryProperties'}, + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, } def __init__( @@ -303,20 +302,20 @@ def __init__( **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Known - values are: "None", "AADDS", "AD". + :keyword directory_service_options: Indicates the directory service used. Required. Known + values are: "None", "AADDS", and "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_01_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. :paramtype active_directory_properties: ~azure.mgmt.storage.v2021_01_01.models.ActiveDirectoryProperties """ - super(AzureFilesIdentityBasedAuthentication, self).__init__(**kwargs) + super().__init__(**kwargs) self.directory_service_options = directory_service_options self.active_directory_properties = active_directory_properties -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -346,17 +345,18 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_01_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -377,45 +377,45 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -435,12 +435,12 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_01_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -481,79 +481,69 @@ class BlobInventoryPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified_time": {"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'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'BlobInventoryPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "BlobInventoryPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.BlobInventoryPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs): """ :keyword policy: The storage account blob inventory policy object. It is composed of policy rules. :paramtype policy: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicySchema """ - super(BlobInventoryPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.last_modified_time = None self.policy = policy -class BlobInventoryPolicyDefinition(msrest.serialization.Model): +class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. Each definition consists of a set of filters. All required parameters must be populated in order to send to Azure. - :ivar filters: Required. An object that defines the filter set. + :ivar filters: An object that defines the filter set. Required. :vartype filters: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyFilter """ _validation = { - 'filters': {'required': True}, + "filters": {"required": True}, } _attribute_map = { - 'filters': {'key': 'filters', 'type': 'BlobInventoryPolicyFilter'}, + "filters": {"key": "filters", "type": "BlobInventoryPolicyFilter"}, } - def __init__( - self, - *, - filters: "_models.BlobInventoryPolicyFilter", - **kwargs - ): + def __init__(self, *, filters: "_models.BlobInventoryPolicyFilter", **kwargs): """ - :keyword filters: Required. An object that defines the filter set. + :keyword filters: An object that defines the filter set. Required. :paramtype filters: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyFilter """ - super(BlobInventoryPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.filters = filters -class BlobInventoryPolicyFilter(msrest.serialization.Model): +class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for blob prefixes to be matched. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Valid values include blockBlob, - appendBlob, pageBlob. Hns accounts does not support pageBlobs. + :ivar blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. Required. :vartype blob_types: list[str] :ivar include_blob_versions: Includes blob versions in blob inventory when value set to true. :vartype include_blob_versions: bool @@ -562,14 +552,14 @@ class BlobInventoryPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'include_blob_versions': {'key': 'includeBlobVersions', 'type': 'bool'}, - 'include_snapshots': {'key': 'includeSnapshots', 'type': 'bool'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "include_blob_versions": {"key": "includeBlobVersions", "type": "bool"}, + "include_snapshots": {"key": "includeSnapshots", "type": "bool"}, } def __init__( @@ -584,8 +574,8 @@ def __init__( """ :keyword prefix_match: An array of strings for blob prefixes to be matched. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Valid values include - blockBlob, appendBlob, pageBlob. Hns accounts does not support pageBlobs. + :keyword blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. Required. :paramtype blob_types: list[str] :keyword include_blob_versions: Includes blob versions in blob inventory when value set to true. @@ -593,91 +583,84 @@ def __init__( :keyword include_snapshots: Includes blob snapshots in blob inventory when value set to true. :paramtype include_snapshots: bool """ - super(BlobInventoryPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.include_blob_versions = include_blob_versions self.include_snapshots = include_snapshots -class BlobInventoryPolicyRule(msrest.serialization.Model): +class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Rule is enabled when set to true. + :ivar enabled: Rule is enabled when set to true. Required. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar definition: Required. An object that defines the blob inventory policy rule. + :ivar definition: An object that defines the blob inventory policy rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyDefinition """ _validation = { - 'enabled': {'required': True}, - 'name': {'required': True}, - 'definition': {'required': True}, + "enabled": {"required": True}, + "name": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'BlobInventoryPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "definition": {"key": "definition", "type": "BlobInventoryPolicyDefinition"}, } - def __init__( - self, - *, - enabled: bool, - name: str, - definition: "_models.BlobInventoryPolicyDefinition", - **kwargs - ): + def __init__(self, *, enabled: bool, name: str, definition: "_models.BlobInventoryPolicyDefinition", **kwargs): """ - :keyword enabled: Required. Rule is enabled when set to true. + :keyword enabled: Rule is enabled when set to true. Required. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword definition: Required. An object that defines the blob inventory policy rule. + :keyword definition: An object that defines the blob inventory policy rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyDefinition """ - super(BlobInventoryPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.definition = definition -class BlobInventoryPolicySchema(msrest.serialization.Model): +class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Policy is enabled if set to true. + :ivar enabled: Policy is enabled if set to true. Required. :vartype enabled: bool - :ivar destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :ivar destination: Container name where blob inventory files are stored. Must be pre-created. + Required. :vartype destination: str - :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". + :ivar type: The valid value is Inventory. Required. "Inventory" :vartype type: str or ~azure.mgmt.storage.v2021_01_01.models.InventoryRuleType - :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :ivar rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :vartype rules: list[~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyRule] """ _validation = { - 'enabled': {'required': True}, - 'destination': {'required': True}, - 'type': {'required': True}, - 'rules': {'required': True}, + "enabled": {"required": True}, + "destination": {"required": True}, + "type": {"required": True}, + "rules": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'destination': {'key': 'destination', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rules': {'key': 'rules', 'type': '[BlobInventoryPolicyRule]'}, + "enabled": {"key": "enabled", "type": "bool"}, + "destination": {"key": "destination", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rules": {"key": "rules", "type": "[BlobInventoryPolicyRule]"}, } def __init__( @@ -690,103 +673,91 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Policy is enabled if set to true. + :keyword enabled: Policy is enabled if set to true. Required. :paramtype enabled: bool - :keyword destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :keyword destination: Container name where blob inventory files are stored. Must be + pre-created. Required. :paramtype destination: str - :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". + :keyword type: The valid value is Inventory. Required. "Inventory" :paramtype type: str or ~azure.mgmt.storage.v2021_01_01.models.InventoryRuleType - :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :keyword rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :paramtype rules: list[~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyRule] """ - super(BlobInventoryPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.destination = destination self.type = type self.rules = rules -class BlobRestoreParameters(msrest.serialization.Model): +class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. All required parameters must be populated in order to send to Azure. - :ivar time_to_restore: Required. Restore blob to the specified time. + :ivar time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime - :ivar blob_ranges: Required. Blob ranges to restore. + :ivar blob_ranges: Blob ranges to restore. Required. :vartype blob_ranges: list[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreRange] """ _validation = { - 'time_to_restore': {'required': True}, - 'blob_ranges': {'required': True}, + "time_to_restore": {"required": True}, + "blob_ranges": {"required": True}, } _attribute_map = { - 'time_to_restore': {'key': 'timeToRestore', 'type': 'iso-8601'}, - 'blob_ranges': {'key': 'blobRanges', 'type': '[BlobRestoreRange]'}, + "time_to_restore": {"key": "timeToRestore", "type": "iso-8601"}, + "blob_ranges": {"key": "blobRanges", "type": "[BlobRestoreRange]"}, } - def __init__( - self, - *, - time_to_restore: datetime.datetime, - blob_ranges: List["_models.BlobRestoreRange"], - **kwargs - ): + def __init__(self, *, time_to_restore: datetime.datetime, blob_ranges: List["_models.BlobRestoreRange"], **kwargs): """ - :keyword time_to_restore: Required. Restore blob to the specified time. + :keyword time_to_restore: Restore blob to the specified time. Required. :paramtype time_to_restore: ~datetime.datetime - :keyword blob_ranges: Required. Blob ranges to restore. + :keyword blob_ranges: Blob ranges to restore. Required. :paramtype blob_ranges: list[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreRange] """ - super(BlobRestoreParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_to_restore = time_to_restore self.blob_ranges = blob_ranges -class BlobRestoreRange(msrest.serialization.Model): +class BlobRestoreRange(_serialization.Model): """Blob range. All required parameters must be populated in order to send to Azure. - :ivar start_range: Required. Blob start range. This is inclusive. Empty means account start. + :ivar start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str - :ivar end_range: Required. Blob end range. This is exclusive. Empty means account end. + :ivar end_range: Blob end range. This is exclusive. Empty means account end. Required. :vartype end_range: str """ _validation = { - 'start_range': {'required': True}, - 'end_range': {'required': True}, + "start_range": {"required": True}, + "end_range": {"required": True}, } _attribute_map = { - 'start_range': {'key': 'startRange', 'type': 'str'}, - 'end_range': {'key': 'endRange', 'type': 'str'}, + "start_range": {"key": "startRange", "type": "str"}, + "end_range": {"key": "endRange", "type": "str"}, } - def __init__( - self, - *, - start_range: str, - end_range: str, - **kwargs - ): + def __init__(self, *, start_range: str, end_range: str, **kwargs): """ - :keyword start_range: Required. Blob start range. This is inclusive. Empty means account start. + :keyword start_range: Blob start range. This is inclusive. Empty means account start. Required. :paramtype start_range: str - :keyword end_range: Required. Blob end range. This is exclusive. Empty means account end. + :keyword end_range: Blob end range. This is exclusive. Empty means account end. Required. :paramtype end_range: str """ - super(BlobRestoreRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_range = start_range self.end_range = end_range -class BlobRestoreStatus(msrest.serialization.Model): +class BlobRestoreStatus(_serialization.Model): """Blob restore status. Variables are only populated by the server, and will be ignored when sending a request. @@ -794,7 +765,7 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", - "Complete", "Failed". + "Complete", and "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_01_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -805,33 +776,29 @@ class BlobRestoreStatus(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'restore_id': {'readonly': True}, - 'parameters': {'readonly': True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "restore_id": {"readonly": True}, + "parameters": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'restore_id': {'key': 'restoreId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'BlobRestoreParameters'}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "restore_id": {"key": "restoreId", "type": "str"}, + "parameters": {"key": "parameters", "type": "BlobRestoreParameters"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobRestoreStatus, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.failure_reason = None self.restore_id = None self.parameters = None -class BlobServiceItems(msrest.serialization.Model): +class BlobServiceItems(_serialization.Model): """BlobServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -841,24 +808,20 @@ class BlobServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobServiceProperties]'}, + "value": {"key": "value", "type": "[BlobServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class BlobServiceProperties(Resource): +class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attributes """The properties of a storage account’s Blob service. Variables are only populated by the server, and will be ignored when sending a request. @@ -901,26 +864,32 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'is_versioning_enabled': {'key': 'properties.isVersioningEnabled', 'type': 'bool'}, - 'automatic_snapshot_policy_enabled': {'key': 'properties.automaticSnapshotPolicyEnabled', 'type': 'bool'}, - 'change_feed': {'key': 'properties.changeFeed', 'type': 'ChangeFeed'}, - 'restore_policy': {'key': 'properties.restorePolicy', 'type': 'RestorePolicyProperties'}, - 'container_delete_retention_policy': {'key': 'properties.containerDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'last_access_time_tracking_policy': {'key': 'properties.lastAccessTimeTrackingPolicy', 'type': 'LastAccessTimeTrackingPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "is_versioning_enabled": {"key": "properties.isVersioningEnabled", "type": "bool"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, + "restore_policy": {"key": "properties.restorePolicy", "type": "RestorePolicyProperties"}, + "container_delete_retention_policy": { + "key": "properties.containerDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "last_access_time_tracking_policy": { + "key": "properties.lastAccessTimeTrackingPolicy", + "type": "LastAccessTimeTrackingPolicy", + }, } def __init__( @@ -967,7 +936,7 @@ def __init__( :paramtype last_access_time_tracking_policy: ~azure.mgmt.storage.v2021_01_01.models.LastAccessTimeTrackingPolicy """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.default_service_version = default_service_version @@ -980,7 +949,7 @@ def __init__( self.last_access_time_tracking_policy = last_access_time_tracking_policy -class ChangeFeed(msrest.serialization.Model): +class ChangeFeed(_serialization.Model): """The blob service properties for change feed events. :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. @@ -992,21 +961,15 @@ class ChangeFeed(msrest.serialization.Model): """ _validation = { - 'retention_in_days': {'maximum': 146000, 'minimum': 1}, + "retention_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_in_days': {'key': 'retentionInDays', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_in_days": {"key": "retentionInDays", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - retention_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, retention_in_days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. :paramtype enabled: bool @@ -1015,12 +978,12 @@ def __init__( retention of the change feed. :paramtype retention_in_days: int """ - super(ChangeFeed, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.retention_in_days = retention_in_days -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1030,7 +993,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_01_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1038,30 +1001,26 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1078,10 +1037,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -1106,50 +1065,50 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2021_01_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2021_01_01.models.CorsRuleAllowedMethodsItem] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -1163,24 +1122,24 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2021_01_01.models.CorsRuleAllowedMethodsItem] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -1188,7 +1147,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -1197,31 +1156,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2021_01_01.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -1229,68 +1183,57 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DateAfterCreation(msrest.serialization.Model): +class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. All required parameters must be populated in order to send to Azure. - :ivar days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :vartype days_after_creation_greater_than: float """ _validation = { - 'days_after_creation_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, } - def __init__( - self, - *, - days_after_creation_greater_than: float, - **kwargs - ): + def __init__(self, *, days_after_creation_greater_than: float, **kwargs): """ - :keyword days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :paramtype days_after_creation_greater_than: float """ - super(DateAfterCreation, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_creation_greater_than = days_after_creation_greater_than -class DateAfterModification(msrest.serialization.Model): +class DateAfterModification(_serialization.Model): """Object to define the number of days after object last modification Or last access. Properties daysAfterModificationGreaterThan and daysAfterLastAccessTimeGreaterThan are mutually exclusive. :ivar days_after_modification_greater_than: Value indicating the age in days after last @@ -1303,13 +1246,13 @@ class DateAfterModification(msrest.serialization.Model): """ _validation = { - 'days_after_modification_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_last_access_time_greater_than': {'minimum': 0, 'multiple': 1}, + "days_after_modification_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_access_time_greater_than": {"minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'float'}, - 'days_after_last_access_time_greater_than': {'key': 'daysAfterLastAccessTimeGreaterThan', 'type': 'float'}, + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, + "days_after_last_access_time_greater_than": {"key": "daysAfterLastAccessTimeGreaterThan", "type": "float"}, } def __init__( @@ -1328,7 +1271,7 @@ def __init__( policy. :paramtype days_after_last_access_time_greater_than: float """ - super(DateAfterModification, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_modification_greater_than = days_after_modification_greater_than self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than @@ -1349,24 +1292,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class DeletedAccount(ProxyResource): @@ -1396,34 +1335,30 @@ class DeletedAccount(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'storage_account_resource_id': {'readonly': True}, - 'location': {'readonly': True}, - 'restore_reference': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'deletion_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'location': {'key': 'properties.location', 'type': 'str'}, - 'restore_reference': {'key': 'properties.restoreReference', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, - 'deletion_time': {'key': 'properties.deletionTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccount, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "storage_account_resource_id": {"readonly": True}, + "location": {"readonly": True}, + "restore_reference": {"readonly": True}, + "creation_time": {"readonly": True}, + "deletion_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "location": {"key": "properties.location", "type": "str"}, + "restore_reference": {"key": "properties.restoreReference", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "str"}, + "deletion_time": {"key": "properties.deletionTime", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_account_resource_id = None self.location = None self.restore_reference = None @@ -1431,7 +1366,7 @@ def __init__( self.deletion_time = None -class DeletedAccountListResult(msrest.serialization.Model): +class DeletedAccountListResult(_serialization.Model): """The response from the List Deleted Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1444,70 +1379,60 @@ class DeletedAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeletedAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeletedAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DeletedShare(msrest.serialization.Model): +class DeletedShare(_serialization.Model): """The deleted share to be restored. All required parameters must be populated in order to send to Azure. - :ivar deleted_share_name: Required. Required. Identify the name of the deleted share that will - be restored. + :ivar deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :vartype deleted_share_name: str - :ivar deleted_share_version: Required. Required. Identify the version of the deleted share that - will be restored. + :ivar deleted_share_version: Required. Identify the version of the deleted share that will be + restored. Required. :vartype deleted_share_version: str """ _validation = { - 'deleted_share_name': {'required': True}, - 'deleted_share_version': {'required': True}, + "deleted_share_name": {"required": True}, + "deleted_share_version": {"required": True}, } _attribute_map = { - 'deleted_share_name': {'key': 'deletedShareName', 'type': 'str'}, - 'deleted_share_version': {'key': 'deletedShareVersion', 'type': 'str'}, + "deleted_share_name": {"key": "deletedShareName", "type": "str"}, + "deleted_share_version": {"key": "deletedShareVersion", "type": "str"}, } - def __init__( - self, - *, - deleted_share_name: str, - deleted_share_version: str, - **kwargs - ): + def __init__(self, *, deleted_share_name: str, deleted_share_version: str, **kwargs): """ - :keyword deleted_share_name: Required. Required. Identify the name of the deleted share that - will be restored. + :keyword deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :paramtype deleted_share_name: str - :keyword deleted_share_version: Required. Required. Identify the version of the deleted share - that will be restored. + :keyword deleted_share_version: Required. Identify the version of the deleted share that will + be restored. Required. :paramtype deleted_share_version: str """ - super(DeletedShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.deleted_share_name = deleted_share_name self.deleted_share_version = deleted_share_version -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. @@ -1518,21 +1443,15 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled. :paramtype enabled: bool @@ -1540,12 +1459,12 @@ def __init__( minimum specified value can be 1 and the maximum value can be 365. :paramtype days: int """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -1555,38 +1474,32 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_01_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2021_01_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1598,15 +1511,15 @@ class Encryption(msrest.serialization.Model): """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, - 'encryption_identity': {'key': 'identity', 'type': 'EncryptionIdentity'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, + "encryption_identity": {"key": "identity", "type": "EncryptionIdentity"}, } def __init__( @@ -1622,9 +1535,9 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_01_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2021_01_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1634,7 +1547,7 @@ def __init__( :keyword encryption_identity: The identity to be used with service-side encryption at rest. :paramtype encryption_identity: ~azure.mgmt.storage.v2021_01_01.models.EncryptionIdentity """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption @@ -1642,7 +1555,7 @@ def __init__( self.encryption_identity = encryption_identity -class EncryptionIdentity(msrest.serialization.Model): +class EncryptionIdentity(_serialization.Model): """Encryption identity for the storage account. :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be @@ -1651,21 +1564,16 @@ class EncryptionIdentity(msrest.serialization.Model): """ _attribute_map = { - 'encryption_user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "encryption_user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - encryption_user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, encryption_user_assigned_identity: Optional[str] = None, **kwargs): """ :keyword encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be associated with server-side encryption on the storage account. :paramtype encryption_user_assigned_identity: str """ - super(EncryptionIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.encryption_user_assigned_identity = encryption_user_assigned_identity @@ -1683,11 +1591,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Known values are: "Enabled", "Disabled". + Disabled. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1704,23 +1612,23 @@ class EncryptionScope(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'EncryptionScopeKeyVaultProperties'}, - 'require_infrastructure_encryption': {'key': 'properties.requireInfrastructureEncryption', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "EncryptionScopeKeyVaultProperties"}, + "require_infrastructure_encryption": {"key": "properties.requireInfrastructureEncryption", "type": "bool"}, } def __init__( @@ -1734,11 +1642,11 @@ def __init__( ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Known values are: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -1748,7 +1656,7 @@ def __init__( applies a secondary layer of encryption with platform managed keys for data at rest. :paramtype require_infrastructure_encryption: bool """ - super(EncryptionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.state = state self.creation_time = None @@ -1757,7 +1665,7 @@ def __init__( self.require_infrastructure_encryption = require_infrastructure_encryption -class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): +class EncryptionScopeKeyVaultProperties(_serialization.Model): """The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. Variables are only populated by the server, and will be ignored when sending a request. @@ -1774,35 +1682,30 @@ class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_uri': {'key': 'keyUri', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_uri": {"key": "keyUri", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_uri: Optional[str] = None, **kwargs): """ :keyword key_uri: The object identifier for a key vault key object. When applied, the encryption scope will use the key referenced by the identifier to enable customer-managed key support on this encryption scope. :paramtype key_uri: str """ - super(EncryptionScopeKeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_uri = key_uri self.current_versioned_key_identifier = None self.last_key_rotation_timestamp = None -class EncryptionScopeListResult(msrest.serialization.Model): +class EncryptionScopeListResult(_serialization.Model): """List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. Variables are only populated by the server, and will be ignored when sending a request. @@ -1815,27 +1718,23 @@ class EncryptionScopeListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EncryptionScope]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EncryptionScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(EncryptionScopeListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -1849,26 +1748,22 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Known values are: "Service", "Account". + default service key is used. Known values are: "Service" and "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_01_01.models.KeyType """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'key_type': {'key': 'keyType', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "key_type": {"key": "keyType", "type": "str"}, } def __init__( - self, - *, - enabled: Optional[bool] = None, - key_type: Optional[Union[str, "_models.KeyType"]] = None, - **kwargs + self, *, enabled: Optional[bool] = None, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is @@ -1876,16 +1771,16 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Known values are: "Service", "Account". + that a default service key is used. Known values are: "Service" and "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_01_01.models.KeyType """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None self.key_type = key_type -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. :ivar blob: The encryption function of the blob storage service. @@ -1899,10 +1794,10 @@ class EncryptionServices(msrest.serialization.Model): """ _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -1924,14 +1819,14 @@ def __init__( :keyword queue: The encryption function of the queue storage service. :paramtype queue: ~azure.mgmt.storage.v2021_01_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = table self.queue = queue -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1957,23 +1852,23 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, - 'microsoft_endpoints': {'key': 'microsoftEndpoints', 'type': 'StorageAccountMicrosoftEndpoints'}, - 'internet_endpoints': {'key': 'internetEndpoints', 'type': 'StorageAccountInternetEndpoints'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + "microsoft_endpoints": {"key": "microsoftEndpoints", "type": "StorageAccountMicrosoftEndpoints"}, + "internet_endpoints": {"key": "internetEndpoints", "type": "StorageAccountInternetEndpoints"}, } def __init__( @@ -1991,7 +1886,7 @@ def __init__( :paramtype internet_endpoints: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountInternetEndpoints """ - super(Endpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -2002,7 +1897,7 @@ def __init__( self.internet_endpoints = internet_endpoints -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the storage resource provider. :ivar error: Azure Storage Resource Provider error response body. @@ -2010,24 +1905,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure Storage Resource Provider error response body. :paramtype error: ~azure.mgmt.storage.v2021_01_01.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """Error response body contract. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -2039,17 +1929,11 @@ class ErrorResponseBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. @@ -2058,23 +1942,23 @@ def __init__( interface. :paramtype message: str """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ExtendedLocation(msrest.serialization.Model): +class ExtendedLocation(_serialization.Model): """The complex type of the extended location. :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Known values are: "EdgeZone". + :ivar type: The type of the extended location. "EdgeZone" :vartype type: str or ~azure.mgmt.storage.v2021_01_01.models.ExtendedLocationTypes """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -2087,15 +1971,15 @@ def __init__( """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Known values are: "EdgeZone". + :keyword type: The type of the extended location. "EdgeZone" :paramtype type: str or ~azure.mgmt.storage.v2021_01_01.models.ExtendedLocationTypes """ - super(ExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class FileServiceItems(msrest.serialization.Model): +class FileServiceItems(_serialization.Model): """FileServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -2105,20 +1989,16 @@ class FileServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileServiceProperties]'}, + "value": {"key": "value", "type": "[FileServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -2149,20 +2029,23 @@ class FileServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'share_delete_retention_policy': {'key': 'properties.shareDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'protocol_settings': {'key': 'properties.protocolSettings', 'type': 'ProtocolSettings'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "share_delete_retention_policy": { + "key": "properties.shareDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "protocol_settings": {"key": "properties.protocolSettings", "type": "ProtocolSettings"}, } def __init__( @@ -2184,14 +2067,14 @@ def __init__( :keyword protocol_settings: Protocol settings for file service. :paramtype protocol_settings: ~azure.mgmt.storage.v2021_01_01.models.ProtocolSettings """ - super(FileServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.share_delete_retention_policy = share_delete_retention_policy self.protocol_settings = protocol_settings -class FileShare(AzureEntityResource): +class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the file share, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -2214,10 +2097,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_01_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_01_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2229,7 +2112,7 @@ class FileShare(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2237,48 +2120,48 @@ class FileShare(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long + :vartype share_usage_bytes: int :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares with expand param "snapshots". :vartype snapshot_time: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2298,17 +2181,17 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_01_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_01_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.ShareAccessTier """ - super(FileShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2325,7 +2208,7 @@ def __init__( self.snapshot_time = None -class FileShareItem(AzureEntityResource): +class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The file share properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -2348,10 +2231,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_01_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_01_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2363,7 +2246,7 @@ class FileShareItem(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2371,48 +2254,48 @@ class FileShareItem(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long + :vartype share_usage_bytes: int :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares with expand param "snapshots". :vartype snapshot_time: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2432,17 +2315,17 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_01_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_01_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.ShareAccessTier """ - super(FileShareItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2459,7 +2342,7 @@ def __init__( self.snapshot_time = None -class FileShareItems(msrest.serialization.Model): +class FileShareItems(_serialization.Model): """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. Variables are only populated by the server, and will be ignored when sending a request. @@ -2472,27 +2355,23 @@ class FileShareItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileShareItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileShareItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2501,7 +2380,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_01_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2514,30 +2393,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2548,8 +2423,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_01_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2559,16 +2434,16 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( @@ -2579,8 +2454,8 @@ def __init__( **kwargs ): """ - :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_01_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2588,7 +2463,7 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.storage.v2021_01_01.models.UserAssignedIdentity] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type @@ -2614,7 +2489,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2625,21 +2500,24 @@ class ImmutabilityPolicy(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -2660,13 +2538,13 @@ def __init__( ExtendImmutabilityPolicy API. :paramtype allow_protected_append_writes: bool """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None self.allow_protected_append_writes = allow_protected_append_writes -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2679,7 +2557,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2690,17 +2568,20 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -2721,7 +2602,7 @@ def __init__( ExtendImmutabilityPolicy API. :paramtype allow_protected_append_writes: bool """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days @@ -2729,49 +2610,41 @@ def __init__( self.allow_protected_append_writes = allow_protected_append_writes -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. Variables are only populated by the server, and will be ignored when sending a request. @@ -2790,16 +2663,16 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } def __init__( @@ -2818,7 +2691,7 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri @@ -2826,15 +2699,15 @@ def __init__( self.last_key_rotation_timestamp = None -class LastAccessTimeTrackingPolicy(msrest.serialization.Model): +class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. All required parameters must be populated in order to send to Azure. - :ivar enable: Required. When set to true last access time based tracking is enabled. + :ivar enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Known values are: "AccessTimeTracking". + read only. "AccessTimeTracking" :vartype name: str or ~azure.mgmt.storage.v2021_01_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2846,14 +2719,14 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): """ _validation = { - 'enable': {'required': True}, + "enable": {"required": True}, } _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tracking_granularity_in_days': {'key': 'trackingGranularityInDays', 'type': 'int'}, - 'blob_type': {'key': 'blobType', 'type': '[str]'}, + "enable": {"key": "enable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "tracking_granularity_in_days": {"key": "trackingGranularityInDays", "type": "int"}, + "blob_type": {"key": "blobType", "type": "[str]"}, } def __init__( @@ -2866,10 +2739,10 @@ def __init__( **kwargs ): """ - :keyword enable: Required. When set to true last access time based tracking is enabled. + :keyword enable: When set to true last access time based tracking is enabled. Required. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Known values are: "AccessTimeTracking". + currently read only. "AccessTimeTracking" :paramtype name: str or ~azure.mgmt.storage.v2021_01_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2879,20 +2752,20 @@ def __init__( supported value. This field is currently read only. :paramtype blob_type: list[str] """ - super(LastAccessTimeTrackingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enable = enable self.name = name self.tracking_granularity_in_days = tracking_granularity_in_days self.blob_type = blob_type -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -2908,15 +2781,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -2930,8 +2803,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -2945,7 +2818,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -2953,7 +2826,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -2964,17 +2837,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -2982,12 +2849,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2999,38 +2866,33 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, } - def __init__( - self, - *, - tags: List[str], - **kwargs - ): + def __init__(self, *, tags: List[str], **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3040,35 +2902,30 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2021_01_01.models.TagProperty] """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, } - def __init__( - self, - *, - tags: Optional[List["_models.TagProperty"]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[List["_models.TagProperty"]] = None, **kwargs): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2021_01_01.models.TagProperty] """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3078,24 +2935,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListBlobInventoryPolicy(msrest.serialization.Model): +class ListBlobInventoryPolicy(_serialization.Model): """List of blob inventory policies returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3105,24 +2958,20 @@ class ListBlobInventoryPolicy(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobInventoryPolicy]'}, + "value": {"key": "value", "type": "[BlobInventoryPolicy]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListBlobInventoryPolicy, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -3152,17 +3001,18 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_01_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_01_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3183,45 +3033,45 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -3241,12 +3091,12 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_01_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -3265,7 +3115,7 @@ def __init__( self.has_immutability_policy = None -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. Variables are only populated by the server, and will be ignored when sending a request. @@ -3278,22 +3128,18 @@ class ListContainerItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListContainerItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3316,33 +3162,28 @@ class ListQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(ListQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata -class ListQueueResource(msrest.serialization.Model): +class ListQueueResource(_serialization.Model): """Response schema. Contains list of queues returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3354,27 +3195,23 @@ class ListQueueResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListQueueServices(msrest.serialization.Model): +class ListQueueServices(_serialization.Model): """ListQueueServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -3384,24 +3221,20 @@ class ListQueueServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueServiceProperties]'}, + "value": {"key": "value", "type": "[QueueServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3411,24 +3244,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class ListTableResource(msrest.serialization.Model): +class ListTableResource(_serialization.Model): """Response schema. Contains list of tables returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3440,27 +3269,23 @@ class ListTableResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Table]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Table]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListTableServices(msrest.serialization.Model): +class ListTableServices(_serialization.Model): """ListTableServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -3470,20 +3295,16 @@ class ListTableServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TableServiceProperties]'}, + "value": {"key": "value", "type": "[TableServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -3508,37 +3329,32 @@ class ManagementPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.ManagementPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :paramtype policy: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicySchema """ - super(ManagementPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.policy = policy -class ManagementPolicyAction(msrest.serialization.Model): +class ManagementPolicyAction(_serialization.Model): """Actions are applied to the filtered blobs when the execution condition is met. :ivar base_blob: The management policy action for base blob. @@ -3550,9 +3366,9 @@ class ManagementPolicyAction(msrest.serialization.Model): """ _attribute_map = { - 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, - 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, - 'version': {'key': 'version', 'type': 'ManagementPolicyVersion'}, + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, + "version": {"key": "version", "type": "ManagementPolicyVersion"}, } def __init__( @@ -3571,13 +3387,13 @@ def __init__( :keyword version: The management policy action for version. :paramtype version: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyVersion """ - super(ManagementPolicyAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_blob = base_blob self.snapshot = snapshot self.version = version -class ManagementPolicyBaseBlob(msrest.serialization.Model): +class ManagementPolicyBaseBlob(_serialization.Model): """Management policy action for base blob. :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot @@ -3594,10 +3410,10 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, - 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, - 'enable_auto_tier_to_hot_from_cool': {'key': 'enableAutoTierToHotFromCool', 'type': 'bool'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, + "enable_auto_tier_to_hot_from_cool": {"key": "enableAutoTierToHotFromCool", "type": "bool"}, } def __init__( @@ -3623,31 +3439,31 @@ def __init__( tierToCool.daysAfterLastAccessTimeGreaterThan. :paramtype enable_auto_tier_to_hot_from_cool: bool """ - super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool -class ManagementPolicyDefinition(msrest.serialization.Model): +class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. All required parameters must be populated in order to send to Azure. - :ivar actions: Required. An object that defines the action set. + :ivar actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyAction :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyFilter """ _validation = { - 'actions': {'required': True}, + "actions": {"required": True}, } _attribute_map = { - 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, - 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, } def __init__( @@ -3658,25 +3474,25 @@ def __init__( **kwargs ): """ - :keyword actions: Required. An object that defines the action set. + :keyword actions: An object that defines the action set. Required. :paramtype actions: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyAction :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyFilter """ - super(ManagementPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.filters = filters -class ManagementPolicyFilter(msrest.serialization.Model): +class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :ivar blob_types: An array of predefined enum values. Currently blockBlob supports all tiering + and delete actions. Only delete actions are supported for appendBlob. Required. :vartype blob_types: list[str] :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. @@ -3684,13 +3500,13 @@ class ManagementPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'blob_index_match': {'key': 'blobIndexMatch', 'type': '[TagFilter]'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "blob_index_match": {"key": "blobIndexMatch", "type": "[TagFilter]"}, } def __init__( @@ -3704,46 +3520,46 @@ def __init__( """ :keyword prefix_match: An array of strings for prefixes to be match. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :keyword blob_types: An array of predefined enum values. Currently blockBlob supports all + tiering and delete actions. Only delete actions are supported for appendBlob. Required. :paramtype blob_types: list[str] :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. :paramtype blob_index_match: list[~azure.mgmt.storage.v2021_01_01.models.TagFilter] """ - super(ManagementPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.blob_index_match = blob_index_match -class ManagementPolicyRule(msrest.serialization.Model): +class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. :ivar enabled: Rule is enabled if set to true. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" :vartype type: str or ~azure.mgmt.storage.v2021_01_01.models.RuleType - :ivar definition: Required. An object that defines the Lifecycle rule. + :ivar definition: An object that defines the Lifecycle rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyDefinition """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - 'definition': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, } def __init__( @@ -3758,55 +3574,52 @@ def __init__( """ :keyword enabled: Rule is enabled if set to true. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" :paramtype type: str or ~azure.mgmt.storage.v2021_01_01.models.RuleType - :keyword definition: Required. An object that defines the Lifecycle rule. + :keyword definition: An object that defines the Lifecycle rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyDefinition """ - super(ManagementPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.type = type self.definition = definition -class ManagementPolicySchema(msrest.serialization.Model): +class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. All required parameters must be populated in order to send to Azure. - :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :vartype rules: list[~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyRule] """ _validation = { - 'rules': {'required': True}, + "rules": {"required": True}, } _attribute_map = { - 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, } - def __init__( - self, - *, - rules: List["_models.ManagementPolicyRule"], - **kwargs - ): + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): """ - :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :paramtype rules: list[~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyRule] """ - super(ManagementPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.rules = rules -class ManagementPolicySnapShot(msrest.serialization.Model): +class ManagementPolicySnapShot(_serialization.Model): """Management policy action for snapshot. :ivar tier_to_cool: The function to tier blob snapshot to cool storage. Support blob snapshot @@ -3820,9 +3633,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -3843,13 +3656,13 @@ def __init__( :keyword delete: The function to delete the blob snapshot. :paramtype delete: ~azure.mgmt.storage.v2021_01_01.models.DateAfterCreation """ - super(ManagementPolicySnapShot, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class ManagementPolicyVersion(msrest.serialization.Model): +class ManagementPolicyVersion(_serialization.Model): """Management policy action for blob version. :ivar tier_to_cool: The function to tier blob version to cool storage. Support blob version @@ -3863,9 +3676,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -3886,13 +3699,13 @@ def __init__( :keyword delete: The function to delete the blob version. :paramtype delete: ~azure.mgmt.storage.v2021_01_01.models.DateAfterCreation """ - super(ManagementPolicyVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -3916,15 +3729,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -3961,7 +3774,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -3973,7 +3786,7 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class Multichannel(msrest.serialization.Model): +class Multichannel(_serialization.Model): """Multichannel setting. Applies to Premium FileStorage only. :ivar enabled: Indicates whether multichannel is enabled. @@ -3981,32 +3794,27 @@ class Multichannel(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Indicates whether multichannel is enabled. :paramtype enabled: bool """ - super(Multichannel, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_01_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_01_01.models.ResourceAccessRule] @@ -4014,28 +3822,28 @@ class NetworkRuleSet(msrest.serialization.Model): :vartype virtual_network_rules: list[~azure.mgmt.storage.v2021_01_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_01_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2021_01_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'resource_access_rules': {'key': 'resourceAccessRules', 'type': '[ResourceAccessRule]'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "resource_access_rules": {"key": "resourceAccessRules", "type": "[ResourceAccessRule]"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, @@ -4045,7 +3853,7 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_01_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4055,11 +3863,11 @@ def __init__( list[~azure.mgmt.storage.v2021_01_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_01_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2021_01_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.resource_access_rules = resource_access_rules self.virtual_network_rules = virtual_network_rules @@ -4067,7 +3875,7 @@ def __init__( self.default_action = default_action -class ObjectReplicationPolicies(msrest.serialization.Model): +class ObjectReplicationPolicies(_serialization.Model): """List storage account object replication policies. :ivar value: The replication policy between two storage accounts. @@ -4075,20 +3883,15 @@ class ObjectReplicationPolicies(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ObjectReplicationPolicy]'}, + "value": {"key": "value", "type": "[ObjectReplicationPolicy]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ObjectReplicationPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs): """ :keyword value: The replication policy between two storage accounts. :paramtype value: list[~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy] """ - super(ObjectReplicationPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4118,22 +3921,22 @@ class ObjectReplicationPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_id': {'readonly': True}, - 'enabled_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_id": {"readonly": True}, + "enabled_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, - 'enabled_time': {'key': 'properties.enabledTime', 'type': 'iso-8601'}, - 'source_account': {'key': 'properties.sourceAccount', 'type': 'str'}, - 'destination_account': {'key': 'properties.destinationAccount', 'type': 'str'}, - 'rules': {'key': 'properties.rules', 'type': '[ObjectReplicationPolicyRule]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "enabled_time": {"key": "properties.enabledTime", "type": "iso-8601"}, + "source_account": {"key": "properties.sourceAccount", "type": "str"}, + "destination_account": {"key": "properties.destinationAccount", "type": "str"}, + "rules": {"key": "properties.rules", "type": "[ObjectReplicationPolicyRule]"}, } def __init__( @@ -4152,7 +3955,7 @@ def __init__( :keyword rules: The storage account object replication rules. :paramtype rules: list[~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicyRule] """ - super(ObjectReplicationPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_id = None self.enabled_time = None self.source_account = source_account @@ -4160,7 +3963,7 @@ def __init__( self.rules = rules -class ObjectReplicationPolicyFilter(msrest.serialization.Model): +class ObjectReplicationPolicyFilter(_serialization.Model): """Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the filter. If multiple filters are defined, a logical AND is performed on all filters. :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin @@ -4172,17 +3975,11 @@ class ObjectReplicationPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'min_creation_time': {'key': 'minCreationTime', 'type': 'str'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "min_creation_time": {"key": "minCreationTime", "type": "str"}, } - def __init__( - self, - *, - prefix_match: Optional[List[str]] = None, - min_creation_time: Optional[str] = None, - **kwargs - ): + def __init__(self, *, prefix_match: Optional[List[str]] = None, min_creation_time: Optional[str] = None, **kwargs): """ :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. @@ -4191,12 +3988,12 @@ def __init__( It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. :paramtype min_creation_time: str """ - super(ObjectReplicationPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.min_creation_time = min_creation_time -class ObjectReplicationPolicyRule(msrest.serialization.Model): +class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. All required parameters must be populated in order to send to Azure. @@ -4204,24 +4001,24 @@ class ObjectReplicationPolicyRule(msrest.serialization.Model): :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :vartype rule_id: str - :ivar source_container: Required. Required. Source container name. + :ivar source_container: Required. Source container name. Required. :vartype source_container: str - :ivar destination_container: Required. Required. Destination container name. + :ivar destination_container: Required. Destination container name. Required. :vartype destination_container: str :ivar filters: Optional. An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicyFilter """ _validation = { - 'source_container': {'required': True}, - 'destination_container': {'required': True}, + "source_container": {"required": True}, + "destination_container": {"required": True}, } _attribute_map = { - 'rule_id': {'key': 'ruleId', 'type': 'str'}, - 'source_container': {'key': 'sourceContainer', 'type': 'str'}, - 'destination_container': {'key': 'destinationContainer', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': 'ObjectReplicationPolicyFilter'}, + "rule_id": {"key": "ruleId", "type": "str"}, + "source_container": {"key": "sourceContainer", "type": "str"}, + "destination_container": {"key": "destinationContainer", "type": "str"}, + "filters": {"key": "filters", "type": "ObjectReplicationPolicyFilter"}, } def __init__( @@ -4237,21 +4034,21 @@ def __init__( :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :paramtype rule_id: str - :keyword source_container: Required. Required. Source container name. + :keyword source_container: Required. Source container name. Required. :paramtype source_container: str - :keyword destination_container: Required. Required. Destination container name. + :keyword destination_container: Required. Destination container name. Required. :paramtype destination_container: str :keyword filters: Optional. An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicyFilter """ - super(ObjectReplicationPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.rule_id = rule_id self.source_container = source_container self.destination_container = destination_container self.filters = filters -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -4265,10 +4062,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -4290,14 +4087,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2021_01_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -4311,10 +4108,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -4336,14 +4133,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -4351,24 +4148,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2021_01_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4378,20 +4170,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -4415,25 +4203,28 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_01_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -4451,13 +4242,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.storage.v2021_01_01.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """List of private endpoint connection associated with the specified storage account. :ivar value: Array of private endpoint connections. @@ -4465,20 +4256,15 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4504,39 +4290,34 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "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, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): """ :keyword required_zone_names: The private link resource Private link DNS zone name. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. @@ -4544,28 +4325,23 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.storage.v2021_01_01.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", and "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -4576,9 +4352,9 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'action_required': {'key': 'actionRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "action_required": {"key": "actionRequired", "type": "str"}, } def __init__( @@ -4591,7 +4367,7 @@ def __init__( ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", and "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -4600,13 +4376,13 @@ def __init__( updates on the consumer. :paramtype action_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.action_required = action_required -class ProtocolSettings(msrest.serialization.Model): +class ProtocolSettings(_serialization.Model): """Protocol settings for file service. :ivar smb: Setting for SMB protocol. @@ -4614,20 +4390,15 @@ class ProtocolSettings(msrest.serialization.Model): """ _attribute_map = { - 'smb': {'key': 'smb', 'type': 'SmbSetting'}, + "smb": {"key": "smb", "type": "SmbSetting"}, } - def __init__( - self, - *, - smb: Optional["_models.SmbSetting"] = None, - **kwargs - ): + def __init__(self, *, smb: Optional["_models.SmbSetting"] = None, **kwargs): """ :keyword smb: Setting for SMB protocol. :paramtype smb: ~azure.mgmt.storage.v2021_01_01.models.SmbSetting """ - super(ProtocolSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.smb = smb @@ -4651,35 +4422,30 @@ class QueueServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Queue service. :paramtype cors: ~azure.mgmt.storage.v2021_01_01.models.CorsRules """ - super(QueueServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class ResourceAccessRule(msrest.serialization.Model): +class ResourceAccessRule(_serialization.Model): """Resource Access Rule. :ivar tenant_id: Tenant Id. @@ -4689,36 +4455,30 @@ class ResourceAccessRule(msrest.serialization.Model): """ _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__( - self, - *, - tenant_id: Optional[str] = None, - resource_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tenant_id: Optional[str] = None, resource_id: Optional[str] = None, **kwargs): """ :keyword tenant_id: Tenant Id. :paramtype tenant_id: str :keyword resource_id: Resource Id. :paramtype resource_id: str """ - super(ResourceAccessRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.tenant_id = tenant_id self.resource_id = resource_id -class RestorePolicyProperties(msrest.serialization.Model): +class RestorePolicyProperties(_serialization.Model): """The blob service properties for blob restore policy. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Blob restore is enabled if set to true. + :ivar enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool :ivar days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. @@ -4730,41 +4490,35 @@ class RestorePolicyProperties(msrest.serialization.Model): """ _validation = { - 'enabled': {'required': True}, - 'days': {'maximum': 365, 'minimum': 1}, - 'last_enabled_time': {'readonly': True}, - 'min_restore_time': {'readonly': True}, + "enabled": {"required": True}, + "days": {"maximum": 365, "minimum": 1}, + "last_enabled_time": {"readonly": True}, + "min_restore_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'min_restore_time': {'key': 'minRestoreTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "min_restore_time": {"key": "minRestoreTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: bool, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: bool, days: Optional[int] = None, **kwargs): """ - :keyword enabled: Required. Blob restore is enabled if set to true. + :keyword enabled: Blob restore is enabled if set to true. Required. :paramtype enabled: bool :keyword days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. :paramtype days: int """ - super(RestorePolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days self.last_enabled_time = None self.min_restore_time = None -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -4777,45 +4531,40 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_01_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_01_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class RoutingPreference(msrest.serialization.Model): +class RoutingPreference(_serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_01_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4826,9 +4575,9 @@ class RoutingPreference(msrest.serialization.Model): """ _attribute_map = { - 'routing_choice': {'key': 'routingChoice', 'type': 'str'}, - 'publish_microsoft_endpoints': {'key': 'publishMicrosoftEndpoints', 'type': 'bool'}, - 'publish_internet_endpoints': {'key': 'publishInternetEndpoints', 'type': 'bool'}, + "routing_choice": {"key": "routingChoice", "type": "str"}, + "publish_microsoft_endpoints": {"key": "publishMicrosoftEndpoints", "type": "bool"}, + "publish_internet_endpoints": {"key": "publishInternetEndpoints", "type": "bool"}, } def __init__( @@ -4841,7 +4590,7 @@ def __init__( ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_01_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4850,31 +4599,31 @@ def __init__( storage endpoints are to be published. :paramtype publish_internet_endpoints: bool """ - super(RoutingPreference, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_choice = routing_choice self.publish_microsoft_endpoints = publish_microsoft_endpoints self.publish_internet_endpoints = publish_internet_endpoints -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2021_01_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_01_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_01_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -4906,29 +4655,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, - } - - _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, + } + + _attribute_map = { + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -4955,20 +4704,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_01_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_01_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_01_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -4999,7 +4749,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -5020,7 +4770,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -5029,70 +4779,60 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2021_01_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_01_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_01_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_01_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -5105,45 +4845,41 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Storage SKU and its properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_01_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_01_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -5157,22 +4893,22 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -5183,16 +4919,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_01_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2021_01_01.models.Restriction] """ - super(SkuInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -5202,7 +4938,7 @@ def __init__( self.restrictions = restrictions -class SmbSetting(msrest.serialization.Model): +class SmbSetting(_serialization.Model): """Setting for SMB protocol. :ivar multichannel: Multichannel setting. Applies to Premium FileStorage only. @@ -5222,11 +4958,11 @@ class SmbSetting(msrest.serialization.Model): """ _attribute_map = { - 'multichannel': {'key': 'multichannel', 'type': 'Multichannel'}, - 'versions': {'key': 'versions', 'type': 'str'}, - 'authentication_methods': {'key': 'authenticationMethods', 'type': 'str'}, - 'kerberos_ticket_encryption': {'key': 'kerberosTicketEncryption', 'type': 'str'}, - 'channel_encryption': {'key': 'channelEncryption', 'type': 'str'}, + "multichannel": {"key": "multichannel", "type": "Multichannel"}, + "versions": {"key": "versions", "type": "str"}, + "authentication_methods": {"key": "authenticationMethods", "type": "str"}, + "kerberos_ticket_encryption": {"key": "kerberosTicketEncryption", "type": "str"}, + "channel_encryption": {"key": "channelEncryption", "type": "str"}, } def __init__( @@ -5255,7 +4991,7 @@ def __init__( AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. :paramtype channel_encryption: str """ - super(SmbSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.multichannel = multichannel self.versions = versions self.authentication_methods = authentication_methods @@ -5278,46 +5014,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -5332,21 +5062,21 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_01_01.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_01_01.models.Identity :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_01_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_01_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -5355,7 +5085,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_01_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -5367,7 +5097,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_01_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -5381,7 +5111,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2021_01_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5399,7 +5129,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -5416,7 +5146,7 @@ class StorageAccount(TrackedResource): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5428,70 +5158,76 @@ class StorageAccount(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'blob_restore_status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'blob_restore_status': {'key': 'properties.blobRestoreStatus', 'type': 'BlobRestoreStatus'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "blob_restore_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "blob_restore_status": {"key": "properties.blobRestoreStatus", "type": "BlobRestoreStatus"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -5510,9 +5246,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_01_01.models.Identity @@ -5528,7 +5264,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5539,7 +5275,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5549,7 +5285,7 @@ def __init__( :keyword enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. :paramtype enable_nfs_v3: bool """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -5582,69 +5318,64 @@ def __init__( self.enable_nfs_v3 = enable_nfs_v3 -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_01_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str :ivar extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :vartype extended_location: ~azure.mgmt.storage.v2021_01_01.models.ExtendedLocation - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_01_01.models.Identity @@ -5658,7 +5389,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_01_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5670,7 +5401,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -5681,7 +5412,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5693,31 +5424,34 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, } def __init__( @@ -5745,24 +5479,24 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2021_01_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str :keyword extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :paramtype extended_location: ~azure.mgmt.storage.v2021_01_01.models.ExtendedLocation - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_01_01.models.Identity @@ -5776,7 +5510,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_01_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5788,7 +5522,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5799,7 +5533,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5809,7 +5543,7 @@ def __init__( :keyword enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. :paramtype enable_nfs_v3: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -5831,7 +5565,7 @@ def __init__( self.enable_nfs_v3 = enable_nfs_v3 -class StorageAccountInternetEndpoints(msrest.serialization.Model): +class StorageAccountInternetEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -5847,33 +5581,29 @@ class StorageAccountInternetEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountInternetEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.file = None self.web = None self.dfs = None -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -5883,35 +5613,31 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_01_01.models.KeyPermission """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -5922,24 +5648,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -5952,27 +5674,23 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): +class StorageAccountMicrosoftEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -5992,30 +5710,26 @@ class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountMicrosoftEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -6024,55 +5738,50 @@ def __init__( self.dfs = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2, kerb1, kerb2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2, kerb1, kerb2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2021_01_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_01_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6082,7 +5791,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2021_01_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6093,7 +5802,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_01_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6104,7 +5813,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6114,21 +5823,24 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, } def __init__( @@ -6156,16 +5868,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2021_01_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_01_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_01_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6175,7 +5887,7 @@ def __init__( unencrypted. :paramtype encryption: ~azure.mgmt.storage.v2021_01_01.models.Encryption :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_01_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6187,7 +5899,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_01_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_01_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6198,7 +5910,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_01_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6206,7 +5918,7 @@ def __init__( default value is null, which is equivalent to true. :paramtype allow_shared_key_access: bool """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -6246,36 +5958,31 @@ class StorageQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'approximate_message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "approximate_message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'approximate_message_count': {'key': 'properties.approximateMessageCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "approximate_message_count": {"key": "properties.approximateMessageCount", "type": "int"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(StorageQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata self.approximate_message_count = None -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -6285,49 +5992,45 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuInformation]'}, + "value": {"key": "value", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_01_01.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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_01_01.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'}, + "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__( @@ -6345,19 +6048,19 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_01_01.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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_01_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -6384,26 +6087,22 @@ class Table(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'table_name': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "table_name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Table, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.table_name = None @@ -6427,86 +6126,74 @@ class TableServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Table service. :paramtype cors: ~azure.mgmt.storage.v2021_01_01.models.CorsRules """ - super(TableServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class TagFilter(msrest.serialization.Model): +class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. All required parameters must be populated in order to send to Azure. - :ivar name: Required. This is the filter tag name, it can have 1 - 128 characters. + :ivar name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str - :ivar op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :ivar op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :vartype op: str - :ivar value: Required. This is the filter tag value field used for tag based filtering, it can - have 0 - 256 characters. + :ivar value: This is the filter tag value field used for tag based filtering, it can have 0 - + 256 characters. Required. :vartype value: str """ _validation = { - 'name': {'required': True, 'max_length': 128, 'min_length': 1}, - 'op': {'required': True}, - 'value': {'required': True, 'max_length': 256, 'min_length': 0}, + "name": {"required": True, "max_length": 128, "min_length": 1}, + "op": {"required": True}, + "value": {"required": True, "max_length": 256}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'op': {'key': 'op', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "op": {"key": "op", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - op: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, op: str, value: str, **kwargs): """ - :keyword name: Required. This is the filter tag name, it can have 1 - 128 characters. + :keyword name: This is the filter tag name, it can have 1 - 128 characters. Required. :paramtype name: str - :keyword op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :keyword op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :paramtype op: str - :keyword value: Required. This is the filter tag value field used for tag based filtering, it - can have 0 - 256 characters. + :keyword value: This is the filter tag value field used for tag based filtering, it can have 0 + - 256 characters. Required. :paramtype value: str """ - super(TagFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.op = op self.value = value -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -6524,28 +6211,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -6553,13 +6236,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -6576,30 +6259,26 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -6608,13 +6287,13 @@ def __init__( self.upn = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_01_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -6625,33 +6304,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -6659,24 +6334,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2021_01_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -6688,27 +6358,23 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """UserAssignedIdentity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -6720,72 +6386,68 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_01_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_01_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py index 18bb429d480d..fc9efc6bbd4e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,10 +25,13 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobInventoryPolicyName.""" DEFAULT = "default" + class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - @@ -39,6 +42,7 @@ class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): COMPLETE = "Complete" FAILED = "Failed" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -50,7 +54,9 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CorsRuleAllowedMethodsItem.""" DELETE = "DELETE" GET = "GET" @@ -60,30 +66,31 @@ class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): OPTIONS = "OPTIONS" PUT = "PUT" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the directory service used. - """ + """Indicates the directory service used.""" NONE = "None" AADDS = "AADDS" AD = "AD" + class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. @@ -92,6 +99,7 @@ class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): SMB = "SMB" NFS = "NFS" + class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. @@ -100,19 +108,26 @@ class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. - """ + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + +class Enum30(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum30.""" + + DEFAULT = "default" + + class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation. - """ + """The type of extendedLocation.""" EDGE_ZONE = "EdgeZone" + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -125,29 +140,30 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type. - """ + """The identity type.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -157,27 +173,29 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Inventory - """ + """The valid value is Inventory.""" INVENTORY = "Inventory" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service @@ -187,9 +205,9 @@ class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SERVICE = "Service" ACCOUNT = "Account" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -197,22 +215,23 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - """ + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -222,9 +241,9 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -232,26 +251,33 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListContainersInclude.""" DELETED = "deleted" + class ListSharesExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListSharesExpand.""" DELETED = "deleted" SNAPSHOTS = "snapshots" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. @@ -261,12 +287,13 @@ class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" + class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only - """ + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only.""" ACCESS_TIME_TRACKING = "AccessTimeTracking" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -281,43 +308,46 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state. - """ + """The current provisioning state.""" SUCCEEDED = "Succeeded" CREATING = "Creating" DELETING = "Deleting" FAILED = "Failed" + class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status. - """ + """The private endpoint connection status.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class PutSharesExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PutSharesExpand.""" SNAPSHOTS = "snapshots" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -326,6 +356,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -336,27 +367,28 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The property is for NFS share only. The default is NoRootSquash. - """ + """The property is for NFS share only. The default is NoRootSquash.""" NO_ROOT_SQUASH = "NoRootSquash" ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" + class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Routing Choice defines the kind of network routing opted by the user. - """ + """Routing Choice defines the kind of network routing opted by the user.""" MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" + class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Lifecycle - """ + """The valid value is Lifecycle.""" LIFECYCLE = "Lifecycle" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -367,6 +399,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. @@ -377,6 +410,7 @@ class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): COOL = "Cool" PREMIUM = "Premium" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -387,6 +421,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -397,6 +432,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -411,16 +447,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SKU tier. This is based on the SKU name. - """ + """The SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "provisioning" DEPROVISIONING = "deprovisioning" @@ -428,14 +464,16 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" + class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountExpand.""" GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/__init__.py index 9a63fd415725..a7c5747747ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/__init__.py @@ -29,26 +29,27 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_operations.py index 8546383ef85c..5bad921f41c4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_containers_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -34,361 +48,307 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum30], subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum30], subscription_id: str, *, if_match: Optional[str] = None, @@ -397,43 +357,42 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum30], subscription_id: str, *, if_match: str, @@ -442,36 +401,34 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -486,34 +443,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -523,93 +479,79 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class BlobContainersOperations: """ @@ -630,7 +572,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -638,18 +579,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> Iterable[_models.ListContainerItems]: + ) -> Iterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -658,35 +599,39 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_01_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -694,18 +639,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -722,10 +666,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -735,19 +677,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -755,37 +697,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -795,7 +824,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -803,10 +833,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -814,63 +843,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -880,7 +995,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -888,72 +1004,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -961,72 +1073,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1034,10 +1142,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1047,16 +1154,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1064,37 +1172,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1104,7 +1299,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1112,70 +1308,155 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_01_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -1185,7 +1466,8 @@ def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1193,51 +1475,55 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum30], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -1245,44 +1531,144 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum30], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum30], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1290,10 +1676,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1301,17 +1686,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1319,6 +1703,7 @@ def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum30], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1326,52 +1711,52 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1379,10 +1764,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1390,17 +1774,16 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( @@ -1408,6 +1791,7 @@ def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum30], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1417,52 +1801,52 @@ def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1470,10 +1854,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1481,71 +1864,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1553,10 +1932,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1564,19 +1942,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1584,6 +1961,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1591,56 +1970,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1648,10 +2126,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1659,65 +2136,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1727,7 +2290,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1735,22 +2299,20 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_operations.py index 7629c296a612..abf5192ec058 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_inventory_policies_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,167 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - *, - json: Optional[_models.BlobInventoryPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobInventoryPoliciesOperations: """ @@ -207,52 +208,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -260,10 +262,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -271,68 +272,151 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy 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 - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -340,10 +424,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -351,61 +434,62 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -413,10 +497,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -427,51 +510,50 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -479,15 +561,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -504,10 +588,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -518,8 +600,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_operations.py index 151a7b578c04..840159c2f378 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_blob_services_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,134 +27,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum30], subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum30], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -168,47 +170,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -216,15 +220,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -241,10 +247,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -254,66 +258,149 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum30], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum30], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum30], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -321,72 +408,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum30], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -394,22 +476,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_operations.py index b93535f0bfaa..eb90ef3ec468 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_deleted_accounts_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,81 +27,74 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_get_request( - deleted_account_name: str, - location: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(deleted_account_name: str, location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), - "location": _SERIALIZER.url("location", location, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "deletedAccountName": _SERIALIZER.url( + "deleted_account_name", deleted_account_name, "str", max_length=24, min_length=3 + ), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DeletedAccountsOperations: """ @@ -115,38 +115,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DeletedAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -154,13 +152,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -177,10 +179,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -191,48 +191,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace - def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,10 +235,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,12 +245,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_operations.py index 750ac842cb0d..6563d111f5c8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_encryption_scopes_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,181 +27,164 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_put_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EncryptionScopesOperations: """ @@ -215,14 +205,15 @@ def __init__(self, *args, **kwargs): 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 + @overload def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -230,47 +221,137 @@ def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -278,10 +359,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -290,73 +370,160 @@ def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace + @overload def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -364,10 +531,9 @@ def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,62 +541,59 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -438,10 +601,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,58 +611,54 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.EncryptionScopeListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -508,15 +666,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -533,10 +693,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -546,8 +704,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_operations.py index e7147163b52f..f6f8a5aa93c0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum30], subscription_id: str, - *, - json: Optional[_models.FileServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum30], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class FileServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +211,162 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum30], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum30], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum30], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +374,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum30], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +442,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_operations.py index c56e9fedbed2..b2c7cdde39b8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_file_shares_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -34,44 +48,43 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, + expand: Optional[Union[str, _models.ListSharesExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( @@ -80,95 +93,80 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: Optional[_models.FileShare] = None, - content: Any = None, - expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, + expand: Optional[Union[str, _models.PutSharesExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -177,44 +175,43 @@ def build_get_request( share_name: str, subscription_id: str, *, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -229,82 +226,72 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_restore_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.DeletedShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class FileSharesOperations: """ @@ -325,7 +312,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -333,17 +319,17 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, + expand: Optional[Union[str, _models.ListSharesExpand]] = None, **kwargs: Any - ) -> Iterable[_models.FileShareItems]: + ) -> Iterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -351,36 +337,40 @@ def list( :param filter: Optional. When specified, only share names starting with the filter will be listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. Default value - is None. + :param expand: Optional, used to expand the properties within share's properties. Known values + are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -388,18 +378,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -416,10 +405,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -429,20 +416,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, - expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -450,50 +437,144 @@ def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare - :param expand: Optional, used to create a snapshot. Default value is None. + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. + :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare or IO + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. + :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.PutSharesExpand + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -501,10 +582,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -512,63 +592,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_01_01.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -578,7 +744,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -586,25 +753,23 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def get( @@ -612,56 +777,58 @@ def get( resource_group_name: str, account_name: str, share_name: str, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Known values - are "stats" or None. Default value is "stats". + are "stats" and None. Default value is "stats". :type expand: str :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -669,25 +836,23 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -701,44 +866,46 @@ def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -746,10 +913,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -759,52 +925,135 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace + @overload def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_01_01.models.DeletedShare + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_01_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -814,7 +1063,8 @@ def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -822,10 +1072,9 @@ def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -835,5 +1084,4 @@ def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_operations.py index 008ce8c80c71..04ad0f53724f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,130 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,52 +169,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -215,78 +223,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy 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 - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -294,71 +384,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_01_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -366,10 +456,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +468,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_operations.py index c9e110b5a3ee..011080394d66 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_object_replication_policies_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,161 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - *, - json: Optional[_models.ObjectReplicationPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ObjectReplicationPoliciesOperations: """ @@ -207,49 +202,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +252,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +279,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -296,56 +291,52 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -353,10 +344,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -364,68 +354,150 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy 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 - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -433,10 +505,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -444,60 +515,57 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -505,10 +573,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -519,5 +586,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_operations.py index c5f41824146a..7575bf09c392 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_endpoint_connections_operations.py index fa12779a547a..1e29d4bb2e3a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,173 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -207,49 +214,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +264,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +291,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,56 +302,52 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -352,10 +355,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,67 +365,148 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace + @overload def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection 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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -431,10 +514,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,60 +524,57 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -503,10 +582,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -517,5 +595,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_link_resources_operations.py index 81443bac130a..c17ea48f0e3c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,52 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_storage_account_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,46 +91,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -128,22 +136,20 @@ def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_operations.py index 18c906589a10..ab43a7061811 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,183 +27,188 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( @@ -211,36 +223,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueOperations: """ @@ -261,60 +273,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -322,79 +419,163 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -402,72 +583,66 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.StorageQueue: + def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -475,72 +650,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -548,10 +719,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -561,8 +731,7 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -572,15 +741,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.ListQueueResource]: + ) -> Iterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -589,31 +758,35 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -621,17 +794,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -648,10 +821,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -661,8 +832,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_operations.py index d28d1b045ca7..e83cd8b8370a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_queue_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum30], subscription_id: str, - *, - json: Optional[_models.QueueServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum30], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +211,163 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum30], parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :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: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum30], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum30], + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties 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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +375,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum30], **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +443,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_operations.py index 664da336b8d6..6477c92f6a37 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_operations.py index 11f13a3456e1..e189cd9284da 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +29,110 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,153 +140,129 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -304,280 +270,238 @@ def build_list_keys_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "kerb", + expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_restore_blob_ranges_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobRestoreParameters] = None, - content: Any = None, - **kwargs: Any +def build_restore_blob_ranges_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revoke_user_delegation_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: """ @@ -598,45 +522,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2021_01_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -644,55 +621,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -700,10 +685,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -712,22 +696,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -736,14 +721,17 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCreateParameters + :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 @@ -755,20 +743,98 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -776,79 +842,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -856,10 +917,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -869,15 +929,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -885,40 +944,43 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_01_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -926,32 +988,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -964,32 +1026,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountUpdateParameters + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -998,7 +1145,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1006,58 +1154,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1065,13 +1210,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1088,10 +1237,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1101,49 +1248,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1151,14 +1294,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1175,10 +1321,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1188,57 +1332,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1246,65 +1386,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_01_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1313,7 +1526,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1321,63 +1535,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1386,7 +1673,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1394,63 +1682,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1459,7 +1818,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1467,50 +1827,47 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1518,10 +1875,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1531,26 +1887,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1562,85 +1912,90 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1648,10 +2003,9 @@ def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1659,38 +2013,80 @@ def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace + @overload def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1702,20 +2098,54 @@ def begin_restore_blob_ranges( :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.BlobRestoreParameters 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. + :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_01_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1723,79 +2153,76 @@ def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1803,10 +2230,9 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1816,5 +2242,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_operations.py index 57d12e08be7b..a9761da609f3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,204 +27,194 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableOperations: """ @@ -238,52 +235,47 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def create(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -291,71 +283,65 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -363,71 +349,65 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -435,71 +415,67 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -507,10 +483,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -520,49 +495,47 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -570,15 +543,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -595,10 +570,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,8 +581,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_operations.py index 00744a5403e6..65ebad748ffd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_table_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum30], subscription_id: str, - *, - json: Optional[_models.TableServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum30], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +211,163 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum30], parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :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: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum30], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum30], + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties 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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +375,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum30], **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_01_01.models.Enum30 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_01_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +443,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_operations.py index 20aef2cc985b..f21e0ca2b20b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_01_01/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,41 +87,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_01_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-01-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-01-01")) # type: Literal["2021-01-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -122,14 +128,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -146,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -159,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_configuration.py index 33fa3a464384..c4e0321493c4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-02-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-02-01") # type: str + api_version = kwargs.pop("api_version", "2021-02-01") # type: Literal["2021-02-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json index fd77f718b432..1314530cfc01 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -117,4 +117,4 @@ "table_services": "TableServicesOperations", "table": "TableOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py index 54c29d928402..5ac78c52bbea 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_storage_management_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -69,9 +89,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_02_01.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_02_01.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -89,28 +109,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -129,37 +145,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -168,7 +163,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_configuration.py index c4ec19bcf03f..c1da39352795 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-02-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-02-01") # type: str + api_version = kwargs.pop("api_version", "2021-02-01") # type: Literal["2021-02-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py index 3ebd13841c38..593452f2aadb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/_storage_management_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -72,9 +92,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_02_01.aio.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_02_01.aio.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -92,28 +112,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -132,37 +148,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -171,7 +166,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/__init__.py index 9a63fd415725..a7c5747747ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/__init__.py @@ -29,26 +29,27 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_operations.py index 7d1829d5c90d..ed5ee4f261e5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_containers_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,30 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -43,7 +72,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,18 +79,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListContainerItems]: + ) -> AsyncIterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -71,36 +99,40 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_02_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -108,18 +140,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -136,10 +167,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,19 +178,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -169,37 +198,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -209,7 +325,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -217,10 +334,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -228,63 +344,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -294,7 +496,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -302,72 +505,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -375,72 +574,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -448,10 +643,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -461,16 +655,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -478,37 +673,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -518,7 +800,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -526,70 +809,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -599,7 +967,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -607,51 +976,55 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum31], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -659,44 +1032,144 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum31], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum31], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -704,10 +1177,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -715,17 +1187,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -733,6 +1204,7 @@ async def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum31], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -740,52 +1212,52 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -793,10 +1265,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -804,17 +1275,16 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -822,6 +1292,7 @@ async def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum31], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -831,52 +1302,52 @@ async def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -884,10 +1355,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -895,71 +1365,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -967,10 +1433,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -978,19 +1443,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -998,6 +1462,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1005,56 +1471,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1062,10 +1627,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1073,65 +1637,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1141,7 +1791,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1149,22 +1800,20 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_operations.py index e71707a26c3f..695b0b5990d5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_inventory_policies_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_inventory_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._blob_inventory_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobInventoryPoliciesOperations: """ .. warning:: @@ -43,52 +63,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +117,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,68 +127,151 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy 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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -176,10 +279,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,61 +289,62 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -249,10 +352,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -263,51 +365,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -315,15 +416,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -340,10 +443,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -354,8 +455,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_operations.py index 45724be01a06..43aceb820d26 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_blob_services_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -43,48 +62,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,66 +150,149 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum31], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum31], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum31], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -197,72 +300,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum31], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -270,22 +368,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_operations.py index 4cb974e06749..2cca19a8e4c2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_deleted_accounts_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DeletedAccountsOperations: """ .. warning:: @@ -43,38 +58,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) + :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -82,13 +96,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -105,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -119,48 +135,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async - async def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -168,10 +179,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,12 +189,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_operations.py index 14dd0da30aef..546bc029598b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_encryption_scopes_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._encryption_scopes_operations import build_get_request, build_list_request, build_patch_request, build_put_request -T = TypeVar('T') +from ...operations._encryption_scopes_operations import ( + build_get_request, + build_list_request, + build_patch_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EncryptionScopesOperations: """ .. warning:: @@ -43,14 +63,15 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -58,47 +79,137 @@ async def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -106,10 +217,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -118,73 +228,160 @@ async def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace_async + @overload async def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +389,9 @@ async def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,62 +399,59 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -266,10 +459,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -277,58 +469,57 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EncryptionScopeListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) + :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -336,15 +527,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -361,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -374,8 +565,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_operations.py index bdcf3b98ab74..b179b653f219 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +102,162 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum31], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum31], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum31], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +265,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum31], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +333,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_operations.py index c9b6c343b7c2..6ed256b9ee3e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_file_shares_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_shares_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_restore_request, build_update_request -T = TypeVar('T') +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_restore_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileSharesOperations: """ .. warning:: @@ -43,7 +65,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -51,17 +72,17 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, + expand: Optional[Union[str, _models.ListSharesExpand]] = None, **kwargs: Any - ) -> AsyncIterable[_models.FileShareItems]: + ) -> AsyncIterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -69,37 +90,41 @@ def list( :param filter: Optional. When specified, only share names starting with the filter will be listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. Default value - is None. + :param expand: Optional, used to expand the properties within share's properties. Known values + are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) + :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -107,18 +132,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -135,10 +159,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -148,20 +170,20 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, - expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -169,50 +191,144 @@ async def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare - :param expand: Optional, used to create a snapshot. Default value is None. + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. + :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare or IO + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. + :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -220,10 +336,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -231,63 +346,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -297,7 +498,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -305,25 +507,23 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def get( @@ -331,56 +531,58 @@ async def get( resource_group_name: str, account_name: str, share_name: str, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Known values - are "stats" or None. Default value is "stats". + are "stats" and None. Default value is "stats". :type expand: str :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -388,25 +590,23 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -420,44 +620,46 @@ async def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -465,10 +667,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -478,52 +679,135 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_02_01.models.DeletedShare + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_02_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -533,7 +817,8 @@ async def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -541,10 +826,9 @@ async def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -554,5 +838,4 @@ async def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_operations.py index 6d1edb2fa4ad..5e99f77a5e31 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,52 +59,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -94,78 +113,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy + :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: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -173,71 +274,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -245,10 +346,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -258,5 +358,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_operations.py index afa29741c911..789ec116faca 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_object_replication_policies_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._object_replication_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._object_replication_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ObjectReplicationPoliciesOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,56 +152,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -189,10 +205,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -200,68 +215,150 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy 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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -269,10 +366,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -280,60 +376,57 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -341,10 +434,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -355,5 +447,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_operations.py index f8ebf1952a2e..5e38146a3469 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_endpoint_connections_operations.py index 8f5031dc10e5..5ae1414ee15d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request, build_get_request, build_list_request, build_put_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +151,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +204,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +214,148 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection 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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +363,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +373,57 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +431,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,5 +444,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_link_resources_operations.py index 1a8e80feae68..0027c2a2059c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,46 +55,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -88,22 +100,20 @@ async def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_operations.py index acff7b617a65..2c1e66002f56 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._queue_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueOperations: """ .. warning:: @@ -43,60 +64,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue 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 - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -104,79 +210,163 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -184,72 +374,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -257,72 +443,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -330,10 +512,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -343,8 +524,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -354,15 +534,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListQueueResource]: + ) -> AsyncIterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -371,32 +551,36 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) + :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -404,17 +588,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -431,10 +615,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -444,8 +626,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_operations.py index 3b2d5f4b4e60..b5853403bfa4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_queue_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._queue_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +102,163 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum31], parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :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: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum31], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum31], + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties 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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +266,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum31], **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +334,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_operations.py index 648b1bd6c765..5e917dcb59f9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) + :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +95,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +133,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_operations.py index 1cf6dc6bef43..8ad9f2ebc933 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,31 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_restore_blob_ranges_request_initial, build_revoke_user_delegation_keys_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_restore_blob_ranges_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +75,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2021_02_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2021_02_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCheckNameAvailabilityParameters 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 - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +174,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +238,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +249,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +274,17 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCreateParameters + :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 @@ -203,20 +297,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCreateParameters 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. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +398,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +473,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,15 +485,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -333,40 +500,43 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,32 +544,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -412,32 +582,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -446,7 +701,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -454,58 +710,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -513,13 +767,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -536,10 +794,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,49 +805,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -599,14 +854,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -623,10 +881,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -636,57 +892,53 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -694,65 +946,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_02_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -761,7 +1086,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -769,63 +1095,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -834,7 +1233,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -842,63 +1242,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -907,7 +1378,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -915,50 +1387,47 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -966,10 +1435,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -979,26 +1447,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1010,85 +1472,90 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1096,10 +1563,9 @@ async def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1107,38 +1573,81 @@ async def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - @distributed_trace_async + @overload async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1151,20 +1660,55 @@ async def begin_restore_blob_ranges( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobRestoreParameters 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. + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1172,79 +1716,76 @@ async def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1252,10 +1793,9 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1265,5 +1805,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_operations.py index f72f353d9069..fb4c3eccbe67 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._table_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableOperations: """ .. warning:: @@ -43,52 +64,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -96,71 +114,67 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -168,71 +182,65 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,71 +248,67 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -312,10 +316,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -325,50 +328,47 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -376,15 +376,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -401,10 +403,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -414,8 +414,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_operations.py index 162cbd802b30..9da09bca8a35 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_table_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._table_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,80 +102,163 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum31], parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :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: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum31], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum31], + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties 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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +266,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum31], **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +334,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_operations.py index 260e91f4432d..b2d14620a9d3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,42 +57,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_02_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -85,14 +98,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -109,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -122,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/__init__.py index 82c172aa1eb5..f40f69fa2da8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/__init__.py @@ -138,252 +138,252 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountStatus, - BlobInventoryPolicyName, - BlobRestoreProgressStatus, - Bypass, - CorsRuleAllowedMethodsItem, - CreatedByType, - DefaultAction, - DirectoryServiceOptions, - EnabledProtocols, - EncryptionScopeSource, - EncryptionScopeState, - ExpirationAction, - ExtendedLocationTypes, - GeoReplicationStatus, - HttpProtocol, - IdentityType, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - InventoryRuleType, - KeyPermission, - KeySource, - KeyType, - Kind, - LargeFileSharesState, - LeaseContainerRequestAction, - LeaseDuration, - LeaseState, - LeaseStatus, - ListContainersInclude, - ListSharesExpand, - ManagementPolicyName, - MinimumTlsVersion, - Name, - Permissions, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisioningState, - PublicAccess, - PutSharesExpand, - Reason, - ReasonCode, - RootSquashType, - RoutingChoice, - RuleType, - Services, - ShareAccessTier, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - StorageAccountExpand, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import BlobInventoryPolicyName +from ._storage_management_client_enums import BlobRestoreProgressStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CorsRuleAllowedMethodsItem +from ._storage_management_client_enums import CreatedByType +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import EnabledProtocols +from ._storage_management_client_enums import EncryptionScopeSource +from ._storage_management_client_enums import EncryptionScopeState +from ._storage_management_client_enums import Enum31 +from ._storage_management_client_enums import ExpirationAction +from ._storage_management_client_enums import ExtendedLocationTypes +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import IdentityType +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import InventoryRuleType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import KeyType +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ListContainersInclude +from ._storage_management_client_enums import ListSharesExpand +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Name +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._storage_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import PutSharesExpand +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RootSquashType +from ._storage_management_client_enums import RoutingChoice +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import ShareAccessTier +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import StorageAccountExpand +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccountSasParameters', - 'ActiveDirectoryProperties', - 'AzureEntityResource', - 'AzureFilesIdentityBasedAuthentication', - 'BlobContainer', - 'BlobInventoryPolicy', - 'BlobInventoryPolicyDefinition', - 'BlobInventoryPolicyFilter', - 'BlobInventoryPolicyRule', - 'BlobInventoryPolicySchema', - 'BlobRestoreParameters', - 'BlobRestoreRange', - 'BlobRestoreStatus', - 'BlobServiceItems', - 'BlobServiceProperties', - 'ChangeFeed', - 'CheckNameAvailabilityResult', - 'CloudErrorBody', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DateAfterCreation', - 'DateAfterModification', - 'DeleteRetentionPolicy', - 'DeletedAccount', - 'DeletedAccountListResult', - 'DeletedShare', - 'Dimension', - 'Encryption', - 'EncryptionIdentity', - 'EncryptionScope', - 'EncryptionScopeKeyVaultProperties', - 'EncryptionScopeListResult', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'ErrorResponse', - 'ErrorResponseBody', - 'ExtendedLocation', - 'FileServiceItems', - 'FileServiceProperties', - 'FileShare', - 'FileShareItem', - 'FileShareItems', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'KeyCreationTime', - 'KeyPolicy', - 'KeyVaultProperties', - 'LastAccessTimeTrackingPolicy', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListBlobInventoryPolicy', - 'ListContainerItem', - 'ListContainerItems', - 'ListQueue', - 'ListQueueResource', - 'ListQueueServices', - 'ListServiceSasResponse', - 'ListTableResource', - 'ListTableServices', - 'ManagementPolicy', - 'ManagementPolicyAction', - 'ManagementPolicyBaseBlob', - 'ManagementPolicyDefinition', - 'ManagementPolicyFilter', - 'ManagementPolicyRule', - 'ManagementPolicySchema', - 'ManagementPolicySnapShot', - 'ManagementPolicyVersion', - 'MetricSpecification', - 'Multichannel', - 'NetworkRuleSet', - 'ObjectReplicationPolicies', - 'ObjectReplicationPolicy', - 'ObjectReplicationPolicyFilter', - 'ObjectReplicationPolicyRule', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProtocolSettings', - 'ProxyResource', - 'QueueServiceProperties', - 'Resource', - 'ResourceAccessRule', - 'RestorePolicyProperties', - 'Restriction', - 'RoutingPreference', - 'SKUCapability', - 'SasPolicy', - 'ServiceSasParameters', - 'ServiceSpecification', - 'Sku', - 'SkuInformation', - 'SmbSetting', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountInternetEndpoints', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountMicrosoftEndpoints', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageQueue', - 'StorageSkuListResult', - 'SystemData', - 'Table', - 'TableServiceProperties', - 'TagFilter', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'UserAssignedIdentity', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'BlobInventoryPolicyName', - 'BlobRestoreProgressStatus', - 'Bypass', - 'CorsRuleAllowedMethodsItem', - 'CreatedByType', - 'DefaultAction', - 'DirectoryServiceOptions', - 'EnabledProtocols', - 'EncryptionScopeSource', - 'EncryptionScopeState', - 'ExpirationAction', - 'ExtendedLocationTypes', - 'GeoReplicationStatus', - 'HttpProtocol', - 'IdentityType', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'InventoryRuleType', - 'KeyPermission', - 'KeySource', - 'KeyType', - 'Kind', - 'LargeFileSharesState', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseState', - 'LeaseStatus', - 'ListContainersInclude', - 'ListSharesExpand', - 'ManagementPolicyName', - 'MinimumTlsVersion', - 'Name', - 'Permissions', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'ProvisioningState', - 'PublicAccess', - 'PutSharesExpand', - 'Reason', - 'ReasonCode', - 'RootSquashType', - 'RoutingChoice', - 'RuleType', - 'Services', - 'ShareAccessTier', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'StorageAccountExpand', - 'UsageUnit', + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobInventoryPolicy", + "BlobInventoryPolicyDefinition", + "BlobInventoryPolicyFilter", + "BlobInventoryPolicyRule", + "BlobInventoryPolicySchema", + "BlobRestoreParameters", + "BlobRestoreRange", + "BlobRestoreStatus", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorBody", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "DeletedAccount", + "DeletedAccountListResult", + "DeletedShare", + "Dimension", + "Encryption", + "EncryptionIdentity", + "EncryptionScope", + "EncryptionScopeKeyVaultProperties", + "EncryptionScopeListResult", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ErrorResponse", + "ErrorResponseBody", + "ExtendedLocation", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "KeyCreationTime", + "KeyPolicy", + "KeyVaultProperties", + "LastAccessTimeTrackingPolicy", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListBlobInventoryPolicy", + "ListContainerItem", + "ListContainerItems", + "ListQueue", + "ListQueueResource", + "ListQueueServices", + "ListServiceSasResponse", + "ListTableResource", + "ListTableServices", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "ManagementPolicyVersion", + "MetricSpecification", + "Multichannel", + "NetworkRuleSet", + "ObjectReplicationPolicies", + "ObjectReplicationPolicy", + "ObjectReplicationPolicyFilter", + "ObjectReplicationPolicyRule", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProtocolSettings", + "ProxyResource", + "QueueServiceProperties", + "Resource", + "ResourceAccessRule", + "RestorePolicyProperties", + "Restriction", + "RoutingPreference", + "SKUCapability", + "SasPolicy", + "ServiceSasParameters", + "ServiceSpecification", + "Sku", + "SkuInformation", + "SmbSetting", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountInternetEndpoints", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountMicrosoftEndpoints", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageQueue", + "StorageSkuListResult", + "SystemData", + "Table", + "TableServiceProperties", + "TagFilter", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "UserAssignedIdentity", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "BlobInventoryPolicyName", + "BlobRestoreProgressStatus", + "Bypass", + "CorsRuleAllowedMethodsItem", + "CreatedByType", + "DefaultAction", + "DirectoryServiceOptions", + "EnabledProtocols", + "EncryptionScopeSource", + "EncryptionScopeState", + "Enum31", + "ExpirationAction", + "ExtendedLocationTypes", + "GeoReplicationStatus", + "HttpProtocol", + "IdentityType", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "InventoryRuleType", + "KeyPermission", + "KeySource", + "KeyType", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseState", + "LeaseStatus", + "ListContainersInclude", + "ListSharesExpand", + "ManagementPolicyName", + "MinimumTlsVersion", + "Name", + "Permissions", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicAccess", + "PutSharesExpand", + "Reason", + "ReasonCode", + "RootSquashType", + "RoutingChoice", + "RuleType", + "Services", + "ShareAccessTier", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "StorageAccountExpand", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py index ab0b5c75d766..d9af17ad5027 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,64 +8,69 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2021_02_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_02_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_02_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_02_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -81,33 +87,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2021_02_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_02_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_02_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_02_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -118,42 +125,42 @@ def __init__( self.key_to_sign = key_to_sign -class ActiveDirectoryProperties(msrest.serialization.Model): +class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). All required parameters must be populated in order to send to Azure. - :ivar domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :vartype domain_name: str - :ivar net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. Required. :vartype net_bios_domain_name: str - :ivar forest_name: Required. Specifies the Active Directory forest to get. + :ivar forest_name: Specifies the Active Directory forest to get. Required. :vartype forest_name: str - :ivar domain_guid: Required. Specifies the domain GUID. + :ivar domain_guid: Specifies the domain GUID. Required. :vartype domain_guid: str - :ivar domain_sid: Required. Specifies the security identifier (SID). + :ivar domain_sid: Specifies the security identifier (SID). Required. :vartype domain_sid: str - :ivar azure_storage_sid: Required. Specifies the security identifier (SID) for Azure Storage. + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. Required. :vartype azure_storage_sid: str """ _validation = { - 'domain_name': {'required': True}, - 'net_bios_domain_name': {'required': True}, - 'forest_name': {'required': True}, - 'domain_guid': {'required': True}, - 'domain_sid': {'required': True}, - 'azure_storage_sid': {'required': True}, + "domain_name": {"required": True}, + "net_bios_domain_name": {"required": True}, + "forest_name": {"required": True}, + "domain_guid": {"required": True}, + "domain_sid": {"required": True}, + "azure_storage_sid": {"required": True}, } _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'net_bios_domain_name': {'key': 'netBiosDomainName', 'type': 'str'}, - 'forest_name': {'key': 'forestName', 'type': 'str'}, - 'domain_guid': {'key': 'domainGuid', 'type': 'str'}, - 'domain_sid': {'key': 'domainSid', 'type': 'str'}, - 'azure_storage_sid': {'key': 'azureStorageSid', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, } def __init__( @@ -168,22 +175,22 @@ def __init__( **kwargs ): """ - :keyword domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :paramtype domain_name: str - :keyword net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. Required. :paramtype net_bios_domain_name: str - :keyword forest_name: Required. Specifies the Active Directory forest to get. + :keyword forest_name: Specifies the Active Directory forest to get. Required. :paramtype forest_name: str - :keyword domain_guid: Required. Specifies the domain GUID. + :keyword domain_guid: Specifies the domain GUID. Required. :paramtype domain_guid: str - :keyword domain_sid: Required. Specifies the security identifier (SID). + :keyword domain_sid: Specifies the security identifier (SID). Required. :paramtype domain_sid: str - :keyword azure_storage_sid: Required. Specifies the security identifier (SID) for Azure - Storage. + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + Required. :paramtype azure_storage_sid: str """ - super(ActiveDirectoryProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.net_bios_domain_name = net_bios_domain_name self.forest_name = forest_name @@ -192,7 +199,7 @@ def __init__( self.azure_storage_sid = azure_storage_sid -class Resource(msrest.serialization.Model): +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. @@ -208,24 +215,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -249,36 +252,32 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): +class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Known values - are: "None", "AADDS", "AD". + :ivar directory_service_options: Indicates the directory service used. Required. Known values + are: "None", "AADDS", and "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_02_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -287,12 +286,12 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): """ _validation = { - 'directory_service_options': {'required': True}, + "directory_service_options": {"required": True}, } _attribute_map = { - 'directory_service_options': {'key': 'directoryServiceOptions', 'type': 'str'}, - 'active_directory_properties': {'key': 'activeDirectoryProperties', 'type': 'ActiveDirectoryProperties'}, + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, } def __init__( @@ -303,20 +302,20 @@ def __init__( **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Known - values are: "None", "AADDS", "AD". + :keyword directory_service_options: Indicates the directory service used. Required. Known + values are: "None", "AADDS", and "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_02_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. :paramtype active_directory_properties: ~azure.mgmt.storage.v2021_02_01.models.ActiveDirectoryProperties """ - super(AzureFilesIdentityBasedAuthentication, self).__init__(**kwargs) + super().__init__(**kwargs) self.directory_service_options = directory_service_options self.active_directory_properties = active_directory_properties -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -346,17 +345,18 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_02_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -377,45 +377,45 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -435,12 +435,12 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_02_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -481,79 +481,69 @@ class BlobInventoryPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified_time": {"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'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'BlobInventoryPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "BlobInventoryPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.BlobInventoryPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs): """ :keyword policy: The storage account blob inventory policy object. It is composed of policy rules. :paramtype policy: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicySchema """ - super(BlobInventoryPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.last_modified_time = None self.policy = policy -class BlobInventoryPolicyDefinition(msrest.serialization.Model): +class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. Each definition consists of a set of filters. All required parameters must be populated in order to send to Azure. - :ivar filters: Required. An object that defines the filter set. + :ivar filters: An object that defines the filter set. Required. :vartype filters: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyFilter """ _validation = { - 'filters': {'required': True}, + "filters": {"required": True}, } _attribute_map = { - 'filters': {'key': 'filters', 'type': 'BlobInventoryPolicyFilter'}, + "filters": {"key": "filters", "type": "BlobInventoryPolicyFilter"}, } - def __init__( - self, - *, - filters: "_models.BlobInventoryPolicyFilter", - **kwargs - ): + def __init__(self, *, filters: "_models.BlobInventoryPolicyFilter", **kwargs): """ - :keyword filters: Required. An object that defines the filter set. + :keyword filters: An object that defines the filter set. Required. :paramtype filters: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyFilter """ - super(BlobInventoryPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.filters = filters -class BlobInventoryPolicyFilter(msrest.serialization.Model): +class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for blob prefixes to be matched. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Valid values include blockBlob, - appendBlob, pageBlob. Hns accounts does not support pageBlobs. + :ivar blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. Required. :vartype blob_types: list[str] :ivar include_blob_versions: Includes blob versions in blob inventory when value set to true. :vartype include_blob_versions: bool @@ -562,14 +552,14 @@ class BlobInventoryPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'include_blob_versions': {'key': 'includeBlobVersions', 'type': 'bool'}, - 'include_snapshots': {'key': 'includeSnapshots', 'type': 'bool'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "include_blob_versions": {"key": "includeBlobVersions", "type": "bool"}, + "include_snapshots": {"key": "includeSnapshots", "type": "bool"}, } def __init__( @@ -584,8 +574,8 @@ def __init__( """ :keyword prefix_match: An array of strings for blob prefixes to be matched. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Valid values include - blockBlob, appendBlob, pageBlob. Hns accounts does not support pageBlobs. + :keyword blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. Required. :paramtype blob_types: list[str] :keyword include_blob_versions: Includes blob versions in blob inventory when value set to true. @@ -593,91 +583,84 @@ def __init__( :keyword include_snapshots: Includes blob snapshots in blob inventory when value set to true. :paramtype include_snapshots: bool """ - super(BlobInventoryPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.include_blob_versions = include_blob_versions self.include_snapshots = include_snapshots -class BlobInventoryPolicyRule(msrest.serialization.Model): +class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Rule is enabled when set to true. + :ivar enabled: Rule is enabled when set to true. Required. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar definition: Required. An object that defines the blob inventory policy rule. + :ivar definition: An object that defines the blob inventory policy rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyDefinition """ _validation = { - 'enabled': {'required': True}, - 'name': {'required': True}, - 'definition': {'required': True}, + "enabled": {"required": True}, + "name": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'BlobInventoryPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "definition": {"key": "definition", "type": "BlobInventoryPolicyDefinition"}, } - def __init__( - self, - *, - enabled: bool, - name: str, - definition: "_models.BlobInventoryPolicyDefinition", - **kwargs - ): + def __init__(self, *, enabled: bool, name: str, definition: "_models.BlobInventoryPolicyDefinition", **kwargs): """ - :keyword enabled: Required. Rule is enabled when set to true. + :keyword enabled: Rule is enabled when set to true. Required. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword definition: Required. An object that defines the blob inventory policy rule. + :keyword definition: An object that defines the blob inventory policy rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyDefinition """ - super(BlobInventoryPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.definition = definition -class BlobInventoryPolicySchema(msrest.serialization.Model): +class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Policy is enabled if set to true. + :ivar enabled: Policy is enabled if set to true. Required. :vartype enabled: bool - :ivar destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :ivar destination: Container name where blob inventory files are stored. Must be pre-created. + Required. :vartype destination: str - :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". + :ivar type: The valid value is Inventory. Required. "Inventory" :vartype type: str or ~azure.mgmt.storage.v2021_02_01.models.InventoryRuleType - :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :ivar rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :vartype rules: list[~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyRule] """ _validation = { - 'enabled': {'required': True}, - 'destination': {'required': True}, - 'type': {'required': True}, - 'rules': {'required': True}, + "enabled": {"required": True}, + "destination": {"required": True}, + "type": {"required": True}, + "rules": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'destination': {'key': 'destination', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rules': {'key': 'rules', 'type': '[BlobInventoryPolicyRule]'}, + "enabled": {"key": "enabled", "type": "bool"}, + "destination": {"key": "destination", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rules": {"key": "rules", "type": "[BlobInventoryPolicyRule]"}, } def __init__( @@ -690,103 +673,91 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Policy is enabled if set to true. + :keyword enabled: Policy is enabled if set to true. Required. :paramtype enabled: bool - :keyword destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :keyword destination: Container name where blob inventory files are stored. Must be + pre-created. Required. :paramtype destination: str - :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". + :keyword type: The valid value is Inventory. Required. "Inventory" :paramtype type: str or ~azure.mgmt.storage.v2021_02_01.models.InventoryRuleType - :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :keyword rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :paramtype rules: list[~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyRule] """ - super(BlobInventoryPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.destination = destination self.type = type self.rules = rules -class BlobRestoreParameters(msrest.serialization.Model): +class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. All required parameters must be populated in order to send to Azure. - :ivar time_to_restore: Required. Restore blob to the specified time. + :ivar time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime - :ivar blob_ranges: Required. Blob ranges to restore. + :ivar blob_ranges: Blob ranges to restore. Required. :vartype blob_ranges: list[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreRange] """ _validation = { - 'time_to_restore': {'required': True}, - 'blob_ranges': {'required': True}, + "time_to_restore": {"required": True}, + "blob_ranges": {"required": True}, } _attribute_map = { - 'time_to_restore': {'key': 'timeToRestore', 'type': 'iso-8601'}, - 'blob_ranges': {'key': 'blobRanges', 'type': '[BlobRestoreRange]'}, + "time_to_restore": {"key": "timeToRestore", "type": "iso-8601"}, + "blob_ranges": {"key": "blobRanges", "type": "[BlobRestoreRange]"}, } - def __init__( - self, - *, - time_to_restore: datetime.datetime, - blob_ranges: List["_models.BlobRestoreRange"], - **kwargs - ): + def __init__(self, *, time_to_restore: datetime.datetime, blob_ranges: List["_models.BlobRestoreRange"], **kwargs): """ - :keyword time_to_restore: Required. Restore blob to the specified time. + :keyword time_to_restore: Restore blob to the specified time. Required. :paramtype time_to_restore: ~datetime.datetime - :keyword blob_ranges: Required. Blob ranges to restore. + :keyword blob_ranges: Blob ranges to restore. Required. :paramtype blob_ranges: list[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreRange] """ - super(BlobRestoreParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_to_restore = time_to_restore self.blob_ranges = blob_ranges -class BlobRestoreRange(msrest.serialization.Model): +class BlobRestoreRange(_serialization.Model): """Blob range. All required parameters must be populated in order to send to Azure. - :ivar start_range: Required. Blob start range. This is inclusive. Empty means account start. + :ivar start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str - :ivar end_range: Required. Blob end range. This is exclusive. Empty means account end. + :ivar end_range: Blob end range. This is exclusive. Empty means account end. Required. :vartype end_range: str """ _validation = { - 'start_range': {'required': True}, - 'end_range': {'required': True}, + "start_range": {"required": True}, + "end_range": {"required": True}, } _attribute_map = { - 'start_range': {'key': 'startRange', 'type': 'str'}, - 'end_range': {'key': 'endRange', 'type': 'str'}, + "start_range": {"key": "startRange", "type": "str"}, + "end_range": {"key": "endRange", "type": "str"}, } - def __init__( - self, - *, - start_range: str, - end_range: str, - **kwargs - ): + def __init__(self, *, start_range: str, end_range: str, **kwargs): """ - :keyword start_range: Required. Blob start range. This is inclusive. Empty means account start. + :keyword start_range: Blob start range. This is inclusive. Empty means account start. Required. :paramtype start_range: str - :keyword end_range: Required. Blob end range. This is exclusive. Empty means account end. + :keyword end_range: Blob end range. This is exclusive. Empty means account end. Required. :paramtype end_range: str """ - super(BlobRestoreRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_range = start_range self.end_range = end_range -class BlobRestoreStatus(msrest.serialization.Model): +class BlobRestoreStatus(_serialization.Model): """Blob restore status. Variables are only populated by the server, and will be ignored when sending a request. @@ -794,7 +765,7 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", - "Complete", "Failed". + "Complete", and "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_02_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -805,33 +776,29 @@ class BlobRestoreStatus(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'restore_id': {'readonly': True}, - 'parameters': {'readonly': True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "restore_id": {"readonly": True}, + "parameters": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'restore_id': {'key': 'restoreId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'BlobRestoreParameters'}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "restore_id": {"key": "restoreId", "type": "str"}, + "parameters": {"key": "parameters", "type": "BlobRestoreParameters"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobRestoreStatus, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.failure_reason = None self.restore_id = None self.parameters = None -class BlobServiceItems(msrest.serialization.Model): +class BlobServiceItems(_serialization.Model): """BlobServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -841,24 +808,20 @@ class BlobServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobServiceProperties]'}, + "value": {"key": "value", "type": "[BlobServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class BlobServiceProperties(Resource): +class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attributes """The properties of a storage account’s Blob service. Variables are only populated by the server, and will be ignored when sending a request. @@ -901,26 +864,32 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'is_versioning_enabled': {'key': 'properties.isVersioningEnabled', 'type': 'bool'}, - 'automatic_snapshot_policy_enabled': {'key': 'properties.automaticSnapshotPolicyEnabled', 'type': 'bool'}, - 'change_feed': {'key': 'properties.changeFeed', 'type': 'ChangeFeed'}, - 'restore_policy': {'key': 'properties.restorePolicy', 'type': 'RestorePolicyProperties'}, - 'container_delete_retention_policy': {'key': 'properties.containerDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'last_access_time_tracking_policy': {'key': 'properties.lastAccessTimeTrackingPolicy', 'type': 'LastAccessTimeTrackingPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "is_versioning_enabled": {"key": "properties.isVersioningEnabled", "type": "bool"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, + "restore_policy": {"key": "properties.restorePolicy", "type": "RestorePolicyProperties"}, + "container_delete_retention_policy": { + "key": "properties.containerDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "last_access_time_tracking_policy": { + "key": "properties.lastAccessTimeTrackingPolicy", + "type": "LastAccessTimeTrackingPolicy", + }, } def __init__( @@ -967,7 +936,7 @@ def __init__( :paramtype last_access_time_tracking_policy: ~azure.mgmt.storage.v2021_02_01.models.LastAccessTimeTrackingPolicy """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.default_service_version = default_service_version @@ -980,7 +949,7 @@ def __init__( self.last_access_time_tracking_policy = last_access_time_tracking_policy -class ChangeFeed(msrest.serialization.Model): +class ChangeFeed(_serialization.Model): """The blob service properties for change feed events. :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. @@ -992,21 +961,15 @@ class ChangeFeed(msrest.serialization.Model): """ _validation = { - 'retention_in_days': {'maximum': 146000, 'minimum': 1}, + "retention_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_in_days': {'key': 'retentionInDays', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_in_days": {"key": "retentionInDays", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - retention_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, retention_in_days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. :paramtype enabled: bool @@ -1015,12 +978,12 @@ def __init__( retention of the change feed. :paramtype retention_in_days: int """ - super(ChangeFeed, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.retention_in_days = retention_in_days -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1030,7 +993,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_02_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1038,30 +1001,26 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1078,10 +1037,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -1106,50 +1065,50 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2021_02_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2021_02_01.models.CorsRuleAllowedMethodsItem] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -1163,24 +1122,24 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2021_02_01.models.CorsRuleAllowedMethodsItem] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -1188,7 +1147,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -1197,31 +1156,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2021_02_01.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -1229,68 +1183,57 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DateAfterCreation(msrest.serialization.Model): +class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. All required parameters must be populated in order to send to Azure. - :ivar days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :vartype days_after_creation_greater_than: float """ _validation = { - 'days_after_creation_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, } - def __init__( - self, - *, - days_after_creation_greater_than: float, - **kwargs - ): + def __init__(self, *, days_after_creation_greater_than: float, **kwargs): """ - :keyword days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :paramtype days_after_creation_greater_than: float """ - super(DateAfterCreation, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_creation_greater_than = days_after_creation_greater_than -class DateAfterModification(msrest.serialization.Model): +class DateAfterModification(_serialization.Model): """Object to define the number of days after object last modification Or last access. Properties daysAfterModificationGreaterThan and daysAfterLastAccessTimeGreaterThan are mutually exclusive. :ivar days_after_modification_greater_than: Value indicating the age in days after last @@ -1303,13 +1246,13 @@ class DateAfterModification(msrest.serialization.Model): """ _validation = { - 'days_after_modification_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_last_access_time_greater_than': {'minimum': 0, 'multiple': 1}, + "days_after_modification_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_access_time_greater_than": {"minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'float'}, - 'days_after_last_access_time_greater_than': {'key': 'daysAfterLastAccessTimeGreaterThan', 'type': 'float'}, + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, + "days_after_last_access_time_greater_than": {"key": "daysAfterLastAccessTimeGreaterThan", "type": "float"}, } def __init__( @@ -1328,7 +1271,7 @@ def __init__( policy. :paramtype days_after_last_access_time_greater_than: float """ - super(DateAfterModification, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_modification_greater_than = days_after_modification_greater_than self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than @@ -1349,24 +1292,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class DeletedAccount(ProxyResource): @@ -1396,34 +1335,30 @@ class DeletedAccount(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'storage_account_resource_id': {'readonly': True}, - 'location': {'readonly': True}, - 'restore_reference': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'deletion_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'location': {'key': 'properties.location', 'type': 'str'}, - 'restore_reference': {'key': 'properties.restoreReference', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, - 'deletion_time': {'key': 'properties.deletionTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccount, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "storage_account_resource_id": {"readonly": True}, + "location": {"readonly": True}, + "restore_reference": {"readonly": True}, + "creation_time": {"readonly": True}, + "deletion_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "location": {"key": "properties.location", "type": "str"}, + "restore_reference": {"key": "properties.restoreReference", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "str"}, + "deletion_time": {"key": "properties.deletionTime", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_account_resource_id = None self.location = None self.restore_reference = None @@ -1431,7 +1366,7 @@ def __init__( self.deletion_time = None -class DeletedAccountListResult(msrest.serialization.Model): +class DeletedAccountListResult(_serialization.Model): """The response from the List Deleted Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1444,70 +1379,60 @@ class DeletedAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeletedAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeletedAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DeletedShare(msrest.serialization.Model): +class DeletedShare(_serialization.Model): """The deleted share to be restored. All required parameters must be populated in order to send to Azure. - :ivar deleted_share_name: Required. Required. Identify the name of the deleted share that will - be restored. + :ivar deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :vartype deleted_share_name: str - :ivar deleted_share_version: Required. Required. Identify the version of the deleted share that - will be restored. + :ivar deleted_share_version: Required. Identify the version of the deleted share that will be + restored. Required. :vartype deleted_share_version: str """ _validation = { - 'deleted_share_name': {'required': True}, - 'deleted_share_version': {'required': True}, + "deleted_share_name": {"required": True}, + "deleted_share_version": {"required": True}, } _attribute_map = { - 'deleted_share_name': {'key': 'deletedShareName', 'type': 'str'}, - 'deleted_share_version': {'key': 'deletedShareVersion', 'type': 'str'}, + "deleted_share_name": {"key": "deletedShareName", "type": "str"}, + "deleted_share_version": {"key": "deletedShareVersion", "type": "str"}, } - def __init__( - self, - *, - deleted_share_name: str, - deleted_share_version: str, - **kwargs - ): + def __init__(self, *, deleted_share_name: str, deleted_share_version: str, **kwargs): """ - :keyword deleted_share_name: Required. Required. Identify the name of the deleted share that - will be restored. + :keyword deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :paramtype deleted_share_name: str - :keyword deleted_share_version: Required. Required. Identify the version of the deleted share - that will be restored. + :keyword deleted_share_version: Required. Identify the version of the deleted share that will + be restored. Required. :paramtype deleted_share_version: str """ - super(DeletedShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.deleted_share_name = deleted_share_name self.deleted_share_version = deleted_share_version -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. @@ -1518,21 +1443,15 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled. :paramtype enabled: bool @@ -1540,12 +1459,12 @@ def __init__( minimum specified value can be 1 and the maximum value can be 365. :paramtype days: int """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -1555,38 +1474,32 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_02_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2021_02_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1598,15 +1511,15 @@ class Encryption(msrest.serialization.Model): """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, - 'encryption_identity': {'key': 'identity', 'type': 'EncryptionIdentity'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, + "encryption_identity": {"key": "identity", "type": "EncryptionIdentity"}, } def __init__( @@ -1622,9 +1535,9 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_02_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2021_02_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1634,7 +1547,7 @@ def __init__( :keyword encryption_identity: The identity to be used with service-side encryption at rest. :paramtype encryption_identity: ~azure.mgmt.storage.v2021_02_01.models.EncryptionIdentity """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption @@ -1642,7 +1555,7 @@ def __init__( self.encryption_identity = encryption_identity -class EncryptionIdentity(msrest.serialization.Model): +class EncryptionIdentity(_serialization.Model): """Encryption identity for the storage account. :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be @@ -1651,21 +1564,16 @@ class EncryptionIdentity(msrest.serialization.Model): """ _attribute_map = { - 'encryption_user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "encryption_user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - encryption_user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, encryption_user_assigned_identity: Optional[str] = None, **kwargs): """ :keyword encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be associated with server-side encryption on the storage account. :paramtype encryption_user_assigned_identity: str """ - super(EncryptionIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.encryption_user_assigned_identity = encryption_user_assigned_identity @@ -1683,11 +1591,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Known values are: "Enabled", "Disabled". + Disabled. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1704,23 +1612,23 @@ class EncryptionScope(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'EncryptionScopeKeyVaultProperties'}, - 'require_infrastructure_encryption': {'key': 'properties.requireInfrastructureEncryption', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "EncryptionScopeKeyVaultProperties"}, + "require_infrastructure_encryption": {"key": "properties.requireInfrastructureEncryption", "type": "bool"}, } def __init__( @@ -1734,11 +1642,11 @@ def __init__( ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Known values are: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -1748,7 +1656,7 @@ def __init__( applies a secondary layer of encryption with platform managed keys for data at rest. :paramtype require_infrastructure_encryption: bool """ - super(EncryptionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.state = state self.creation_time = None @@ -1757,7 +1665,7 @@ def __init__( self.require_infrastructure_encryption = require_infrastructure_encryption -class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): +class EncryptionScopeKeyVaultProperties(_serialization.Model): """The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. Variables are only populated by the server, and will be ignored when sending a request. @@ -1774,35 +1682,30 @@ class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_uri': {'key': 'keyUri', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_uri": {"key": "keyUri", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_uri: Optional[str] = None, **kwargs): """ :keyword key_uri: The object identifier for a key vault key object. When applied, the encryption scope will use the key referenced by the identifier to enable customer-managed key support on this encryption scope. :paramtype key_uri: str """ - super(EncryptionScopeKeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_uri = key_uri self.current_versioned_key_identifier = None self.last_key_rotation_timestamp = None -class EncryptionScopeListResult(msrest.serialization.Model): +class EncryptionScopeListResult(_serialization.Model): """List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. Variables are only populated by the server, and will be ignored when sending a request. @@ -1815,27 +1718,23 @@ class EncryptionScopeListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EncryptionScope]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EncryptionScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(EncryptionScopeListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -1849,26 +1748,22 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Known values are: "Service", "Account". + default service key is used. Known values are: "Service" and "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_02_01.models.KeyType """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'key_type': {'key': 'keyType', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "key_type": {"key": "keyType", "type": "str"}, } def __init__( - self, - *, - enabled: Optional[bool] = None, - key_type: Optional[Union[str, "_models.KeyType"]] = None, - **kwargs + self, *, enabled: Optional[bool] = None, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is @@ -1876,16 +1771,16 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Known values are: "Service", "Account". + that a default service key is used. Known values are: "Service" and "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_02_01.models.KeyType """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None self.key_type = key_type -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. :ivar blob: The encryption function of the blob storage service. @@ -1899,10 +1794,10 @@ class EncryptionServices(msrest.serialization.Model): """ _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -1924,14 +1819,14 @@ def __init__( :keyword queue: The encryption function of the queue storage service. :paramtype queue: ~azure.mgmt.storage.v2021_02_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = table self.queue = queue -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -1957,23 +1852,23 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, - 'microsoft_endpoints': {'key': 'microsoftEndpoints', 'type': 'StorageAccountMicrosoftEndpoints'}, - 'internet_endpoints': {'key': 'internetEndpoints', 'type': 'StorageAccountInternetEndpoints'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + "microsoft_endpoints": {"key": "microsoftEndpoints", "type": "StorageAccountMicrosoftEndpoints"}, + "internet_endpoints": {"key": "internetEndpoints", "type": "StorageAccountInternetEndpoints"}, } def __init__( @@ -1991,7 +1886,7 @@ def __init__( :paramtype internet_endpoints: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountInternetEndpoints """ - super(Endpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -2002,7 +1897,7 @@ def __init__( self.internet_endpoints = internet_endpoints -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the storage resource provider. :ivar error: Azure Storage Resource Provider error response body. @@ -2010,24 +1905,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure Storage Resource Provider error response body. :paramtype error: ~azure.mgmt.storage.v2021_02_01.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """Error response body contract. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -2039,17 +1929,11 @@ class ErrorResponseBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. @@ -2058,23 +1942,23 @@ def __init__( interface. :paramtype message: str """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ExtendedLocation(msrest.serialization.Model): +class ExtendedLocation(_serialization.Model): """The complex type of the extended location. :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Known values are: "EdgeZone". + :ivar type: The type of the extended location. "EdgeZone" :vartype type: str or ~azure.mgmt.storage.v2021_02_01.models.ExtendedLocationTypes """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -2087,15 +1971,15 @@ def __init__( """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Known values are: "EdgeZone". + :keyword type: The type of the extended location. "EdgeZone" :paramtype type: str or ~azure.mgmt.storage.v2021_02_01.models.ExtendedLocationTypes """ - super(ExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class FileServiceItems(msrest.serialization.Model): +class FileServiceItems(_serialization.Model): """FileServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -2105,20 +1989,16 @@ class FileServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileServiceProperties]'}, + "value": {"key": "value", "type": "[FileServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -2149,20 +2029,23 @@ class FileServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'share_delete_retention_policy': {'key': 'properties.shareDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'protocol_settings': {'key': 'properties.protocolSettings', 'type': 'ProtocolSettings'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "share_delete_retention_policy": { + "key": "properties.shareDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "protocol_settings": {"key": "properties.protocolSettings", "type": "ProtocolSettings"}, } def __init__( @@ -2184,14 +2067,14 @@ def __init__( :keyword protocol_settings: Protocol settings for file service. :paramtype protocol_settings: ~azure.mgmt.storage.v2021_02_01.models.ProtocolSettings """ - super(FileServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.share_delete_retention_policy = share_delete_retention_policy self.protocol_settings = protocol_settings -class FileShare(AzureEntityResource): +class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the file share, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -2214,10 +2097,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_02_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_02_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2229,7 +2112,7 @@ class FileShare(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2237,48 +2120,48 @@ class FileShare(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long + :vartype share_usage_bytes: int :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares with expand param "snapshots". :vartype snapshot_time: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2298,17 +2181,17 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_02_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_02_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.ShareAccessTier """ - super(FileShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2325,7 +2208,7 @@ def __init__( self.snapshot_time = None -class FileShareItem(AzureEntityResource): +class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The file share properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -2348,10 +2231,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_02_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_02_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2363,7 +2246,7 @@ class FileShareItem(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2371,48 +2254,48 @@ class FileShareItem(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long + :vartype share_usage_bytes: int :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares with expand param "snapshots". :vartype snapshot_time: ~datetime.datetime """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2432,17 +2315,17 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_02_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_02_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.ShareAccessTier """ - super(FileShareItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2459,7 +2342,7 @@ def __init__( self.snapshot_time = None -class FileShareItems(msrest.serialization.Model): +class FileShareItems(_serialization.Model): """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. Variables are only populated by the server, and will be ignored when sending a request. @@ -2472,27 +2355,23 @@ class FileShareItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileShareItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileShareItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2501,7 +2380,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_02_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2514,30 +2393,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2548,8 +2423,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_02_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2559,16 +2434,16 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( @@ -2579,8 +2454,8 @@ def __init__( **kwargs ): """ - :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_02_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2588,7 +2463,7 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.storage.v2021_02_01.models.UserAssignedIdentity] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type @@ -2614,7 +2489,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2625,21 +2500,24 @@ class ImmutabilityPolicy(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -2660,13 +2538,13 @@ def __init__( ExtendImmutabilityPolicy API. :paramtype allow_protected_append_writes: bool """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None self.allow_protected_append_writes = allow_protected_append_writes -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2679,7 +2557,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2690,17 +2568,20 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -2721,7 +2602,7 @@ def __init__( ExtendImmutabilityPolicy API. :paramtype allow_protected_append_writes: bool """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days @@ -2729,49 +2610,41 @@ def __init__( self.allow_protected_append_writes = allow_protected_append_writes -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyCreationTime(msrest.serialization.Model): +class KeyCreationTime(_serialization.Model): """Storage account keys creation time. :ivar key1: @@ -2781,60 +2654,49 @@ class KeyCreationTime(msrest.serialization.Model): """ _attribute_map = { - 'key1': {'key': 'key1', 'type': 'iso-8601'}, - 'key2': {'key': 'key2', 'type': 'iso-8601'}, + "key1": {"key": "key1", "type": "iso-8601"}, + "key2": {"key": "key2", "type": "iso-8601"}, } - def __init__( - self, - *, - key1: Optional[datetime.datetime] = None, - key2: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, key1: Optional[datetime.datetime] = None, key2: Optional[datetime.datetime] = None, **kwargs): """ :keyword key1: :paramtype key1: ~datetime.datetime :keyword key2: :paramtype key2: ~datetime.datetime """ - super(KeyCreationTime, self).__init__(**kwargs) + super().__init__(**kwargs) self.key1 = key1 self.key2 = key2 -class KeyPolicy(msrest.serialization.Model): +class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar key_expiration_period_in_days: Required. The key expiration period in days. + :ivar key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int """ _validation = { - 'key_expiration_period_in_days': {'required': True}, + "key_expiration_period_in_days": {"required": True}, } _attribute_map = { - 'key_expiration_period_in_days': {'key': 'keyExpirationPeriodInDays', 'type': 'int'}, + "key_expiration_period_in_days": {"key": "keyExpirationPeriodInDays", "type": "int"}, } - def __init__( - self, - *, - key_expiration_period_in_days: int, - **kwargs - ): + def __init__(self, *, key_expiration_period_in_days: int, **kwargs): """ - :keyword key_expiration_period_in_days: Required. The key expiration period in days. + :keyword key_expiration_period_in_days: The key expiration period in days. Required. :paramtype key_expiration_period_in_days: int """ - super(KeyPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_expiration_period_in_days = key_expiration_period_in_days -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. Variables are only populated by the server, and will be ignored when sending a request. @@ -2853,16 +2715,16 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } def __init__( @@ -2881,7 +2743,7 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri @@ -2889,15 +2751,15 @@ def __init__( self.last_key_rotation_timestamp = None -class LastAccessTimeTrackingPolicy(msrest.serialization.Model): +class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. All required parameters must be populated in order to send to Azure. - :ivar enable: Required. When set to true last access time based tracking is enabled. + :ivar enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Known values are: "AccessTimeTracking". + read only. "AccessTimeTracking" :vartype name: str or ~azure.mgmt.storage.v2021_02_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2909,14 +2771,14 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): """ _validation = { - 'enable': {'required': True}, + "enable": {"required": True}, } _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tracking_granularity_in_days': {'key': 'trackingGranularityInDays', 'type': 'int'}, - 'blob_type': {'key': 'blobType', 'type': '[str]'}, + "enable": {"key": "enable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "tracking_granularity_in_days": {"key": "trackingGranularityInDays", "type": "int"}, + "blob_type": {"key": "blobType", "type": "[str]"}, } def __init__( @@ -2929,10 +2791,10 @@ def __init__( **kwargs ): """ - :keyword enable: Required. When set to true last access time based tracking is enabled. + :keyword enable: When set to true last access time based tracking is enabled. Required. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Known values are: "AccessTimeTracking". + currently read only. "AccessTimeTracking" :paramtype name: str or ~azure.mgmt.storage.v2021_02_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -2942,20 +2804,20 @@ def __init__( supported value. This field is currently read only. :paramtype blob_type: list[str] """ - super(LastAccessTimeTrackingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enable = enable self.name = name self.tracking_granularity_in_days = tracking_granularity_in_days self.blob_type = blob_type -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -2971,15 +2833,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -2993,8 +2855,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3008,7 +2870,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -3016,7 +2878,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -3027,17 +2889,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -3045,12 +2901,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3062,38 +2918,33 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, } - def __init__( - self, - *, - tags: List[str], - **kwargs - ): + def __init__(self, *, tags: List[str], **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3103,35 +2954,30 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2021_02_01.models.TagProperty] """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, } - def __init__( - self, - *, - tags: Optional[List["_models.TagProperty"]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[List["_models.TagProperty"]] = None, **kwargs): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2021_02_01.models.TagProperty] """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3141,24 +2987,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListBlobInventoryPolicy(msrest.serialization.Model): +class ListBlobInventoryPolicy(_serialization.Model): """List of blob inventory policies returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3168,24 +3010,20 @@ class ListBlobInventoryPolicy(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobInventoryPolicy]'}, + "value": {"key": "value", "type": "[BlobInventoryPolicy]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListBlobInventoryPolicy, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -3215,17 +3053,18 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_02_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_02_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3246,45 +3085,45 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, } def __init__( @@ -3304,12 +3143,12 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_02_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -3328,7 +3167,7 @@ def __init__( self.has_immutability_policy = None -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. Variables are only populated by the server, and will be ignored when sending a request. @@ -3341,22 +3180,18 @@ class ListContainerItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListContainerItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3379,33 +3214,28 @@ class ListQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(ListQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata -class ListQueueResource(msrest.serialization.Model): +class ListQueueResource(_serialization.Model): """Response schema. Contains list of queues returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3417,27 +3247,23 @@ class ListQueueResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListQueueServices(msrest.serialization.Model): +class ListQueueServices(_serialization.Model): """ListQueueServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -3447,24 +3273,20 @@ class ListQueueServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueServiceProperties]'}, + "value": {"key": "value", "type": "[QueueServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3474,24 +3296,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class ListTableResource(msrest.serialization.Model): +class ListTableResource(_serialization.Model): """Response schema. Contains list of tables returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3503,27 +3321,23 @@ class ListTableResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Table]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Table]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListTableServices(msrest.serialization.Model): +class ListTableServices(_serialization.Model): """ListTableServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -3533,20 +3347,16 @@ class ListTableServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TableServiceProperties]'}, + "value": {"key": "value", "type": "[TableServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -3571,37 +3381,32 @@ class ManagementPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.ManagementPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :paramtype policy: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicySchema """ - super(ManagementPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.policy = policy -class ManagementPolicyAction(msrest.serialization.Model): +class ManagementPolicyAction(_serialization.Model): """Actions are applied to the filtered blobs when the execution condition is met. :ivar base_blob: The management policy action for base blob. @@ -3613,9 +3418,9 @@ class ManagementPolicyAction(msrest.serialization.Model): """ _attribute_map = { - 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, - 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, - 'version': {'key': 'version', 'type': 'ManagementPolicyVersion'}, + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, + "version": {"key": "version", "type": "ManagementPolicyVersion"}, } def __init__( @@ -3634,13 +3439,13 @@ def __init__( :keyword version: The management policy action for version. :paramtype version: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyVersion """ - super(ManagementPolicyAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_blob = base_blob self.snapshot = snapshot self.version = version -class ManagementPolicyBaseBlob(msrest.serialization.Model): +class ManagementPolicyBaseBlob(_serialization.Model): """Management policy action for base blob. :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot @@ -3657,10 +3462,10 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, - 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, - 'enable_auto_tier_to_hot_from_cool': {'key': 'enableAutoTierToHotFromCool', 'type': 'bool'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, + "enable_auto_tier_to_hot_from_cool": {"key": "enableAutoTierToHotFromCool", "type": "bool"}, } def __init__( @@ -3686,31 +3491,31 @@ def __init__( tierToCool.daysAfterLastAccessTimeGreaterThan. :paramtype enable_auto_tier_to_hot_from_cool: bool """ - super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool -class ManagementPolicyDefinition(msrest.serialization.Model): +class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. All required parameters must be populated in order to send to Azure. - :ivar actions: Required. An object that defines the action set. + :ivar actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyAction :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyFilter """ _validation = { - 'actions': {'required': True}, + "actions": {"required": True}, } _attribute_map = { - 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, - 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, } def __init__( @@ -3721,25 +3526,25 @@ def __init__( **kwargs ): """ - :keyword actions: Required. An object that defines the action set. + :keyword actions: An object that defines the action set. Required. :paramtype actions: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyAction :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyFilter """ - super(ManagementPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.filters = filters -class ManagementPolicyFilter(msrest.serialization.Model): +class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :ivar blob_types: An array of predefined enum values. Currently blockBlob supports all tiering + and delete actions. Only delete actions are supported for appendBlob. Required. :vartype blob_types: list[str] :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. @@ -3747,13 +3552,13 @@ class ManagementPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'blob_index_match': {'key': 'blobIndexMatch', 'type': '[TagFilter]'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "blob_index_match": {"key": "blobIndexMatch", "type": "[TagFilter]"}, } def __init__( @@ -3767,46 +3572,46 @@ def __init__( """ :keyword prefix_match: An array of strings for prefixes to be match. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :keyword blob_types: An array of predefined enum values. Currently blockBlob supports all + tiering and delete actions. Only delete actions are supported for appendBlob. Required. :paramtype blob_types: list[str] :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. :paramtype blob_index_match: list[~azure.mgmt.storage.v2021_02_01.models.TagFilter] """ - super(ManagementPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.blob_index_match = blob_index_match -class ManagementPolicyRule(msrest.serialization.Model): +class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. :ivar enabled: Rule is enabled if set to true. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" :vartype type: str or ~azure.mgmt.storage.v2021_02_01.models.RuleType - :ivar definition: Required. An object that defines the Lifecycle rule. + :ivar definition: An object that defines the Lifecycle rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyDefinition """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - 'definition': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, } def __init__( @@ -3821,55 +3626,52 @@ def __init__( """ :keyword enabled: Rule is enabled if set to true. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" :paramtype type: str or ~azure.mgmt.storage.v2021_02_01.models.RuleType - :keyword definition: Required. An object that defines the Lifecycle rule. + :keyword definition: An object that defines the Lifecycle rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyDefinition """ - super(ManagementPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.type = type self.definition = definition -class ManagementPolicySchema(msrest.serialization.Model): +class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. All required parameters must be populated in order to send to Azure. - :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :vartype rules: list[~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyRule] """ _validation = { - 'rules': {'required': True}, + "rules": {"required": True}, } _attribute_map = { - 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, } - def __init__( - self, - *, - rules: List["_models.ManagementPolicyRule"], - **kwargs - ): + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): """ - :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :paramtype rules: list[~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyRule] """ - super(ManagementPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.rules = rules -class ManagementPolicySnapShot(msrest.serialization.Model): +class ManagementPolicySnapShot(_serialization.Model): """Management policy action for snapshot. :ivar tier_to_cool: The function to tier blob snapshot to cool storage. Support blob snapshot @@ -3883,9 +3685,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -3906,13 +3708,13 @@ def __init__( :keyword delete: The function to delete the blob snapshot. :paramtype delete: ~azure.mgmt.storage.v2021_02_01.models.DateAfterCreation """ - super(ManagementPolicySnapShot, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class ManagementPolicyVersion(msrest.serialization.Model): +class ManagementPolicyVersion(_serialization.Model): """Management policy action for blob version. :ivar tier_to_cool: The function to tier blob version to cool storage. Support blob version @@ -3926,9 +3728,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -3949,13 +3751,13 @@ def __init__( :keyword delete: The function to delete the blob version. :paramtype delete: ~azure.mgmt.storage.v2021_02_01.models.DateAfterCreation """ - super(ManagementPolicyVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -3979,15 +3781,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -4024,7 +3826,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -4036,7 +3838,7 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class Multichannel(msrest.serialization.Model): +class Multichannel(_serialization.Model): """Multichannel setting. Applies to Premium FileStorage only. :ivar enabled: Indicates whether multichannel is enabled. @@ -4044,32 +3846,27 @@ class Multichannel(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Indicates whether multichannel is enabled. :paramtype enabled: bool """ - super(Multichannel, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_02_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_02_01.models.ResourceAccessRule] @@ -4077,28 +3874,28 @@ class NetworkRuleSet(msrest.serialization.Model): :vartype virtual_network_rules: list[~azure.mgmt.storage.v2021_02_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_02_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2021_02_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'resource_access_rules': {'key': 'resourceAccessRules', 'type': '[ResourceAccessRule]'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "resource_access_rules": {"key": "resourceAccessRules", "type": "[ResourceAccessRule]"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, @@ -4108,7 +3905,7 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_02_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4118,11 +3915,11 @@ def __init__( list[~azure.mgmt.storage.v2021_02_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_02_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2021_02_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.resource_access_rules = resource_access_rules self.virtual_network_rules = virtual_network_rules @@ -4130,7 +3927,7 @@ def __init__( self.default_action = default_action -class ObjectReplicationPolicies(msrest.serialization.Model): +class ObjectReplicationPolicies(_serialization.Model): """List storage account object replication policies. :ivar value: The replication policy between two storage accounts. @@ -4138,20 +3935,15 @@ class ObjectReplicationPolicies(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ObjectReplicationPolicy]'}, + "value": {"key": "value", "type": "[ObjectReplicationPolicy]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ObjectReplicationPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs): """ :keyword value: The replication policy between two storage accounts. :paramtype value: list[~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy] """ - super(ObjectReplicationPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4181,22 +3973,22 @@ class ObjectReplicationPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_id': {'readonly': True}, - 'enabled_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_id": {"readonly": True}, + "enabled_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, - 'enabled_time': {'key': 'properties.enabledTime', 'type': 'iso-8601'}, - 'source_account': {'key': 'properties.sourceAccount', 'type': 'str'}, - 'destination_account': {'key': 'properties.destinationAccount', 'type': 'str'}, - 'rules': {'key': 'properties.rules', 'type': '[ObjectReplicationPolicyRule]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "enabled_time": {"key": "properties.enabledTime", "type": "iso-8601"}, + "source_account": {"key": "properties.sourceAccount", "type": "str"}, + "destination_account": {"key": "properties.destinationAccount", "type": "str"}, + "rules": {"key": "properties.rules", "type": "[ObjectReplicationPolicyRule]"}, } def __init__( @@ -4215,7 +4007,7 @@ def __init__( :keyword rules: The storage account object replication rules. :paramtype rules: list[~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicyRule] """ - super(ObjectReplicationPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_id = None self.enabled_time = None self.source_account = source_account @@ -4223,7 +4015,7 @@ def __init__( self.rules = rules -class ObjectReplicationPolicyFilter(msrest.serialization.Model): +class ObjectReplicationPolicyFilter(_serialization.Model): """Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the filter. If multiple filters are defined, a logical AND is performed on all filters. :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin @@ -4235,17 +4027,11 @@ class ObjectReplicationPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'min_creation_time': {'key': 'minCreationTime', 'type': 'str'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "min_creation_time": {"key": "minCreationTime", "type": "str"}, } - def __init__( - self, - *, - prefix_match: Optional[List[str]] = None, - min_creation_time: Optional[str] = None, - **kwargs - ): + def __init__(self, *, prefix_match: Optional[List[str]] = None, min_creation_time: Optional[str] = None, **kwargs): """ :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. @@ -4254,12 +4040,12 @@ def __init__( It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. :paramtype min_creation_time: str """ - super(ObjectReplicationPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.min_creation_time = min_creation_time -class ObjectReplicationPolicyRule(msrest.serialization.Model): +class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. All required parameters must be populated in order to send to Azure. @@ -4267,24 +4053,24 @@ class ObjectReplicationPolicyRule(msrest.serialization.Model): :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :vartype rule_id: str - :ivar source_container: Required. Required. Source container name. + :ivar source_container: Required. Source container name. Required. :vartype source_container: str - :ivar destination_container: Required. Required. Destination container name. + :ivar destination_container: Required. Destination container name. Required. :vartype destination_container: str :ivar filters: Optional. An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicyFilter """ _validation = { - 'source_container': {'required': True}, - 'destination_container': {'required': True}, + "source_container": {"required": True}, + "destination_container": {"required": True}, } _attribute_map = { - 'rule_id': {'key': 'ruleId', 'type': 'str'}, - 'source_container': {'key': 'sourceContainer', 'type': 'str'}, - 'destination_container': {'key': 'destinationContainer', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': 'ObjectReplicationPolicyFilter'}, + "rule_id": {"key": "ruleId", "type": "str"}, + "source_container": {"key": "sourceContainer", "type": "str"}, + "destination_container": {"key": "destinationContainer", "type": "str"}, + "filters": {"key": "filters", "type": "ObjectReplicationPolicyFilter"}, } def __init__( @@ -4300,21 +4086,21 @@ def __init__( :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :paramtype rule_id: str - :keyword source_container: Required. Required. Source container name. + :keyword source_container: Required. Source container name. Required. :paramtype source_container: str - :keyword destination_container: Required. Required. Destination container name. + :keyword destination_container: Required. Destination container name. Required. :paramtype destination_container: str :keyword filters: Optional. An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicyFilter """ - super(ObjectReplicationPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.rule_id = rule_id self.source_container = source_container self.destination_container = destination_container self.filters = filters -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -4328,10 +4114,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -4353,14 +4139,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2021_02_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -4374,10 +4160,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -4399,14 +4185,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -4414,24 +4200,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2021_02_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4441,20 +4222,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -4478,25 +4255,28 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_02_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -4514,13 +4294,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.storage.v2021_02_01.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """List of private endpoint connection associated with the specified storage account. :ivar value: Array of private endpoint connections. @@ -4528,20 +4308,15 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4567,39 +4342,34 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "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, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): """ :keyword required_zone_names: The private link resource Private link DNS zone name. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. @@ -4607,28 +4377,23 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.storage.v2021_02_01.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", and "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -4639,9 +4404,9 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'action_required': {'key': 'actionRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "action_required": {"key": "actionRequired", "type": "str"}, } def __init__( @@ -4654,7 +4419,7 @@ def __init__( ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", and "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -4663,13 +4428,13 @@ def __init__( updates on the consumer. :paramtype action_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.action_required = action_required -class ProtocolSettings(msrest.serialization.Model): +class ProtocolSettings(_serialization.Model): """Protocol settings for file service. :ivar smb: Setting for SMB protocol. @@ -4677,20 +4442,15 @@ class ProtocolSettings(msrest.serialization.Model): """ _attribute_map = { - 'smb': {'key': 'smb', 'type': 'SmbSetting'}, + "smb": {"key": "smb", "type": "SmbSetting"}, } - def __init__( - self, - *, - smb: Optional["_models.SmbSetting"] = None, - **kwargs - ): + def __init__(self, *, smb: Optional["_models.SmbSetting"] = None, **kwargs): """ :keyword smb: Setting for SMB protocol. :paramtype smb: ~azure.mgmt.storage.v2021_02_01.models.SmbSetting """ - super(ProtocolSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.smb = smb @@ -4714,35 +4474,30 @@ class QueueServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Queue service. :paramtype cors: ~azure.mgmt.storage.v2021_02_01.models.CorsRules """ - super(QueueServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class ResourceAccessRule(msrest.serialization.Model): +class ResourceAccessRule(_serialization.Model): """Resource Access Rule. :ivar tenant_id: Tenant Id. @@ -4752,36 +4507,30 @@ class ResourceAccessRule(msrest.serialization.Model): """ _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__( - self, - *, - tenant_id: Optional[str] = None, - resource_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tenant_id: Optional[str] = None, resource_id: Optional[str] = None, **kwargs): """ :keyword tenant_id: Tenant Id. :paramtype tenant_id: str :keyword resource_id: Resource Id. :paramtype resource_id: str """ - super(ResourceAccessRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.tenant_id = tenant_id self.resource_id = resource_id -class RestorePolicyProperties(msrest.serialization.Model): +class RestorePolicyProperties(_serialization.Model): """The blob service properties for blob restore policy. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Blob restore is enabled if set to true. + :ivar enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool :ivar days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. @@ -4793,41 +4542,35 @@ class RestorePolicyProperties(msrest.serialization.Model): """ _validation = { - 'enabled': {'required': True}, - 'days': {'maximum': 365, 'minimum': 1}, - 'last_enabled_time': {'readonly': True}, - 'min_restore_time': {'readonly': True}, + "enabled": {"required": True}, + "days": {"maximum": 365, "minimum": 1}, + "last_enabled_time": {"readonly": True}, + "min_restore_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'min_restore_time': {'key': 'minRestoreTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "min_restore_time": {"key": "minRestoreTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: bool, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: bool, days: Optional[int] = None, **kwargs): """ - :keyword enabled: Required. Blob restore is enabled if set to true. + :keyword enabled: Blob restore is enabled if set to true. Required. :paramtype enabled: bool :keyword days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. :paramtype days: int """ - super(RestorePolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days self.last_enabled_time = None self.min_restore_time = None -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -4840,45 +4583,40 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_02_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_02_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class RoutingPreference(msrest.serialization.Model): +class RoutingPreference(_serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_02_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4889,9 +4627,9 @@ class RoutingPreference(msrest.serialization.Model): """ _attribute_map = { - 'routing_choice': {'key': 'routingChoice', 'type': 'str'}, - 'publish_microsoft_endpoints': {'key': 'publishMicrosoftEndpoints', 'type': 'bool'}, - 'publish_internet_endpoints': {'key': 'publishInternetEndpoints', 'type': 'bool'}, + "routing_choice": {"key": "routingChoice", "type": "str"}, + "publish_microsoft_endpoints": {"key": "publishMicrosoftEndpoints", "type": "bool"}, + "publish_internet_endpoints": {"key": "publishInternetEndpoints", "type": "bool"}, } def __init__( @@ -4904,7 +4642,7 @@ def __init__( ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_02_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -4913,72 +4651,66 @@ def __init__( storage endpoints are to be published. :paramtype publish_internet_endpoints: bool """ - super(RoutingPreference, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_choice = routing_choice self.publish_microsoft_endpoints = publish_microsoft_endpoints self.publish_internet_endpoints = publish_internet_endpoints -class SasPolicy(msrest.serialization.Model): +class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :ivar sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str - :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :ivar expiration_action: The SAS expiration action. Can only be Log. "Log" :vartype expiration_action: str or ~azure.mgmt.storage.v2021_02_01.models.ExpirationAction """ _validation = { - 'sas_expiration_period': {'required': True}, - 'expiration_action': {'required': True}, + "sas_expiration_period": {"required": True}, + "expiration_action": {"required": True}, } _attribute_map = { - 'sas_expiration_period': {'key': 'sasExpirationPeriod', 'type': 'str'}, - 'expiration_action': {'key': 'expirationAction', 'type': 'str'}, + "sas_expiration_period": {"key": "sasExpirationPeriod", "type": "str"}, + "expiration_action": {"key": "expirationAction", "type": "str"}, } def __init__( - self, - *, - sas_expiration_period: str, - expiration_action: Union[str, "_models.ExpirationAction"] = "Log", - **kwargs + self, *, sas_expiration_period: str, expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs ): """ - :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :keyword sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :paramtype sas_expiration_period: str - :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :keyword expiration_action: The SAS expiration action. Can only be Log. "Log" :paramtype expiration_action: str or ~azure.mgmt.storage.v2021_02_01.models.ExpirationAction """ - super(SasPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_expiration_period = sas_expiration_period self.expiration_action = expiration_action -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2021_02_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_02_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_02_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -5010,29 +4742,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, - } - - _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, + } + + _attribute_map = { + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -5059,20 +4791,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_02_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_02_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_02_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -5103,7 +4836,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -5124,7 +4857,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -5133,70 +4866,60 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2021_02_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_02_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_02_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_02_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -5209,45 +4932,41 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Storage SKU and its properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_02_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_02_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -5261,22 +4980,22 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -5287,16 +5006,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_02_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2021_02_01.models.Restriction] """ - super(SkuInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -5306,7 +5025,7 @@ def __init__( self.restrictions = restrictions -class SmbSetting(msrest.serialization.Model): +class SmbSetting(_serialization.Model): """Setting for SMB protocol. :ivar multichannel: Multichannel setting. Applies to Premium FileStorage only. @@ -5326,11 +5045,11 @@ class SmbSetting(msrest.serialization.Model): """ _attribute_map = { - 'multichannel': {'key': 'multichannel', 'type': 'Multichannel'}, - 'versions': {'key': 'versions', 'type': 'str'}, - 'authentication_methods': {'key': 'authenticationMethods', 'type': 'str'}, - 'kerberos_ticket_encryption': {'key': 'kerberosTicketEncryption', 'type': 'str'}, - 'channel_encryption': {'key': 'channelEncryption', 'type': 'str'}, + "multichannel": {"key": "multichannel", "type": "Multichannel"}, + "versions": {"key": "versions", "type": "str"}, + "authentication_methods": {"key": "authenticationMethods", "type": "str"}, + "kerberos_ticket_encryption": {"key": "kerberosTicketEncryption", "type": "str"}, + "channel_encryption": {"key": "channelEncryption", "type": "str"}, } def __init__( @@ -5359,7 +5078,7 @@ def __init__( AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. :paramtype channel_encryption: str """ - super(SmbSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.multichannel = multichannel self.versions = versions self.authentication_methods = authentication_methods @@ -5382,46 +5101,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -5436,21 +5149,21 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_02_01.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_02_01.models.Identity :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_02_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_02_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -5459,7 +5172,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_02_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -5471,7 +5184,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_02_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -5491,7 +5204,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2021_02_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5509,7 +5222,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -5526,7 +5239,7 @@ class StorageAccount(TrackedResource): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5538,76 +5251,82 @@ class StorageAccount(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'sas_policy': {'readonly': True}, - 'key_policy': {'readonly': True}, - 'key_creation_time': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'blob_restore_status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'key_creation_time': {'key': 'properties.keyCreationTime', 'type': 'KeyCreationTime'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'blob_restore_status': {'key': 'properties.blobRestoreStatus', 'type': 'BlobRestoreStatus'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "sas_policy": {"readonly": True}, + "key_policy": {"readonly": True}, + "key_creation_time": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "blob_restore_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "key_creation_time": {"key": "properties.keyCreationTime", "type": "KeyCreationTime"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "blob_restore_status": {"key": "properties.blobRestoreStatus", "type": "BlobRestoreStatus"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -5626,9 +5345,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_02_01.models.Identity @@ -5644,7 +5363,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5655,7 +5374,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5665,7 +5384,7 @@ def __init__( :keyword enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. :paramtype enable_nfs_v3: bool """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -5701,69 +5420,64 @@ def __init__( self.enable_nfs_v3 = enable_nfs_v3 -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_02_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str :ivar extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :vartype extended_location: ~azure.mgmt.storage.v2021_02_01.models.ExtendedLocation - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_02_01.models.Identity @@ -5781,7 +5495,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_02_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5793,7 +5507,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -5804,7 +5518,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5816,33 +5530,36 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, } def __init__( @@ -5872,24 +5589,24 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2021_02_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str :keyword extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :paramtype extended_location: ~azure.mgmt.storage.v2021_02_01.models.ExtendedLocation - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_02_01.models.Identity @@ -5907,7 +5624,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_02_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5919,7 +5636,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -5930,7 +5647,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5940,7 +5657,7 @@ def __init__( :keyword enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. :paramtype enable_nfs_v3: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -5964,7 +5681,7 @@ def __init__( self.enable_nfs_v3 = enable_nfs_v3 -class StorageAccountInternetEndpoints(msrest.serialization.Model): +class StorageAccountInternetEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -5980,33 +5697,29 @@ class StorageAccountInternetEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountInternetEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.file = None self.web = None self.dfs = None -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -6016,40 +5729,36 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_02_01.models.KeyPermission :ivar creation_time: Creation time of the key, in round trip date format. :vartype creation_time: ~datetime.datetime """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, - 'creation_time': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, + "creation_time": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None self.creation_time = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -6060,24 +5769,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -6090,27 +5795,23 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): +class StorageAccountMicrosoftEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -6130,30 +5831,26 @@ class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountMicrosoftEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -6162,55 +5859,50 @@ def __init__( self.dfs = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2, kerb1, kerb2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2, kerb1, kerb2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2021_02_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_02_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6224,7 +5916,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar key_policy: KeyPolicy assigned to the storage account. :vartype key_policy: ~azure.mgmt.storage.v2021_02_01.models.KeyPolicy :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6235,7 +5927,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_02_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6246,7 +5938,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6256,23 +5948,26 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, } def __init__( @@ -6302,16 +5997,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2021_02_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_02_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_02_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6325,7 +6020,7 @@ def __init__( :keyword key_policy: KeyPolicy assigned to the storage account. :paramtype key_policy: ~azure.mgmt.storage.v2021_02_01.models.KeyPolicy :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_02_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6337,7 +6032,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_02_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_02_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6348,7 +6043,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_02_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6356,7 +6051,7 @@ def __init__( default value is null, which is equivalent to true. :paramtype allow_shared_key_access: bool """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -6398,36 +6093,31 @@ class StorageQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'approximate_message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "approximate_message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'approximate_message_count': {'key': 'properties.approximateMessageCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "approximate_message_count": {"key": "properties.approximateMessageCount", "type": "int"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(StorageQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata self.approximate_message_count = None -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -6437,49 +6127,45 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuInformation]'}, + "value": {"key": "value", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_02_01.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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_02_01.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'}, + "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__( @@ -6497,19 +6183,19 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_02_01.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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_02_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -6536,26 +6222,22 @@ class Table(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'table_name': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "table_name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Table, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.table_name = None @@ -6579,86 +6261,74 @@ class TableServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Table service. :paramtype cors: ~azure.mgmt.storage.v2021_02_01.models.CorsRules """ - super(TableServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class TagFilter(msrest.serialization.Model): +class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. All required parameters must be populated in order to send to Azure. - :ivar name: Required. This is the filter tag name, it can have 1 - 128 characters. + :ivar name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str - :ivar op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :ivar op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :vartype op: str - :ivar value: Required. This is the filter tag value field used for tag based filtering, it can - have 0 - 256 characters. + :ivar value: This is the filter tag value field used for tag based filtering, it can have 0 - + 256 characters. Required. :vartype value: str """ _validation = { - 'name': {'required': True, 'max_length': 128, 'min_length': 1}, - 'op': {'required': True}, - 'value': {'required': True, 'max_length': 256, 'min_length': 0}, + "name": {"required": True, "max_length": 128, "min_length": 1}, + "op": {"required": True}, + "value": {"required": True, "max_length": 256}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'op': {'key': 'op', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "op": {"key": "op", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - op: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, op: str, value: str, **kwargs): """ - :keyword name: Required. This is the filter tag name, it can have 1 - 128 characters. + :keyword name: This is the filter tag name, it can have 1 - 128 characters. Required. :paramtype name: str - :keyword op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :keyword op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :paramtype op: str - :keyword value: Required. This is the filter tag value field used for tag based filtering, it - can have 0 - 256 characters. + :keyword value: This is the filter tag value field used for tag based filtering, it can have 0 + - 256 characters. Required. :paramtype value: str """ - super(TagFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.op = op self.value = value -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -6676,28 +6346,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -6705,13 +6371,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -6728,30 +6394,26 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -6760,13 +6422,13 @@ def __init__( self.upn = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_02_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -6777,33 +6439,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -6811,24 +6469,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2021_02_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -6840,27 +6493,23 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """UserAssignedIdentity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -6872,72 +6521,68 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_02_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "provisioning", - "deprovisioning", "succeeded", "failed", "networkSourceDeleted". + "deprovisioning", "succeeded", "failed", and "networkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_02_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py index da1c97b2f356..d755fef7c6ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,10 +25,13 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobInventoryPolicyName.""" DEFAULT = "default" + class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - @@ -39,6 +42,7 @@ class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): COMPLETE = "Complete" FAILED = "Failed" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -50,7 +54,9 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CorsRuleAllowedMethodsItem.""" DELETE = "DELETE" GET = "GET" @@ -60,30 +66,31 @@ class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): OPTIONS = "OPTIONS" PUT = "PUT" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the directory service used. - """ + """Indicates the directory service used.""" NONE = "None" AADDS = "AADDS" AD = "AD" + class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. @@ -92,6 +99,7 @@ class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): SMB = "SMB" NFS = "NFS" + class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. @@ -100,25 +108,32 @@ class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. - """ + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + +class Enum31(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum31.""" + + DEFAULT = "default" + + class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SAS expiration action. Can only be Log. - """ + """The SAS expiration action. Can only be Log.""" LOG = "Log" + class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation. - """ + """The type of extendedLocation.""" EDGE_ZONE = "EdgeZone" + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -131,29 +146,30 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type. - """ + """The identity type.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -163,27 +179,29 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Inventory - """ + """The valid value is Inventory.""" INVENTORY = "Inventory" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service @@ -193,9 +211,9 @@ class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SERVICE = "Service" ACCOUNT = "Account" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -203,22 +221,23 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - """ + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -228,9 +247,9 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -238,26 +257,33 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListContainersInclude.""" DELETED = "deleted" + class ListSharesExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListSharesExpand.""" DELETED = "deleted" SNAPSHOTS = "snapshots" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. @@ -267,12 +293,13 @@ class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" + class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only - """ + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only.""" ACCESS_TIME_TRACKING = "AccessTimeTracking" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -287,43 +314,46 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state. - """ + """The current provisioning state.""" SUCCEEDED = "Succeeded" CREATING = "Creating" DELETING = "Deleting" FAILED = "Failed" + class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status. - """ + """The private endpoint connection status.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class PutSharesExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """PutSharesExpand.""" SNAPSHOTS = "snapshots" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -332,6 +362,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -342,27 +373,28 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The property is for NFS share only. The default is NoRootSquash. - """ + """The property is for NFS share only. The default is NoRootSquash.""" NO_ROOT_SQUASH = "NoRootSquash" ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" + class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Routing Choice defines the kind of network routing opted by the user. - """ + """Routing Choice defines the kind of network routing opted by the user.""" MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" + class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Lifecycle - """ + """The valid value is Lifecycle.""" LIFECYCLE = "Lifecycle" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -373,6 +405,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. @@ -383,6 +416,7 @@ class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): COOL = "Cool" PREMIUM = "Premium" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -393,6 +427,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -403,6 +438,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -417,16 +453,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SKU tier. This is based on the SKU name. - """ + """The SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "provisioning" DEPROVISIONING = "deprovisioning" @@ -434,14 +470,16 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "failed" NETWORK_SOURCE_DELETED = "networkSourceDeleted" + class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountExpand.""" GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/__init__.py index 9a63fd415725..a7c5747747ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/__init__.py @@ -29,26 +29,27 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_operations.py index 589724cade39..e89bb4982070 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_containers_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -34,361 +48,307 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum31], subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum31], subscription_id: str, *, if_match: Optional[str] = None, @@ -397,43 +357,42 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum31], subscription_id: str, *, if_match: str, @@ -442,36 +401,34 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -486,34 +443,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -523,93 +479,79 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class BlobContainersOperations: """ @@ -630,7 +572,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -638,18 +579,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> Iterable[_models.ListContainerItems]: + ) -> Iterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -658,35 +599,39 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_02_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -694,18 +639,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -722,10 +666,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -735,19 +677,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -755,37 +697,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -795,7 +824,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -803,10 +833,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -814,63 +843,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -880,7 +995,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -888,72 +1004,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -961,72 +1073,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1034,10 +1142,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1047,16 +1154,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1064,37 +1172,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1104,7 +1299,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1112,70 +1308,155 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_02_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -1185,7 +1466,8 @@ def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1193,51 +1475,55 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum31], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -1245,44 +1531,144 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum31], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum31], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1290,10 +1676,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1301,17 +1686,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1319,6 +1703,7 @@ def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum31], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1326,52 +1711,52 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1379,10 +1764,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1390,17 +1774,16 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( @@ -1408,6 +1791,7 @@ def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum31], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1417,52 +1801,52 @@ def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1470,10 +1854,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1481,71 +1864,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1553,10 +1932,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1564,19 +1942,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1584,6 +1961,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1591,56 +1970,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1648,10 +2126,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1659,65 +2136,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1727,7 +2290,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1735,22 +2299,20 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_operations.py index 7e9d4bff0cab..17c058fcfbe4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_inventory_policies_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,167 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - *, - json: Optional[_models.BlobInventoryPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobInventoryPoliciesOperations: """ @@ -207,52 +208,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -260,10 +262,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -271,68 +272,151 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy 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 - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -340,10 +424,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -351,61 +434,62 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -413,10 +497,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -427,51 +510,50 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -479,15 +561,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -504,10 +588,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -518,8 +600,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_operations.py index c0f0e9c994d3..4a0298c3c8e8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_blob_services_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,134 +27,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum31], subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum31], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -168,47 +170,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -216,15 +220,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -241,10 +247,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -254,66 +258,149 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum31], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum31], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum31], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -321,72 +408,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum31], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -394,22 +476,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_operations.py index b6e66a18bf53..896c7b6aba05 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_deleted_accounts_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,81 +27,74 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_get_request( - deleted_account_name: str, - location: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(deleted_account_name: str, location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), - "location": _SERIALIZER.url("location", location, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "deletedAccountName": _SERIALIZER.url( + "deleted_account_name", deleted_account_name, "str", max_length=24, min_length=3 + ), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DeletedAccountsOperations: """ @@ -115,38 +115,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DeletedAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -154,13 +152,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -177,10 +179,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -191,48 +191,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace - def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,10 +235,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,12 +245,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_operations.py index e4ab7b5b08f9..0ff66cc1ef83 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_encryption_scopes_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,181 +27,164 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_put_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EncryptionScopesOperations: """ @@ -215,14 +205,15 @@ def __init__(self, *args, **kwargs): 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 + @overload def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -230,47 +221,137 @@ def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -278,10 +359,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -290,73 +370,160 @@ def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace + @overload def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -364,10 +531,9 @@ def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,62 +541,59 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -438,10 +601,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,58 +611,54 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.EncryptionScopeListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -508,15 +666,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -533,10 +693,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -546,8 +704,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_operations.py index 25b38a6afafb..d836e8183a4d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum31], subscription_id: str, - *, - json: Optional[_models.FileServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum31], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class FileServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +211,162 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum31], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum31], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum31], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +374,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum31], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +442,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_operations.py index 783c42ac8c31..c2e3ed82a05f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_file_shares_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -34,44 +48,43 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, + expand: Optional[Union[str, _models.ListSharesExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( @@ -80,95 +93,80 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: Optional[_models.FileShare] = None, - content: Any = None, - expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, + expand: Optional[Union[str, _models.PutSharesExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -177,44 +175,43 @@ def build_get_request( share_name: str, subscription_id: str, *, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -229,82 +226,72 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_restore_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.DeletedShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class FileSharesOperations: """ @@ -325,7 +312,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -333,17 +319,17 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - expand: Optional[Union[str, "_models.ListSharesExpand"]] = None, + expand: Optional[Union[str, _models.ListSharesExpand]] = None, **kwargs: Any - ) -> Iterable[_models.FileShareItems]: + ) -> Iterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -351,36 +337,40 @@ def list( :param filter: Optional. When specified, only share names starting with the filter will be listed. Default value is None. :type filter: str - :param expand: Optional, used to expand the properties within share's properties. Default value - is None. + :param expand: Optional, used to expand the properties within share's properties. Known values + are: "deleted" and "snapshots". Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.ListSharesExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -388,18 +378,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -416,10 +405,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -429,20 +416,20 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, - expand: Optional[Union[str, "_models.PutSharesExpand"]] = None, + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -450,50 +437,144 @@ def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare - :param expand: Optional, used to create a snapshot. Default value is None. + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. + :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[Union[str, _models.PutSharesExpand]] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare or IO + :param expand: Optional, used to create a snapshot. "snapshots" Default value is None. + :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.PutSharesExpand + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -501,10 +582,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -512,63 +592,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_02_01.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -578,7 +744,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -586,25 +753,23 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def get( @@ -612,56 +777,58 @@ def get( resource_group_name: str, account_name: str, share_name: str, - expand: Optional[str] = "stats", + expand: Literal["stats"] = "stats", x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> _models.FileShare: """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Known values - are "stats" or None. Default value is "stats". + are "stats" and None. Default value is "stats". :type expand: str :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -669,25 +836,23 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -701,44 +866,46 @@ def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -746,10 +913,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -759,52 +925,135 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace + @overload def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_02_01.models.DeletedShare + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_02_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -814,7 +1063,8 @@ def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -822,10 +1072,9 @@ def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -835,5 +1084,4 @@ def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_operations.py index fd668860dc8b..ccdc8c32cafd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,130 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,52 +169,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -215,78 +223,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy 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 - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -294,71 +384,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_02_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -366,10 +456,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +468,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_operations.py index 80eec726662a..2f51ae0303c7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_object_replication_policies_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,161 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - *, - json: Optional[_models.ObjectReplicationPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ObjectReplicationPoliciesOperations: """ @@ -207,49 +202,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +252,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +279,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -296,56 +291,52 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -353,10 +344,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -364,68 +354,150 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: The ID of object replication policy or 'default' if the + policy ID is unknown. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy 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 - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -433,10 +505,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -444,60 +515,57 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: The ID of object replication policy or 'default' if the - policy ID is unknown. + policy ID is unknown. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -505,10 +573,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -519,5 +586,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_operations.py index b90d35706aab..30d6c3773f5c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_endpoint_connections_operations.py index 3a8475955e5d..628659f5a5a8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,173 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -207,49 +214,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +264,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +291,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,56 +302,52 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -352,10 +355,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,67 +365,148 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace + @overload def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection 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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -431,10 +514,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,60 +524,57 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -503,10 +582,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -517,5 +595,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_link_resources_operations.py index def4e04b795d..200a4e9f5cb5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,52 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_storage_account_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,46 +91,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -128,22 +136,20 @@ def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_operations.py index 2f0b1f7be401..b90bdf6e773a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,183 +27,188 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( @@ -211,36 +223,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueOperations: """ @@ -261,60 +273,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -322,79 +419,163 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -402,72 +583,66 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.StorageQueue: + def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -475,72 +650,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -548,10 +719,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -561,8 +731,7 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -572,15 +741,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.ListQueueResource]: + ) -> Iterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -589,31 +758,35 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -621,17 +794,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -648,10 +821,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -661,8 +832,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_operations.py index f8995361ae52..152610a1212b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_queue_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum31], subscription_id: str, - *, - json: Optional[_models.QueueServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum31], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +211,163 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum31], parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :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: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum31], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum31], + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties 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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +375,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum31], **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +443,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_operations.py index b15dba59e858..8557a4cfc95d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_operations.py index 27bcf46391f7..3cf80e46bd42 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +29,110 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,153 +140,129 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -304,280 +270,238 @@ def build_list_keys_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "kerb", + expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_restore_blob_ranges_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobRestoreParameters] = None, - content: Any = None, - **kwargs: Any +def build_restore_blob_ranges_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revoke_user_delegation_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: """ @@ -598,45 +522,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2021_02_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -644,55 +621,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -700,10 +685,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -712,22 +696,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -736,14 +721,17 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCreateParameters + :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 @@ -755,20 +743,98 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -776,79 +842,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -856,10 +917,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -869,15 +929,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -885,40 +944,43 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_02_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -926,32 +988,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -964,32 +1026,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountUpdateParameters + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -998,7 +1145,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1006,58 +1154,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1065,13 +1210,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1088,10 +1237,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1101,49 +1248,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1151,14 +1294,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1175,10 +1321,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1188,57 +1332,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1246,65 +1386,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_02_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1313,7 +1526,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1321,63 +1535,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1386,7 +1673,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1394,63 +1682,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1459,7 +1818,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1467,50 +1827,47 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1518,10 +1875,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1531,26 +1887,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1562,85 +1912,90 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1648,10 +2003,9 @@ def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1659,38 +2013,80 @@ def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace + @overload def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1702,20 +2098,54 @@ def begin_restore_blob_ranges( :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.BlobRestoreParameters 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. + :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_02_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1723,79 +2153,76 @@ def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1803,10 +2230,9 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1816,5 +2242,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_operations.py index 6a9c424dcc60..90d1d965eecc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,204 +27,194 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableOperations: """ @@ -238,52 +235,47 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def create(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -291,71 +283,65 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -363,71 +349,65 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -435,71 +415,67 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -507,10 +483,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -520,49 +495,47 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -570,15 +543,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -595,10 +570,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,8 +581,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_operations.py index 92ff96e5ca85..84b85fcd67c6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_table_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum31], subscription_id: str, - *, - json: Optional[_models.TableServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum31], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,80 +211,163 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum31], parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :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: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum31], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum31], + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties 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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +375,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum31], **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_02_01.models.Enum31 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_02_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +443,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_operations.py index 43a7bbbc1005..c542fbd175ab 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_02_01/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,41 +87,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_02_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-02-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-02-01")) # type: Literal["2021-02-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -122,14 +128,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -146,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -159,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_configuration.py index f79f8e02325e..40b6042bdc67 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-04-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", "2021-04-01") # type: Literal["2021-04-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json index 3a4347381ea3..80378abb14dc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -117,4 +117,4 @@ "table_services": "TableServicesOperations", "table": "TableOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py index 54d204bbbb21..4963a6b6c8c4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_storage_management_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -69,9 +89,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_04_01.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_04_01.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -89,28 +109,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -129,37 +145,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -168,7 +163,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_configuration.py index 35f75c7989c1..bcbdd6e5ad3d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-04-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-04-01") # type: str + api_version = kwargs.pop("api_version", "2021-04-01") # type: Literal["2021-04-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py index c70345d3dcb4..677b96c26211 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/_storage_management_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -72,9 +92,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_04_01.aio.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_04_01.aio.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -92,28 +112,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -132,37 +148,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -171,7 +166,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/__init__.py index 9a63fd415725..a7c5747747ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/__init__.py @@ -29,26 +29,27 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_operations.py index d74cda44e72e..1341c13ec5c1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_containers_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,31 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_object_level_worm_request_initial, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_object_level_worm_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -45,7 +75,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,18 +82,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListContainerItems]: + ) -> AsyncIterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -73,36 +102,40 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_04_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -110,18 +143,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -138,10 +170,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,19 +181,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -171,37 +201,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -211,7 +328,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -219,10 +337,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -230,63 +347,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -296,7 +499,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -304,72 +508,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -377,72 +577,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -450,10 +646,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -463,16 +658,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -480,37 +676,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -520,7 +803,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -528,70 +812,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -601,7 +970,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -609,51 +979,55 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum35], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -661,44 +1035,144 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum35], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum35], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -706,10 +1180,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -717,17 +1190,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -735,6 +1207,7 @@ async def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum35], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -742,52 +1215,52 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -795,10 +1268,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -806,17 +1278,16 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( @@ -824,6 +1295,7 @@ async def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum35], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -833,52 +1305,52 @@ async def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -886,10 +1358,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -897,71 +1368,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -969,10 +1436,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -980,19 +1446,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -1000,6 +1465,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1007,56 +1474,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1064,10 +1630,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1075,65 +1640,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1143,7 +1794,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1151,52 +1803,48 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_object_level_worm_request_initial( + request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata['url'], + template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1204,10 +1852,9 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1217,16 +1864,11 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore - + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace_async - async def begin_object_level_worm( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + async def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites require a container level immutability policy either in locked @@ -1234,16 +1876,16 @@ async def begin_object_level_worm( # pylint: disable=inconsistent-return-statem on the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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. @@ -1255,53 +1897,48 @@ async def begin_object_level_worm( # pylint: disable=inconsistent-return-statem 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_operations.py index 7f99163cbee2..3a75649a163a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_inventory_policies_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_inventory_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._blob_inventory_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobInventoryPoliciesOperations: """ .. warning:: @@ -43,52 +63,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +117,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,68 +127,151 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy 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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -176,10 +279,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,61 +289,62 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -249,10 +352,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -263,51 +365,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -315,15 +416,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -340,10 +443,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -354,8 +455,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_operations.py index e3112018c2c9..ecb04bdaf783 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_blob_services_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -43,48 +62,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,66 +150,149 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum35], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum35], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum35], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -197,72 +300,67 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum35], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -270,22 +368,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_operations.py index 7a936d8f713f..8cf31aada27a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_deleted_accounts_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DeletedAccountsOperations: """ .. warning:: @@ -43,38 +58,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) + :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -82,13 +96,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -105,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -119,48 +135,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async - async def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -168,10 +179,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,12 +189,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_operations.py index f5c72d7c7112..07a07b9fab30 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_encryption_scopes_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._encryption_scopes_operations import build_get_request, build_list_request, build_patch_request, build_put_request -T = TypeVar('T') +from ...operations._encryption_scopes_operations import ( + build_get_request, + build_list_request, + build_patch_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EncryptionScopesOperations: """ .. warning:: @@ -43,14 +63,15 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -58,47 +79,137 @@ async def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -106,10 +217,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -118,73 +228,160 @@ async def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace_async + @overload async def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +389,9 @@ async def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,62 +399,59 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -266,10 +459,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -277,58 +469,57 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EncryptionScopeListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) + :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -336,15 +527,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -361,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -374,8 +565,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_operations.py index 26e8a5f6eeef..7cc2b1d1d402 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,10 +102,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,70 +112,153 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum35], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum35], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum35], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -170,10 +266,9 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,62 +276,58 @@ async def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum35], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -244,10 +335,9 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,12 +345,11 @@ async def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_operations.py index 8a405d076630..56464a565fb3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_file_shares_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,24 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_shares_operations import build_create_request, build_delete_request, build_get_request, build_lease_request, build_list_request, build_restore_request, build_update_request -T = TypeVar('T') +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_lease_request, + build_list_request, + build_restore_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileSharesOperations: """ .. warning:: @@ -43,7 +66,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,15 +75,15 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.FileShareItems]: + ) -> AsyncIterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -74,33 +96,37 @@ def list( None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) + :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -108,18 +134,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -136,10 +161,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -150,13 +173,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, @@ -164,6 +185,8 @@ async def create( share_name: str, file_share: _models.FileShare, expand: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -171,51 +194,147 @@ async def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -223,10 +342,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -235,63 +353,149 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -301,7 +505,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -309,10 +514,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -320,15 +524,14 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def get( @@ -343,16 +546,16 @@ async def get( """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. Default value is None. @@ -361,31 +564,33 @@ async def get( None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -393,10 +598,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -404,15 +608,14 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -427,16 +630,16 @@ async def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str @@ -445,34 +648,37 @@ async def delete( # pylint: disable=inconsistent-return-statements snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the - file share contains any snapshots (leased or unleased), the deletion fails. + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. :type include: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -480,10 +686,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -494,52 +699,135 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace_async + @overload async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_04_01.models.DeletedShare + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_04_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -549,7 +837,8 @@ async def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -557,10 +846,9 @@ async def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -571,10 +859,9 @@ async def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, @@ -582,60 +869,156 @@ async def lease( share_name: str, x_ms_snapshot: Optional[str] = None, parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse, or the result of cls(response) + :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseShareResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseShareRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, api_version=api_version, content_type=content_type, json=_json, - x_ms_snapshot=x_ms_snapshot, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -643,10 +1026,9 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -655,14 +1037,13 @@ async def lease( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_operations.py index 6b92981369c7..286ef9889935 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,52 +59,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -94,78 +113,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy + :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: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -173,71 +274,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -245,10 +346,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -258,5 +358,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_operations.py index 15adfb5f9e5a..a08e92482ea7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_object_replication_policies_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._object_replication_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._object_replication_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ObjectReplicationPoliciesOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,58 +152,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -191,10 +207,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,70 +217,156 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy 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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -273,10 +374,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -284,62 +384,59 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -347,10 +444,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -361,5 +457,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_operations.py index bef21540dd1b..bb52282f5d97 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_endpoint_connections_operations.py index 478f6f5d4c50..a4d00fafdc4f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request, build_get_request, build_list_request, build_put_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +151,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +204,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +214,148 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection 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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +363,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +373,57 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +431,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,5 +444,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_link_resources_operations.py index cb9a5b1ab8a2..835d5b293900 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,46 +55,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -88,22 +100,20 @@ async def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_operations.py index 5915e46055a0..382ba3dbbc96 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._queue_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueOperations: """ .. warning:: @@ -43,60 +64,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue 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 - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -104,10 +210,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,69 +220,154 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -185,10 +375,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -196,62 +385,59 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -259,10 +445,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -270,62 +455,59 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -333,10 +515,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -347,8 +528,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -358,15 +538,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListQueueResource]: + ) -> AsyncIterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -375,32 +555,36 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) + :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -408,17 +592,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -435,10 +619,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -449,8 +631,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_operations.py index 88c3bc2db99f..3e1909876724 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_queue_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._queue_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,10 +102,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,70 +112,154 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum35], parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :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: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum35], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum35], + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties 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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -170,10 +267,9 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,62 +277,58 @@ async def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum35], **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -244,10 +336,9 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,12 +346,11 @@ async def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_operations.py index 02e35eed4fab..d8c6df9deecc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) + :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +95,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +133,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_operations.py index fabbc3e0fe65..0590a9108549 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,31 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_restore_blob_ranges_request_initial, build_revoke_user_delegation_keys_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_restore_blob_ranges_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: """ .. warning:: @@ -45,45 +75,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2021_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2021_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCheckNameAvailabilityParameters 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 - :return: CheckNameAvailabilityResult, or the result of cls(response) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +174,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +238,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +249,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +274,17 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCreateParameters + :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 @@ -203,20 +297,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCreateParameters 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. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +398,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +473,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,15 +485,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -333,40 +500,43 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_04_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,32 +544,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -412,32 +582,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -446,7 +701,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -454,58 +710,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -513,13 +767,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -536,10 +794,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,49 +805,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -599,14 +854,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -623,10 +881,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -636,57 +892,53 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -694,65 +946,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_04_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -761,7 +1086,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -769,63 +1095,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -834,7 +1233,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -842,63 +1242,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -907,7 +1378,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -915,50 +1387,47 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -966,10 +1435,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -979,26 +1447,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1010,85 +1472,90 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1096,10 +1563,9 @@ async def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1107,38 +1573,81 @@ async def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - @distributed_trace_async + @overload async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1151,20 +1660,55 @@ async def begin_restore_blob_ranges( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobRestoreParameters 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. + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1172,79 +1716,76 @@ async def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1252,10 +1793,9 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1265,5 +1805,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_operations.py index 8c76184dd0f3..3ccf0abbed97 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._table_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableOperations: """ .. warning:: @@ -43,52 +64,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +114,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,61 +124,58 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -169,10 +183,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -180,61 +193,56 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -242,10 +250,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,61 +260,58 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -315,10 +319,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -329,50 +332,47 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -380,15 +380,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -405,10 +407,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -419,8 +419,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_operations.py index df12e59d7453..a773278f633a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_table_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._table_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,10 +102,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,70 +112,154 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum35], parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :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: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum35], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum35], + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties 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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -170,10 +267,9 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,62 +277,58 @@ async def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum35], **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -244,10 +336,9 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,12 +346,11 @@ async def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_operations.py index 754930cf7cef..687b59582d55 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,42 +57,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_04_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -85,14 +98,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -109,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -122,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/__init__.py index 8cfef998e7d4..ba4592d240a1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/__init__.py @@ -145,267 +145,267 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountStatus, - BlobInventoryPolicyName, - BlobRestoreProgressStatus, - Bypass, - CorsRuleAllowedMethodsItem, - CreatedByType, - DefaultAction, - DefaultSharePermission, - DirectoryServiceOptions, - EnabledProtocols, - EncryptionScopeSource, - EncryptionScopeState, - ExpirationAction, - ExtendedLocationTypes, - Format, - GeoReplicationStatus, - HttpProtocol, - IdentityType, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - InventoryRuleType, - KeyPermission, - KeySource, - KeyType, - Kind, - LargeFileSharesState, - LeaseContainerRequestAction, - LeaseDuration, - LeaseShareAction, - LeaseState, - LeaseStatus, - ListContainersInclude, - ManagementPolicyName, - MigrationState, - MinimumTlsVersion, - Name, - ObjectType, - Permissions, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisioningState, - PublicAccess, - Reason, - ReasonCode, - RootSquashType, - RoutingChoice, - RuleType, - Schedule, - Services, - ShareAccessTier, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - StorageAccountExpand, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import BlobInventoryPolicyName +from ._storage_management_client_enums import BlobRestoreProgressStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CorsRuleAllowedMethodsItem +from ._storage_management_client_enums import CreatedByType +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DefaultSharePermission +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import EnabledProtocols +from ._storage_management_client_enums import EncryptionScopeSource +from ._storage_management_client_enums import EncryptionScopeState +from ._storage_management_client_enums import Enum35 +from ._storage_management_client_enums import ExpirationAction +from ._storage_management_client_enums import ExtendedLocationTypes +from ._storage_management_client_enums import Format +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import IdentityType +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import InventoryRuleType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import KeyType +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseShareAction +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ListContainersInclude +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MigrationState +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Name +from ._storage_management_client_enums import ObjectType +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._storage_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RootSquashType +from ._storage_management_client_enums import RoutingChoice +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Schedule +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import ShareAccessTier +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import StorageAccountExpand +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessPolicy', - 'AccountSasParameters', - 'ActiveDirectoryProperties', - 'AzureEntityResource', - 'AzureFilesIdentityBasedAuthentication', - 'BlobContainer', - 'BlobInventoryPolicy', - 'BlobInventoryPolicyDefinition', - 'BlobInventoryPolicyFilter', - 'BlobInventoryPolicyRule', - 'BlobInventoryPolicySchema', - 'BlobRestoreParameters', - 'BlobRestoreRange', - 'BlobRestoreStatus', - 'BlobServiceItems', - 'BlobServiceProperties', - 'ChangeFeed', - 'CheckNameAvailabilityResult', - 'CloudErrorAutoGenerated', - 'CloudErrorBody', - 'CloudErrorBodyAutoGenerated', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DateAfterCreation', - 'DateAfterModification', - 'DeleteRetentionPolicy', - 'DeletedAccount', - 'DeletedAccountListResult', - 'DeletedShare', - 'Dimension', - 'Encryption', - 'EncryptionIdentity', - 'EncryptionScope', - 'EncryptionScopeKeyVaultProperties', - 'EncryptionScopeListResult', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'ErrorResponse', - 'ErrorResponseBody', - 'ExtendedLocation', - 'FileServiceItems', - 'FileServiceProperties', - 'FileShare', - 'FileShareItem', - 'FileShareItems', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'ImmutableStorageWithVersioning', - 'KeyCreationTime', - 'KeyPolicy', - 'KeyVaultProperties', - 'LastAccessTimeTrackingPolicy', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LeaseShareRequest', - 'LeaseShareResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListBlobInventoryPolicy', - 'ListContainerItem', - 'ListContainerItems', - 'ListQueue', - 'ListQueueResource', - 'ListQueueServices', - 'ListServiceSasResponse', - 'ListTableResource', - 'ListTableServices', - 'ManagementPolicy', - 'ManagementPolicyAction', - 'ManagementPolicyBaseBlob', - 'ManagementPolicyDefinition', - 'ManagementPolicyFilter', - 'ManagementPolicyRule', - 'ManagementPolicySchema', - 'ManagementPolicySnapShot', - 'ManagementPolicyVersion', - 'MetricSpecification', - 'Multichannel', - 'NetworkRuleSet', - 'ObjectReplicationPolicies', - 'ObjectReplicationPolicy', - 'ObjectReplicationPolicyFilter', - 'ObjectReplicationPolicyRule', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProtocolSettings', - 'ProxyResource', - 'QueueServiceProperties', - 'Resource', - 'ResourceAccessRule', - 'RestorePolicyProperties', - 'Restriction', - 'RoutingPreference', - 'SKUCapability', - 'SasPolicy', - 'ServiceSasParameters', - 'ServiceSpecification', - 'SignedIdentifier', - 'Sku', - 'SkuInformation', - 'SmbSetting', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountInternetEndpoints', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountMicrosoftEndpoints', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageQueue', - 'StorageSkuListResult', - 'SystemData', - 'Table', - 'TableServiceProperties', - 'TagFilter', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'UserAssignedIdentity', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountStatus', - 'BlobInventoryPolicyName', - 'BlobRestoreProgressStatus', - 'Bypass', - 'CorsRuleAllowedMethodsItem', - 'CreatedByType', - 'DefaultAction', - 'DefaultSharePermission', - 'DirectoryServiceOptions', - 'EnabledProtocols', - 'EncryptionScopeSource', - 'EncryptionScopeState', - 'ExpirationAction', - 'ExtendedLocationTypes', - 'Format', - 'GeoReplicationStatus', - 'HttpProtocol', - 'IdentityType', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'InventoryRuleType', - 'KeyPermission', - 'KeySource', - 'KeyType', - 'Kind', - 'LargeFileSharesState', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseShareAction', - 'LeaseState', - 'LeaseStatus', - 'ListContainersInclude', - 'ManagementPolicyName', - 'MigrationState', - 'MinimumTlsVersion', - 'Name', - 'ObjectType', - 'Permissions', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'ProvisioningState', - 'PublicAccess', - 'Reason', - 'ReasonCode', - 'RootSquashType', - 'RoutingChoice', - 'RuleType', - 'Schedule', - 'Services', - 'ShareAccessTier', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'StorageAccountExpand', - 'UsageUnit', + "AccessPolicy", + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobInventoryPolicy", + "BlobInventoryPolicyDefinition", + "BlobInventoryPolicyFilter", + "BlobInventoryPolicyRule", + "BlobInventoryPolicySchema", + "BlobRestoreParameters", + "BlobRestoreRange", + "BlobRestoreStatus", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorAutoGenerated", + "CloudErrorBody", + "CloudErrorBodyAutoGenerated", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "DeletedAccount", + "DeletedAccountListResult", + "DeletedShare", + "Dimension", + "Encryption", + "EncryptionIdentity", + "EncryptionScope", + "EncryptionScopeKeyVaultProperties", + "EncryptionScopeListResult", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ErrorResponse", + "ErrorResponseBody", + "ExtendedLocation", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "ImmutableStorageWithVersioning", + "KeyCreationTime", + "KeyPolicy", + "KeyVaultProperties", + "LastAccessTimeTrackingPolicy", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LeaseShareRequest", + "LeaseShareResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListBlobInventoryPolicy", + "ListContainerItem", + "ListContainerItems", + "ListQueue", + "ListQueueResource", + "ListQueueServices", + "ListServiceSasResponse", + "ListTableResource", + "ListTableServices", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "ManagementPolicyVersion", + "MetricSpecification", + "Multichannel", + "NetworkRuleSet", + "ObjectReplicationPolicies", + "ObjectReplicationPolicy", + "ObjectReplicationPolicyFilter", + "ObjectReplicationPolicyRule", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProtocolSettings", + "ProxyResource", + "QueueServiceProperties", + "Resource", + "ResourceAccessRule", + "RestorePolicyProperties", + "Restriction", + "RoutingPreference", + "SKUCapability", + "SasPolicy", + "ServiceSasParameters", + "ServiceSpecification", + "SignedIdentifier", + "Sku", + "SkuInformation", + "SmbSetting", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountInternetEndpoints", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountMicrosoftEndpoints", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageQueue", + "StorageSkuListResult", + "SystemData", + "Table", + "TableServiceProperties", + "TagFilter", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "UserAssignedIdentity", + "VirtualNetworkRule", + "AccessTier", + "AccountStatus", + "BlobInventoryPolicyName", + "BlobRestoreProgressStatus", + "Bypass", + "CorsRuleAllowedMethodsItem", + "CreatedByType", + "DefaultAction", + "DefaultSharePermission", + "DirectoryServiceOptions", + "EnabledProtocols", + "EncryptionScopeSource", + "EncryptionScopeState", + "Enum35", + "ExpirationAction", + "ExtendedLocationTypes", + "Format", + "GeoReplicationStatus", + "HttpProtocol", + "IdentityType", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "InventoryRuleType", + "KeyPermission", + "KeySource", + "KeyType", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseShareAction", + "LeaseState", + "LeaseStatus", + "ListContainersInclude", + "ManagementPolicyName", + "MigrationState", + "MinimumTlsVersion", + "Name", + "ObjectType", + "Permissions", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicAccess", + "Reason", + "ReasonCode", + "RootSquashType", + "RoutingChoice", + "RuleType", + "Schedule", + "Services", + "ShareAccessTier", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "StorageAccountExpand", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py index 25d4168458bb..8f5613ec4133 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccessPolicy(msrest.serialization.Model): +class AccessPolicy(_serialization.Model): """AccessPolicy. :ivar start_time: Start time of the access policy. @@ -29,9 +35,9 @@ class AccessPolicy(msrest.serialization.Model): """ _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'permission': {'key': 'permission', 'type': 'str'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "permission": {"key": "permission", "type": "str"}, } def __init__( @@ -50,60 +56,60 @@ def __init__( :keyword permission: List of abbreviated permissions. :paramtype permission: str """ - super(AccessPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_time = start_time self.expiry_time = expiry_time self.permission = permission -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2021_04_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_04_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_04_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_04_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -120,33 +126,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2021_04_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_04_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_04_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_04_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -157,42 +164,42 @@ def __init__( self.key_to_sign = key_to_sign -class ActiveDirectoryProperties(msrest.serialization.Model): +class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). All required parameters must be populated in order to send to Azure. - :ivar domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :vartype domain_name: str - :ivar net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. Required. :vartype net_bios_domain_name: str - :ivar forest_name: Required. Specifies the Active Directory forest to get. + :ivar forest_name: Specifies the Active Directory forest to get. Required. :vartype forest_name: str - :ivar domain_guid: Required. Specifies the domain GUID. + :ivar domain_guid: Specifies the domain GUID. Required. :vartype domain_guid: str - :ivar domain_sid: Required. Specifies the security identifier (SID). + :ivar domain_sid: Specifies the security identifier (SID). Required. :vartype domain_sid: str - :ivar azure_storage_sid: Required. Specifies the security identifier (SID) for Azure Storage. + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. Required. :vartype azure_storage_sid: str """ _validation = { - 'domain_name': {'required': True}, - 'net_bios_domain_name': {'required': True}, - 'forest_name': {'required': True}, - 'domain_guid': {'required': True}, - 'domain_sid': {'required': True}, - 'azure_storage_sid': {'required': True}, + "domain_name": {"required": True}, + "net_bios_domain_name": {"required": True}, + "forest_name": {"required": True}, + "domain_guid": {"required": True}, + "domain_sid": {"required": True}, + "azure_storage_sid": {"required": True}, } _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'net_bios_domain_name': {'key': 'netBiosDomainName', 'type': 'str'}, - 'forest_name': {'key': 'forestName', 'type': 'str'}, - 'domain_guid': {'key': 'domainGuid', 'type': 'str'}, - 'domain_sid': {'key': 'domainSid', 'type': 'str'}, - 'azure_storage_sid': {'key': 'azureStorageSid', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, } def __init__( @@ -207,22 +214,22 @@ def __init__( **kwargs ): """ - :keyword domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :paramtype domain_name: str - :keyword net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. Required. :paramtype net_bios_domain_name: str - :keyword forest_name: Required. Specifies the Active Directory forest to get. + :keyword forest_name: Specifies the Active Directory forest to get. Required. :paramtype forest_name: str - :keyword domain_guid: Required. Specifies the domain GUID. + :keyword domain_guid: Specifies the domain GUID. Required. :paramtype domain_guid: str - :keyword domain_sid: Required. Specifies the security identifier (SID). + :keyword domain_sid: Specifies the security identifier (SID). Required. :paramtype domain_sid: str - :keyword azure_storage_sid: Required. Specifies the security identifier (SID) for Azure - Storage. + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + Required. :paramtype azure_storage_sid: str """ - super(ActiveDirectoryProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.net_bios_domain_name = net_bios_domain_name self.forest_name = forest_name @@ -231,7 +238,7 @@ def __init__( self.azure_storage_sid = azure_storage_sid -class Resource(msrest.serialization.Model): +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. @@ -247,24 +254,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -288,36 +291,32 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): +class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Known values - are: "None", "AADDS", "AD". + :ivar directory_service_options: Indicates the directory service used. Required. Known values + are: "None", "AADDS", and "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_04_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -326,19 +325,19 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): :ivar default_share_permission: Default share permission for users using Kerberos authentication if RBAC role is not assigned. Known values are: "None", "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", - "StorageFileDataSmbShareElevatedContributor", "StorageFileDataSmbShareOwner". + "StorageFileDataSmbShareElevatedContributor", and "StorageFileDataSmbShareOwner". :vartype default_share_permission: str or ~azure.mgmt.storage.v2021_04_01.models.DefaultSharePermission """ _validation = { - 'directory_service_options': {'required': True}, + "directory_service_options": {"required": True}, } _attribute_map = { - 'directory_service_options': {'key': 'directoryServiceOptions', 'type': 'str'}, - 'active_directory_properties': {'key': 'activeDirectoryProperties', 'type': 'ActiveDirectoryProperties'}, - 'default_share_permission': {'key': 'defaultSharePermission', 'type': 'str'}, + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, + "default_share_permission": {"key": "defaultSharePermission", "type": "str"}, } def __init__( @@ -350,8 +349,8 @@ def __init__( **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Known - values are: "None", "AADDS", "AD". + :keyword directory_service_options: Indicates the directory service used. Required. Known + values are: "None", "AADDS", and "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_04_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. @@ -360,17 +359,17 @@ def __init__( :keyword default_share_permission: Default share permission for users using Kerberos authentication if RBAC role is not assigned. Known values are: "None", "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", - "StorageFileDataSmbShareElevatedContributor", "StorageFileDataSmbShareOwner". + "StorageFileDataSmbShareElevatedContributor", and "StorageFileDataSmbShareOwner". :paramtype default_share_permission: str or ~azure.mgmt.storage.v2021_04_01.models.DefaultSharePermission """ - super(AzureFilesIdentityBasedAuthentication, self).__init__(**kwargs) + super().__init__(**kwargs) self.directory_service_options = directory_service_options self.active_directory_properties = active_directory_properties self.default_share_permission = default_share_permission -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -400,17 +399,18 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_04_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -436,46 +436,49 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, } def __init__( @@ -496,7 +499,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_04_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -506,7 +509,7 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_04_01.models.ImmutableStorageWithVersioning """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -548,81 +551,77 @@ class BlobInventoryPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified_time": {"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'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'BlobInventoryPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "BlobInventoryPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.BlobInventoryPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs): """ :keyword policy: The storage account blob inventory policy object. It is composed of policy rules. :paramtype policy: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicySchema """ - super(BlobInventoryPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.last_modified_time = None self.policy = policy -class BlobInventoryPolicyDefinition(msrest.serialization.Model): +class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. All required parameters must be populated in order to send to Azure. :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyFilter - :ivar format: Required. This is a required field, it specifies the format for the inventory - files. Known values are: "Csv", "Parquet". + :ivar format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". :vartype format: str or ~azure.mgmt.storage.v2021_04_01.models.Format - :ivar schedule: Required. This is a required field. This field is used to schedule an inventory - formation. Known values are: "Daily", "Weekly". + :ivar schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". :vartype schedule: str or ~azure.mgmt.storage.v2021_04_01.models.Schedule - :ivar object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Known values are: "Blob", "Container". + :ivar object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". :vartype object_type: str or ~azure.mgmt.storage.v2021_04_01.models.ObjectType - :ivar schema_fields: Required. This is a required field. This field specifies the fields and - properties of the object to be included in the inventory. The Schema field value 'Name' is - always required. The valid values for this field for the 'Blob' definition.objectType include - 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, + :ivar schema_fields: This is a required field. This field specifies the fields and properties + of the object to be included in the inventory. The Schema field value 'Name' is always + required. The valid values for this field for the 'Blob' definition.objectType include 'Name, + Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, AccessTierChangeTime, Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime'. The valid values for 'Container' definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl' are valid only for Hns enabled - accounts. + accounts. Required. :vartype schema_fields: list[str] """ _validation = { - 'format': {'required': True}, - 'schedule': {'required': True}, - 'object_type': {'required': True}, - 'schema_fields': {'required': True}, + "format": {"required": True}, + "schedule": {"required": True}, + "object_type": {"required": True}, + "schema_fields": {"required": True}, } _attribute_map = { - 'filters': {'key': 'filters', 'type': 'BlobInventoryPolicyFilter'}, - 'format': {'key': 'format', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'schema_fields': {'key': 'schemaFields', 'type': '[str]'}, + "filters": {"key": "filters", "type": "BlobInventoryPolicyFilter"}, + "format": {"key": "format", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "schema_fields": {"key": "schemaFields", "type": "[str]"}, } def __init__( @@ -638,16 +637,17 @@ def __init__( """ :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyFilter - :keyword format: Required. This is a required field, it specifies the format for the inventory - files. Known values are: "Csv", "Parquet". + :keyword format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". :paramtype format: str or ~azure.mgmt.storage.v2021_04_01.models.Format - :keyword schedule: Required. This is a required field. This field is used to schedule an - inventory formation. Known values are: "Daily", "Weekly". + :keyword schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". :paramtype schedule: str or ~azure.mgmt.storage.v2021_04_01.models.Schedule - :keyword object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Known values are: "Blob", "Container". + :keyword object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". :paramtype object_type: str or ~azure.mgmt.storage.v2021_04_01.models.ObjectType - :keyword schema_fields: Required. This is a required field. This field specifies the fields and + :keyword schema_fields: This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is always required. The valid values for this field for the 'Blob' definition.objectType include 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, @@ -656,10 +656,10 @@ def __init__( definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl' are valid only for Hns enabled - accounts. + accounts. Required. :paramtype schema_fields: list[str] """ - super(BlobInventoryPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.filters = filters self.format = format self.schedule = schedule @@ -667,7 +667,7 @@ def __init__( self.schema_fields = schema_fields -class BlobInventoryPolicyFilter(msrest.serialization.Model): +class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. For 'Blob' definition.objectType all filter properties are applicable, 'blobTypes' is required and others are optional. For 'Container' definition.objectType only prefixMatch is applicable and is optional. :ivar prefix_match: An array of strings for blob prefixes to be matched. @@ -687,10 +687,10 @@ class BlobInventoryPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'include_blob_versions': {'key': 'includeBlobVersions', 'type': 'bool'}, - 'include_snapshots': {'key': 'includeSnapshots', 'type': 'bool'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "include_blob_versions": {"key": "includeBlobVersions", "type": "bool"}, + "include_snapshots": {"key": "includeSnapshots", "type": "bool"}, } def __init__( @@ -718,42 +718,42 @@ def __init__( else it must be excluded. :paramtype include_snapshots: bool """ - super(BlobInventoryPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.include_blob_versions = include_blob_versions self.include_snapshots = include_snapshots -class BlobInventoryPolicyRule(msrest.serialization.Model): +class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Rule is enabled when set to true. + :ivar enabled: Rule is enabled when set to true. Required. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :ivar destination: Container name where blob inventory files are stored. Must be pre-created. + Required. :vartype destination: str - :ivar definition: Required. An object that defines the blob inventory policy rule. + :ivar definition: An object that defines the blob inventory policy rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyDefinition """ _validation = { - 'enabled': {'required': True}, - 'name': {'required': True}, - 'destination': {'required': True}, - 'definition': {'required': True}, + "enabled": {"required": True}, + "name": {"required": True}, + "destination": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'destination': {'key': 'destination', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'BlobInventoryPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "destination": {"key": "destination", "type": "str"}, + "definition": {"key": "definition", "type": "BlobInventoryPolicyDefinition"}, } def __init__( @@ -766,48 +766,48 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Rule is enabled when set to true. + :keyword enabled: Rule is enabled when set to true. Required. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :keyword destination: Container name where blob inventory files are stored. Must be + pre-created. Required. :paramtype destination: str - :keyword definition: Required. An object that defines the blob inventory policy rule. + :keyword definition: An object that defines the blob inventory policy rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyDefinition """ - super(BlobInventoryPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.destination = destination self.definition = definition -class BlobInventoryPolicySchema(msrest.serialization.Model): +class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Policy is enabled if set to true. + :ivar enabled: Policy is enabled if set to true. Required. :vartype enabled: bool - :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". + :ivar type: The valid value is Inventory. Required. "Inventory" :vartype type: str or ~azure.mgmt.storage.v2021_04_01.models.InventoryRuleType - :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :ivar rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :vartype rules: list[~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyRule] """ _validation = { - 'enabled': {'required': True}, - 'type': {'required': True}, - 'rules': {'required': True}, + "enabled": {"required": True}, + "type": {"required": True}, + "rules": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rules': {'key': 'rules', 'type': '[BlobInventoryPolicyRule]'}, + "enabled": {"key": "enabled", "type": "bool"}, + "type": {"key": "type", "type": "str"}, + "rules": {"key": "rules", "type": "[BlobInventoryPolicyRule]"}, } def __init__( @@ -819,99 +819,87 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Policy is enabled if set to true. + :keyword enabled: Policy is enabled if set to true. Required. :paramtype enabled: bool - :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". + :keyword type: The valid value is Inventory. Required. "Inventory" :paramtype type: str or ~azure.mgmt.storage.v2021_04_01.models.InventoryRuleType - :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :keyword rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :paramtype rules: list[~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyRule] """ - super(BlobInventoryPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.type = type self.rules = rules -class BlobRestoreParameters(msrest.serialization.Model): +class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. All required parameters must be populated in order to send to Azure. - :ivar time_to_restore: Required. Restore blob to the specified time. + :ivar time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime - :ivar blob_ranges: Required. Blob ranges to restore. + :ivar blob_ranges: Blob ranges to restore. Required. :vartype blob_ranges: list[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreRange] """ _validation = { - 'time_to_restore': {'required': True}, - 'blob_ranges': {'required': True}, + "time_to_restore": {"required": True}, + "blob_ranges": {"required": True}, } _attribute_map = { - 'time_to_restore': {'key': 'timeToRestore', 'type': 'iso-8601'}, - 'blob_ranges': {'key': 'blobRanges', 'type': '[BlobRestoreRange]'}, + "time_to_restore": {"key": "timeToRestore", "type": "iso-8601"}, + "blob_ranges": {"key": "blobRanges", "type": "[BlobRestoreRange]"}, } - def __init__( - self, - *, - time_to_restore: datetime.datetime, - blob_ranges: List["_models.BlobRestoreRange"], - **kwargs - ): + def __init__(self, *, time_to_restore: datetime.datetime, blob_ranges: List["_models.BlobRestoreRange"], **kwargs): """ - :keyword time_to_restore: Required. Restore blob to the specified time. + :keyword time_to_restore: Restore blob to the specified time. Required. :paramtype time_to_restore: ~datetime.datetime - :keyword blob_ranges: Required. Blob ranges to restore. + :keyword blob_ranges: Blob ranges to restore. Required. :paramtype blob_ranges: list[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreRange] """ - super(BlobRestoreParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_to_restore = time_to_restore self.blob_ranges = blob_ranges -class BlobRestoreRange(msrest.serialization.Model): +class BlobRestoreRange(_serialization.Model): """Blob range. All required parameters must be populated in order to send to Azure. - :ivar start_range: Required. Blob start range. This is inclusive. Empty means account start. + :ivar start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str - :ivar end_range: Required. Blob end range. This is exclusive. Empty means account end. + :ivar end_range: Blob end range. This is exclusive. Empty means account end. Required. :vartype end_range: str """ _validation = { - 'start_range': {'required': True}, - 'end_range': {'required': True}, + "start_range": {"required": True}, + "end_range": {"required": True}, } _attribute_map = { - 'start_range': {'key': 'startRange', 'type': 'str'}, - 'end_range': {'key': 'endRange', 'type': 'str'}, + "start_range": {"key": "startRange", "type": "str"}, + "end_range": {"key": "endRange", "type": "str"}, } - def __init__( - self, - *, - start_range: str, - end_range: str, - **kwargs - ): + def __init__(self, *, start_range: str, end_range: str, **kwargs): """ - :keyword start_range: Required. Blob start range. This is inclusive. Empty means account start. + :keyword start_range: Blob start range. This is inclusive. Empty means account start. Required. :paramtype start_range: str - :keyword end_range: Required. Blob end range. This is exclusive. Empty means account end. + :keyword end_range: Blob end range. This is exclusive. Empty means account end. Required. :paramtype end_range: str """ - super(BlobRestoreRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_range = start_range self.end_range = end_range -class BlobRestoreStatus(msrest.serialization.Model): +class BlobRestoreStatus(_serialization.Model): """Blob restore status. Variables are only populated by the server, and will be ignored when sending a request. @@ -919,7 +907,7 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", - "Complete", "Failed". + "Complete", and "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_04_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -930,33 +918,29 @@ class BlobRestoreStatus(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'restore_id': {'readonly': True}, - 'parameters': {'readonly': True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "restore_id": {"readonly": True}, + "parameters": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'restore_id': {'key': 'restoreId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'BlobRestoreParameters'}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "restore_id": {"key": "restoreId", "type": "str"}, + "parameters": {"key": "parameters", "type": "BlobRestoreParameters"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobRestoreStatus, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.failure_reason = None self.restore_id = None self.parameters = None -class BlobServiceItems(msrest.serialization.Model): +class BlobServiceItems(_serialization.Model): """BlobServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -966,24 +950,20 @@ class BlobServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobServiceProperties]'}, + "value": {"key": "value", "type": "[BlobServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class BlobServiceProperties(Resource): +class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attributes """The properties of a storage account’s Blob service. Variables are only populated by the server, and will be ignored when sending a request. @@ -1026,26 +1006,32 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'is_versioning_enabled': {'key': 'properties.isVersioningEnabled', 'type': 'bool'}, - 'automatic_snapshot_policy_enabled': {'key': 'properties.automaticSnapshotPolicyEnabled', 'type': 'bool'}, - 'change_feed': {'key': 'properties.changeFeed', 'type': 'ChangeFeed'}, - 'restore_policy': {'key': 'properties.restorePolicy', 'type': 'RestorePolicyProperties'}, - 'container_delete_retention_policy': {'key': 'properties.containerDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'last_access_time_tracking_policy': {'key': 'properties.lastAccessTimeTrackingPolicy', 'type': 'LastAccessTimeTrackingPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "is_versioning_enabled": {"key": "properties.isVersioningEnabled", "type": "bool"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, + "restore_policy": {"key": "properties.restorePolicy", "type": "RestorePolicyProperties"}, + "container_delete_retention_policy": { + "key": "properties.containerDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "last_access_time_tracking_policy": { + "key": "properties.lastAccessTimeTrackingPolicy", + "type": "LastAccessTimeTrackingPolicy", + }, } def __init__( @@ -1092,7 +1078,7 @@ def __init__( :paramtype last_access_time_tracking_policy: ~azure.mgmt.storage.v2021_04_01.models.LastAccessTimeTrackingPolicy """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.default_service_version = default_service_version @@ -1105,7 +1091,7 @@ def __init__( self.last_access_time_tracking_policy = last_access_time_tracking_policy -class ChangeFeed(msrest.serialization.Model): +class ChangeFeed(_serialization.Model): """The blob service properties for change feed events. :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. @@ -1117,21 +1103,15 @@ class ChangeFeed(msrest.serialization.Model): """ _validation = { - 'retention_in_days': {'maximum': 146000, 'minimum': 1}, + "retention_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_in_days': {'key': 'retentionInDays', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_in_days": {"key": "retentionInDays", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - retention_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, retention_in_days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. :paramtype enabled: bool @@ -1140,12 +1120,12 @@ def __init__( retention of the change feed. :paramtype retention_in_days: int """ - super(ChangeFeed, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.retention_in_days = retention_in_days -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1155,7 +1135,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_04_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1163,30 +1143,26 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CloudErrorAutoGenerated(msrest.serialization.Model): +class CloudErrorAutoGenerated(_serialization.Model): """An error response from the Storage service. :ivar error: An error response from the Storage service. @@ -1194,24 +1170,19 @@ class CloudErrorAutoGenerated(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'CloudErrorBodyAutoGenerated'}, + "error": {"key": "error", "type": "CloudErrorBodyAutoGenerated"}, } - def __init__( - self, - *, - error: Optional["_models.CloudErrorBodyAutoGenerated"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.CloudErrorBodyAutoGenerated"] = None, **kwargs): """ :keyword error: An error response from the Storage service. :paramtype error: ~azure.mgmt.storage.v2021_04_01.models.CloudErrorBodyAutoGenerated """ - super(CloudErrorAutoGenerated, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1228,10 +1199,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -1256,14 +1227,14 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2021_04_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CloudErrorBodyAutoGenerated(msrest.serialization.Model): +class CloudErrorBodyAutoGenerated(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1280,10 +1251,10 @@ class CloudErrorBodyAutoGenerated(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBodyAutoGenerated]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBodyAutoGenerated]"}, } def __init__( @@ -1308,50 +1279,50 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2021_04_01.models.CloudErrorBodyAutoGenerated] """ - super(CloudErrorBodyAutoGenerated, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2021_04_01.models.CorsRuleAllowedMethodsItem] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -1365,24 +1336,24 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2021_04_01.models.CorsRuleAllowedMethodsItem] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -1390,7 +1361,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -1399,31 +1370,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2021_04_01.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -1431,68 +1397,57 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DateAfterCreation(msrest.serialization.Model): +class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. All required parameters must be populated in order to send to Azure. - :ivar days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :vartype days_after_creation_greater_than: float """ _validation = { - 'days_after_creation_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, } - def __init__( - self, - *, - days_after_creation_greater_than: float, - **kwargs - ): + def __init__(self, *, days_after_creation_greater_than: float, **kwargs): """ - :keyword days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :paramtype days_after_creation_greater_than: float """ - super(DateAfterCreation, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_creation_greater_than = days_after_creation_greater_than -class DateAfterModification(msrest.serialization.Model): +class DateAfterModification(_serialization.Model): """Object to define the number of days after object last modification Or last access. Properties daysAfterModificationGreaterThan and daysAfterLastAccessTimeGreaterThan are mutually exclusive. :ivar days_after_modification_greater_than: Value indicating the age in days after last @@ -1505,13 +1460,13 @@ class DateAfterModification(msrest.serialization.Model): """ _validation = { - 'days_after_modification_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_last_access_time_greater_than': {'minimum': 0, 'multiple': 1}, + "days_after_modification_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_access_time_greater_than": {"minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'float'}, - 'days_after_last_access_time_greater_than': {'key': 'daysAfterLastAccessTimeGreaterThan', 'type': 'float'}, + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, + "days_after_last_access_time_greater_than": {"key": "daysAfterLastAccessTimeGreaterThan", "type": "float"}, } def __init__( @@ -1530,7 +1485,7 @@ def __init__( policy. :paramtype days_after_last_access_time_greater_than: float """ - super(DateAfterModification, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_modification_greater_than = days_after_modification_greater_than self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than @@ -1551,24 +1506,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class DeletedAccount(ProxyResource): @@ -1598,34 +1549,30 @@ class DeletedAccount(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'storage_account_resource_id': {'readonly': True}, - 'location': {'readonly': True}, - 'restore_reference': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'deletion_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'location': {'key': 'properties.location', 'type': 'str'}, - 'restore_reference': {'key': 'properties.restoreReference', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, - 'deletion_time': {'key': 'properties.deletionTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccount, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "storage_account_resource_id": {"readonly": True}, + "location": {"readonly": True}, + "restore_reference": {"readonly": True}, + "creation_time": {"readonly": True}, + "deletion_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "location": {"key": "properties.location", "type": "str"}, + "restore_reference": {"key": "properties.restoreReference", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "str"}, + "deletion_time": {"key": "properties.deletionTime", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_account_resource_id = None self.location = None self.restore_reference = None @@ -1633,7 +1580,7 @@ def __init__( self.deletion_time = None -class DeletedAccountListResult(msrest.serialization.Model): +class DeletedAccountListResult(_serialization.Model): """The response from the List Deleted Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1646,70 +1593,60 @@ class DeletedAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeletedAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeletedAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DeletedShare(msrest.serialization.Model): +class DeletedShare(_serialization.Model): """The deleted share to be restored. All required parameters must be populated in order to send to Azure. - :ivar deleted_share_name: Required. Required. Identify the name of the deleted share that will - be restored. + :ivar deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :vartype deleted_share_name: str - :ivar deleted_share_version: Required. Required. Identify the version of the deleted share that - will be restored. + :ivar deleted_share_version: Required. Identify the version of the deleted share that will be + restored. Required. :vartype deleted_share_version: str """ _validation = { - 'deleted_share_name': {'required': True}, - 'deleted_share_version': {'required': True}, + "deleted_share_name": {"required": True}, + "deleted_share_version": {"required": True}, } _attribute_map = { - 'deleted_share_name': {'key': 'deletedShareName', 'type': 'str'}, - 'deleted_share_version': {'key': 'deletedShareVersion', 'type': 'str'}, + "deleted_share_name": {"key": "deletedShareName", "type": "str"}, + "deleted_share_version": {"key": "deletedShareVersion", "type": "str"}, } - def __init__( - self, - *, - deleted_share_name: str, - deleted_share_version: str, - **kwargs - ): + def __init__(self, *, deleted_share_name: str, deleted_share_version: str, **kwargs): """ - :keyword deleted_share_name: Required. Required. Identify the name of the deleted share that - will be restored. + :keyword deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :paramtype deleted_share_name: str - :keyword deleted_share_version: Required. Required. Identify the version of the deleted share - that will be restored. + :keyword deleted_share_version: Required. Identify the version of the deleted share that will + be restored. Required. :paramtype deleted_share_version: str """ - super(DeletedShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.deleted_share_name = deleted_share_name self.deleted_share_version = deleted_share_version -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. @@ -1720,21 +1657,15 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled. :paramtype enabled: bool @@ -1742,12 +1673,12 @@ def __init__( minimum specified value can be 1 and the maximum value can be 365. :paramtype days: int """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -1757,38 +1688,32 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_04_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2021_04_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1800,15 +1725,15 @@ class Encryption(msrest.serialization.Model): """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, - 'encryption_identity': {'key': 'identity', 'type': 'EncryptionIdentity'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, + "encryption_identity": {"key": "identity", "type": "EncryptionIdentity"}, } def __init__( @@ -1824,9 +1749,9 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_04_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2021_04_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1836,7 +1761,7 @@ def __init__( :keyword encryption_identity: The identity to be used with service-side encryption at rest. :paramtype encryption_identity: ~azure.mgmt.storage.v2021_04_01.models.EncryptionIdentity """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption @@ -1844,7 +1769,7 @@ def __init__( self.encryption_identity = encryption_identity -class EncryptionIdentity(msrest.serialization.Model): +class EncryptionIdentity(_serialization.Model): """Encryption identity for the storage account. :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be @@ -1853,21 +1778,16 @@ class EncryptionIdentity(msrest.serialization.Model): """ _attribute_map = { - 'encryption_user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "encryption_user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - encryption_user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, encryption_user_assigned_identity: Optional[str] = None, **kwargs): """ :keyword encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be associated with server-side encryption on the storage account. :paramtype encryption_user_assigned_identity: str """ - super(EncryptionIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.encryption_user_assigned_identity = encryption_user_assigned_identity @@ -1885,11 +1805,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Known values are: "Enabled", "Disabled". + Disabled. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1906,23 +1826,23 @@ class EncryptionScope(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'EncryptionScopeKeyVaultProperties'}, - 'require_infrastructure_encryption': {'key': 'properties.requireInfrastructureEncryption', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "EncryptionScopeKeyVaultProperties"}, + "require_infrastructure_encryption": {"key": "properties.requireInfrastructureEncryption", "type": "bool"}, } def __init__( @@ -1936,11 +1856,11 @@ def __init__( ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Known values are: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -1950,7 +1870,7 @@ def __init__( applies a secondary layer of encryption with platform managed keys for data at rest. :paramtype require_infrastructure_encryption: bool """ - super(EncryptionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.state = state self.creation_time = None @@ -1959,7 +1879,7 @@ def __init__( self.require_infrastructure_encryption = require_infrastructure_encryption -class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): +class EncryptionScopeKeyVaultProperties(_serialization.Model): """The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. Variables are only populated by the server, and will be ignored when sending a request. @@ -1976,35 +1896,30 @@ class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_uri': {'key': 'keyUri', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_uri": {"key": "keyUri", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_uri: Optional[str] = None, **kwargs): """ :keyword key_uri: The object identifier for a key vault key object. When applied, the encryption scope will use the key referenced by the identifier to enable customer-managed key support on this encryption scope. :paramtype key_uri: str """ - super(EncryptionScopeKeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_uri = key_uri self.current_versioned_key_identifier = None self.last_key_rotation_timestamp = None -class EncryptionScopeListResult(msrest.serialization.Model): +class EncryptionScopeListResult(_serialization.Model): """List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. Variables are only populated by the server, and will be ignored when sending a request. @@ -2017,27 +1932,23 @@ class EncryptionScopeListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EncryptionScope]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EncryptionScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(EncryptionScopeListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -2051,26 +1962,22 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Known values are: "Service", "Account". + default service key is used. Known values are: "Service" and "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_04_01.models.KeyType """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'key_type': {'key': 'keyType', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "key_type": {"key": "keyType", "type": "str"}, } def __init__( - self, - *, - enabled: Optional[bool] = None, - key_type: Optional[Union[str, "_models.KeyType"]] = None, - **kwargs + self, *, enabled: Optional[bool] = None, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is @@ -2078,16 +1985,16 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Known values are: "Service", "Account". + that a default service key is used. Known values are: "Service" and "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_04_01.models.KeyType """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None self.key_type = key_type -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. :ivar blob: The encryption function of the blob storage service. @@ -2101,10 +2008,10 @@ class EncryptionServices(msrest.serialization.Model): """ _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -2126,14 +2033,14 @@ def __init__( :keyword queue: The encryption function of the queue storage service. :paramtype queue: ~azure.mgmt.storage.v2021_04_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = table self.queue = queue -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -2159,23 +2066,23 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, - 'microsoft_endpoints': {'key': 'microsoftEndpoints', 'type': 'StorageAccountMicrosoftEndpoints'}, - 'internet_endpoints': {'key': 'internetEndpoints', 'type': 'StorageAccountInternetEndpoints'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + "microsoft_endpoints": {"key": "microsoftEndpoints", "type": "StorageAccountMicrosoftEndpoints"}, + "internet_endpoints": {"key": "internetEndpoints", "type": "StorageAccountInternetEndpoints"}, } def __init__( @@ -2193,7 +2100,7 @@ def __init__( :paramtype internet_endpoints: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountInternetEndpoints """ - super(Endpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -2204,7 +2111,7 @@ def __init__( self.internet_endpoints = internet_endpoints -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the storage resource provider. :ivar error: Azure Storage Resource Provider error response body. @@ -2212,24 +2119,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure Storage Resource Provider error response body. :paramtype error: ~azure.mgmt.storage.v2021_04_01.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """Error response body contract. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -2241,17 +2143,11 @@ class ErrorResponseBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. @@ -2260,23 +2156,23 @@ def __init__( interface. :paramtype message: str """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ExtendedLocation(msrest.serialization.Model): +class ExtendedLocation(_serialization.Model): """The complex type of the extended location. :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Known values are: "EdgeZone". + :ivar type: The type of the extended location. "EdgeZone" :vartype type: str or ~azure.mgmt.storage.v2021_04_01.models.ExtendedLocationTypes """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -2289,15 +2185,15 @@ def __init__( """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Known values are: "EdgeZone". + :keyword type: The type of the extended location. "EdgeZone" :paramtype type: str or ~azure.mgmt.storage.v2021_04_01.models.ExtendedLocationTypes """ - super(ExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class FileServiceItems(msrest.serialization.Model): +class FileServiceItems(_serialization.Model): """FileServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -2307,20 +2203,16 @@ class FileServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileServiceProperties]'}, + "value": {"key": "value", "type": "[FileServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -2351,20 +2243,23 @@ class FileServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'share_delete_retention_policy': {'key': 'properties.shareDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'protocol_settings': {'key': 'properties.protocolSettings', 'type': 'ProtocolSettings'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "share_delete_retention_policy": { + "key": "properties.shareDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "protocol_settings": {"key": "properties.protocolSettings", "type": "ProtocolSettings"}, } def __init__( @@ -2386,14 +2281,14 @@ def __init__( :keyword protocol_settings: Protocol settings for file service. :paramtype protocol_settings: ~azure.mgmt.storage.v2021_04_01.models.ProtocolSettings """ - super(FileServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.share_delete_retention_policy = share_delete_retention_policy self.protocol_settings = protocol_settings -class FileShare(AzureEntityResource): +class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the file share, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -2416,10 +2311,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_04_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_04_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2431,7 +2326,7 @@ class FileShare(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2439,14 +2334,14 @@ class FileShare(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseStatus :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Known values are: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_04_01.models.SignedIdentifier] @@ -2456,48 +2351,48 @@ class FileShare(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2518,19 +2413,19 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_04_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_04_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_04_01.models.SignedIdentifier] """ - super(FileShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2551,7 +2446,7 @@ def __init__( self.snapshot_time = None -class FileShareItem(AzureEntityResource): +class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The file share properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -2574,10 +2469,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_04_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_04_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2589,7 +2484,7 @@ class FileShareItem(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2597,14 +2492,14 @@ class FileShareItem(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseStatus :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Known values are: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_04_01.models.SignedIdentifier] @@ -2614,48 +2509,48 @@ class FileShareItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2676,19 +2571,19 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_04_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_04_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_04_01.models.SignedIdentifier] """ - super(FileShareItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2709,7 +2604,7 @@ def __init__( self.snapshot_time = None -class FileShareItems(msrest.serialization.Model): +class FileShareItems(_serialization.Model): """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. Variables are only populated by the server, and will be ignored when sending a request. @@ -2722,27 +2617,23 @@ class FileShareItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileShareItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileShareItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2751,7 +2642,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_04_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2764,30 +2655,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2798,8 +2685,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_04_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2809,16 +2696,16 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( @@ -2829,8 +2716,8 @@ def __init__( **kwargs ): """ - :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_04_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2838,7 +2725,7 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.storage.v2021_04_01.models.UserAssignedIdentity] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type @@ -2864,7 +2751,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2875,21 +2762,24 @@ class ImmutabilityPolicy(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -2910,13 +2800,13 @@ def __init__( ExtendImmutabilityPolicy API. :paramtype allow_protected_append_writes: bool """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None self.allow_protected_append_writes = allow_protected_append_writes -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2929,7 +2819,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2940,17 +2830,20 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -2971,7 +2864,7 @@ def __init__( ExtendImmutabilityPolicy API. :paramtype allow_protected_append_writes: bool """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days @@ -2979,7 +2872,7 @@ def __init__( self.allow_protected_append_writes = allow_protected_append_writes -class ImmutableStorageWithVersioning(msrest.serialization.Model): +class ImmutableStorageWithVersioning(_serialization.Model): """Object level immutability properties of the container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2990,81 +2883,68 @@ class ImmutableStorageWithVersioning(msrest.serialization.Model): :ivar time_stamp: Returns the date and time the object level immutability was enabled. :vartype time_stamp: ~datetime.datetime :ivar migration_state: This property denotes the container level immutability to object level - immutability migration state. Known values are: "InProgress", "Completed". + immutability migration state. Known values are: "InProgress" and "Completed". :vartype migration_state: str or ~azure.mgmt.storage.v2021_04_01.models.MigrationState """ _validation = { - 'time_stamp': {'readonly': True}, - 'migration_state': {'readonly': True}, + "time_stamp": {"readonly": True}, + "migration_state": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'migration_state': {'key': 'migrationState', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "migration_state": {"key": "migrationState", "type": "str"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: This is an immutable property, when set to true it enables object level immutability at the container level. :paramtype enabled: bool """ - super(ImmutableStorageWithVersioning, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.time_stamp = None self.migration_state = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyCreationTime(msrest.serialization.Model): +class KeyCreationTime(_serialization.Model): """Storage account keys creation time. :ivar key1: @@ -3074,60 +2954,49 @@ class KeyCreationTime(msrest.serialization.Model): """ _attribute_map = { - 'key1': {'key': 'key1', 'type': 'iso-8601'}, - 'key2': {'key': 'key2', 'type': 'iso-8601'}, + "key1": {"key": "key1", "type": "iso-8601"}, + "key2": {"key": "key2", "type": "iso-8601"}, } - def __init__( - self, - *, - key1: Optional[datetime.datetime] = None, - key2: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, key1: Optional[datetime.datetime] = None, key2: Optional[datetime.datetime] = None, **kwargs): """ :keyword key1: :paramtype key1: ~datetime.datetime :keyword key2: :paramtype key2: ~datetime.datetime """ - super(KeyCreationTime, self).__init__(**kwargs) + super().__init__(**kwargs) self.key1 = key1 self.key2 = key2 -class KeyPolicy(msrest.serialization.Model): +class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar key_expiration_period_in_days: Required. The key expiration period in days. + :ivar key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int """ _validation = { - 'key_expiration_period_in_days': {'required': True}, + "key_expiration_period_in_days": {"required": True}, } _attribute_map = { - 'key_expiration_period_in_days': {'key': 'keyExpirationPeriodInDays', 'type': 'int'}, + "key_expiration_period_in_days": {"key": "keyExpirationPeriodInDays", "type": "int"}, } - def __init__( - self, - *, - key_expiration_period_in_days: int, - **kwargs - ): + def __init__(self, *, key_expiration_period_in_days: int, **kwargs): """ - :keyword key_expiration_period_in_days: Required. The key expiration period in days. + :keyword key_expiration_period_in_days: The key expiration period in days. Required. :paramtype key_expiration_period_in_days: int """ - super(KeyPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_expiration_period_in_days = key_expiration_period_in_days -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. Variables are only populated by the server, and will be ignored when sending a request. @@ -3146,16 +3015,16 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } def __init__( @@ -3174,7 +3043,7 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri @@ -3182,15 +3051,15 @@ def __init__( self.last_key_rotation_timestamp = None -class LastAccessTimeTrackingPolicy(msrest.serialization.Model): +class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. All required parameters must be populated in order to send to Azure. - :ivar enable: Required. When set to true last access time based tracking is enabled. + :ivar enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Known values are: "AccessTimeTracking". + read only. "AccessTimeTracking" :vartype name: str or ~azure.mgmt.storage.v2021_04_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3202,14 +3071,14 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): """ _validation = { - 'enable': {'required': True}, + "enable": {"required": True}, } _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tracking_granularity_in_days': {'key': 'trackingGranularityInDays', 'type': 'int'}, - 'blob_type': {'key': 'blobType', 'type': '[str]'}, + "enable": {"key": "enable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "tracking_granularity_in_days": {"key": "trackingGranularityInDays", "type": "int"}, + "blob_type": {"key": "blobType", "type": "[str]"}, } def __init__( @@ -3222,10 +3091,10 @@ def __init__( **kwargs ): """ - :keyword enable: Required. When set to true last access time based tracking is enabled. + :keyword enable: When set to true last access time based tracking is enabled. Required. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Known values are: "AccessTimeTracking". + currently read only. "AccessTimeTracking" :paramtype name: str or ~azure.mgmt.storage.v2021_04_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3235,20 +3104,20 @@ def __init__( supported value. This field is currently read only. :paramtype blob_type: list[str] """ - super(LastAccessTimeTrackingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enable = enable self.name = name self.tracking_granularity_in_days = tracking_granularity_in_days self.blob_type = blob_type -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3264,15 +3133,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -3286,8 +3155,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3301,7 +3170,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -3309,7 +3178,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -3320,17 +3189,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -3338,18 +3201,18 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LeaseShareRequest(msrest.serialization.Model): +class LeaseShareRequest(_serialization.Model): """Lease Share request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3365,15 +3228,15 @@ class LeaseShareRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -3387,8 +3250,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3402,7 +3265,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseShareRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -3410,7 +3273,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseShareResponse(msrest.serialization.Model): +class LeaseShareResponse(_serialization.Model): """Lease Share response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -3421,17 +3284,11 @@ class LeaseShareResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the share, or to renew, change, or release the lease. @@ -3439,12 +3296,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseShareResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3456,38 +3313,33 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, } - def __init__( - self, - *, - tags: List[str], - **kwargs - ): + def __init__(self, *, tags: List[str], **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3497,35 +3349,30 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2021_04_01.models.TagProperty] """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, } - def __init__( - self, - *, - tags: Optional[List["_models.TagProperty"]] = None, - **kwargs - ): + def __init__(self, *, tags: Optional[List["_models.TagProperty"]] = None, **kwargs): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2021_04_01.models.TagProperty] """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3535,24 +3382,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListBlobInventoryPolicy(msrest.serialization.Model): +class ListBlobInventoryPolicy(_serialization.Model): """List of blob inventory policies returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3562,24 +3405,20 @@ class ListBlobInventoryPolicy(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobInventoryPolicy]'}, + "value": {"key": "value", "type": "[BlobInventoryPolicy]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListBlobInventoryPolicy, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -3609,17 +3448,18 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_04_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_04_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3645,46 +3485,49 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, } def __init__( @@ -3705,7 +3548,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_04_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -3715,7 +3558,7 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_04_01.models.ImmutableStorageWithVersioning """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -3735,7 +3578,7 @@ def __init__( self.immutable_storage_with_versioning = immutable_storage_with_versioning -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. Variables are only populated by the server, and will be ignored when sending a request. @@ -3748,22 +3591,18 @@ class ListContainerItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListContainerItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3786,33 +3625,28 @@ class ListQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(ListQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata -class ListQueueResource(msrest.serialization.Model): +class ListQueueResource(_serialization.Model): """Response schema. Contains list of queues returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3824,27 +3658,23 @@ class ListQueueResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListQueueServices(msrest.serialization.Model): +class ListQueueServices(_serialization.Model): """ListQueueServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -3854,24 +3684,20 @@ class ListQueueServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueServiceProperties]'}, + "value": {"key": "value", "type": "[QueueServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3881,24 +3707,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class ListTableResource(msrest.serialization.Model): +class ListTableResource(_serialization.Model): """Response schema. Contains list of tables returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3910,27 +3732,23 @@ class ListTableResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Table]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Table]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListTableServices(msrest.serialization.Model): +class ListTableServices(_serialization.Model): """ListTableServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -3940,20 +3758,16 @@ class ListTableServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TableServiceProperties]'}, + "value": {"key": "value", "type": "[TableServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -3978,37 +3792,32 @@ class ManagementPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.ManagementPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :paramtype policy: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicySchema """ - super(ManagementPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.policy = policy -class ManagementPolicyAction(msrest.serialization.Model): +class ManagementPolicyAction(_serialization.Model): """Actions are applied to the filtered blobs when the execution condition is met. :ivar base_blob: The management policy action for base blob. @@ -4020,9 +3829,9 @@ class ManagementPolicyAction(msrest.serialization.Model): """ _attribute_map = { - 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, - 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, - 'version': {'key': 'version', 'type': 'ManagementPolicyVersion'}, + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, + "version": {"key": "version", "type": "ManagementPolicyVersion"}, } def __init__( @@ -4041,13 +3850,13 @@ def __init__( :keyword version: The management policy action for version. :paramtype version: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyVersion """ - super(ManagementPolicyAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_blob = base_blob self.snapshot = snapshot self.version = version -class ManagementPolicyBaseBlob(msrest.serialization.Model): +class ManagementPolicyBaseBlob(_serialization.Model): """Management policy action for base blob. :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot @@ -4064,10 +3873,10 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, - 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, - 'enable_auto_tier_to_hot_from_cool': {'key': 'enableAutoTierToHotFromCool', 'type': 'bool'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, + "enable_auto_tier_to_hot_from_cool": {"key": "enableAutoTierToHotFromCool", "type": "bool"}, } def __init__( @@ -4093,31 +3902,31 @@ def __init__( tierToCool.daysAfterLastAccessTimeGreaterThan. :paramtype enable_auto_tier_to_hot_from_cool: bool """ - super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool -class ManagementPolicyDefinition(msrest.serialization.Model): +class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. All required parameters must be populated in order to send to Azure. - :ivar actions: Required. An object that defines the action set. + :ivar actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyAction :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyFilter """ _validation = { - 'actions': {'required': True}, + "actions": {"required": True}, } _attribute_map = { - 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, - 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, } def __init__( @@ -4128,25 +3937,25 @@ def __init__( **kwargs ): """ - :keyword actions: Required. An object that defines the action set. + :keyword actions: An object that defines the action set. Required. :paramtype actions: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyAction :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyFilter """ - super(ManagementPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.filters = filters -class ManagementPolicyFilter(msrest.serialization.Model): +class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :ivar blob_types: An array of predefined enum values. Currently blockBlob supports all tiering + and delete actions. Only delete actions are supported for appendBlob. Required. :vartype blob_types: list[str] :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. @@ -4154,13 +3963,13 @@ class ManagementPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'blob_index_match': {'key': 'blobIndexMatch', 'type': '[TagFilter]'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "blob_index_match": {"key": "blobIndexMatch", "type": "[TagFilter]"}, } def __init__( @@ -4174,46 +3983,46 @@ def __init__( """ :keyword prefix_match: An array of strings for prefixes to be match. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :keyword blob_types: An array of predefined enum values. Currently blockBlob supports all + tiering and delete actions. Only delete actions are supported for appendBlob. Required. :paramtype blob_types: list[str] :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. :paramtype blob_index_match: list[~azure.mgmt.storage.v2021_04_01.models.TagFilter] """ - super(ManagementPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.blob_index_match = blob_index_match -class ManagementPolicyRule(msrest.serialization.Model): +class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. :ivar enabled: Rule is enabled if set to true. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" :vartype type: str or ~azure.mgmt.storage.v2021_04_01.models.RuleType - :ivar definition: Required. An object that defines the Lifecycle rule. + :ivar definition: An object that defines the Lifecycle rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyDefinition """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - 'definition': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, } def __init__( @@ -4228,55 +4037,52 @@ def __init__( """ :keyword enabled: Rule is enabled if set to true. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" :paramtype type: str or ~azure.mgmt.storage.v2021_04_01.models.RuleType - :keyword definition: Required. An object that defines the Lifecycle rule. + :keyword definition: An object that defines the Lifecycle rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyDefinition """ - super(ManagementPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.type = type self.definition = definition -class ManagementPolicySchema(msrest.serialization.Model): +class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. All required parameters must be populated in order to send to Azure. - :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :vartype rules: list[~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyRule] """ _validation = { - 'rules': {'required': True}, + "rules": {"required": True}, } _attribute_map = { - 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, } - def __init__( - self, - *, - rules: List["_models.ManagementPolicyRule"], - **kwargs - ): + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): """ - :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :paramtype rules: list[~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyRule] """ - super(ManagementPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.rules = rules -class ManagementPolicySnapShot(msrest.serialization.Model): +class ManagementPolicySnapShot(_serialization.Model): """Management policy action for snapshot. :ivar tier_to_cool: The function to tier blob snapshot to cool storage. Support blob snapshot @@ -4290,9 +4096,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -4313,13 +4119,13 @@ def __init__( :keyword delete: The function to delete the blob snapshot. :paramtype delete: ~azure.mgmt.storage.v2021_04_01.models.DateAfterCreation """ - super(ManagementPolicySnapShot, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class ManagementPolicyVersion(msrest.serialization.Model): +class ManagementPolicyVersion(_serialization.Model): """Management policy action for blob version. :ivar tier_to_cool: The function to tier blob version to cool storage. Support blob version @@ -4333,9 +4139,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -4356,13 +4162,13 @@ def __init__( :keyword delete: The function to delete the blob version. :paramtype delete: ~azure.mgmt.storage.v2021_04_01.models.DateAfterCreation """ - super(ManagementPolicyVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -4386,15 +4192,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -4431,7 +4237,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -4443,7 +4249,7 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class Multichannel(msrest.serialization.Model): +class Multichannel(_serialization.Model): """Multichannel setting. Applies to Premium FileStorage only. :ivar enabled: Indicates whether multichannel is enabled. @@ -4451,32 +4257,27 @@ class Multichannel(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Indicates whether multichannel is enabled. :paramtype enabled: bool """ - super(Multichannel, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_04_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_04_01.models.ResourceAccessRule] @@ -4484,28 +4285,28 @@ class NetworkRuleSet(msrest.serialization.Model): :vartype virtual_network_rules: list[~azure.mgmt.storage.v2021_04_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_04_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2021_04_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'resource_access_rules': {'key': 'resourceAccessRules', 'type': '[ResourceAccessRule]'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "resource_access_rules": {"key": "resourceAccessRules", "type": "[ResourceAccessRule]"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, @@ -4515,7 +4316,7 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_04_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4525,11 +4326,11 @@ def __init__( list[~azure.mgmt.storage.v2021_04_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_04_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2021_04_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.resource_access_rules = resource_access_rules self.virtual_network_rules = virtual_network_rules @@ -4537,7 +4338,7 @@ def __init__( self.default_action = default_action -class ObjectReplicationPolicies(msrest.serialization.Model): +class ObjectReplicationPolicies(_serialization.Model): """List storage account object replication policies. :ivar value: The replication policy between two storage accounts. @@ -4545,20 +4346,15 @@ class ObjectReplicationPolicies(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ObjectReplicationPolicy]'}, + "value": {"key": "value", "type": "[ObjectReplicationPolicy]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ObjectReplicationPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs): """ :keyword value: The replication policy between two storage accounts. :paramtype value: list[~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy] """ - super(ObjectReplicationPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4590,22 +4386,22 @@ class ObjectReplicationPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_id': {'readonly': True}, - 'enabled_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_id": {"readonly": True}, + "enabled_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, - 'enabled_time': {'key': 'properties.enabledTime', 'type': 'iso-8601'}, - 'source_account': {'key': 'properties.sourceAccount', 'type': 'str'}, - 'destination_account': {'key': 'properties.destinationAccount', 'type': 'str'}, - 'rules': {'key': 'properties.rules', 'type': '[ObjectReplicationPolicyRule]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "enabled_time": {"key": "properties.enabledTime", "type": "iso-8601"}, + "source_account": {"key": "properties.sourceAccount", "type": "str"}, + "destination_account": {"key": "properties.destinationAccount", "type": "str"}, + "rules": {"key": "properties.rules", "type": "[ObjectReplicationPolicyRule]"}, } def __init__( @@ -4626,7 +4422,7 @@ def __init__( :keyword rules: The storage account object replication rules. :paramtype rules: list[~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicyRule] """ - super(ObjectReplicationPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_id = None self.enabled_time = None self.source_account = source_account @@ -4634,7 +4430,7 @@ def __init__( self.rules = rules -class ObjectReplicationPolicyFilter(msrest.serialization.Model): +class ObjectReplicationPolicyFilter(_serialization.Model): """Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the filter. If multiple filters are defined, a logical AND is performed on all filters. :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin @@ -4646,17 +4442,11 @@ class ObjectReplicationPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'min_creation_time': {'key': 'minCreationTime', 'type': 'str'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "min_creation_time": {"key": "minCreationTime", "type": "str"}, } - def __init__( - self, - *, - prefix_match: Optional[List[str]] = None, - min_creation_time: Optional[str] = None, - **kwargs - ): + def __init__(self, *, prefix_match: Optional[List[str]] = None, min_creation_time: Optional[str] = None, **kwargs): """ :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. @@ -4665,12 +4455,12 @@ def __init__( It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. :paramtype min_creation_time: str """ - super(ObjectReplicationPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.min_creation_time = min_creation_time -class ObjectReplicationPolicyRule(msrest.serialization.Model): +class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. All required parameters must be populated in order to send to Azure. @@ -4678,24 +4468,24 @@ class ObjectReplicationPolicyRule(msrest.serialization.Model): :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :vartype rule_id: str - :ivar source_container: Required. Required. Source container name. + :ivar source_container: Required. Source container name. Required. :vartype source_container: str - :ivar destination_container: Required. Required. Destination container name. + :ivar destination_container: Required. Destination container name. Required. :vartype destination_container: str :ivar filters: Optional. An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicyFilter """ _validation = { - 'source_container': {'required': True}, - 'destination_container': {'required': True}, + "source_container": {"required": True}, + "destination_container": {"required": True}, } _attribute_map = { - 'rule_id': {'key': 'ruleId', 'type': 'str'}, - 'source_container': {'key': 'sourceContainer', 'type': 'str'}, - 'destination_container': {'key': 'destinationContainer', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': 'ObjectReplicationPolicyFilter'}, + "rule_id": {"key": "ruleId", "type": "str"}, + "source_container": {"key": "sourceContainer", "type": "str"}, + "destination_container": {"key": "destinationContainer", "type": "str"}, + "filters": {"key": "filters", "type": "ObjectReplicationPolicyFilter"}, } def __init__( @@ -4711,21 +4501,21 @@ def __init__( :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :paramtype rule_id: str - :keyword source_container: Required. Required. Source container name. + :keyword source_container: Required. Source container name. Required. :paramtype source_container: str - :keyword destination_container: Required. Required. Destination container name. + :keyword destination_container: Required. Destination container name. Required. :paramtype destination_container: str :keyword filters: Optional. An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicyFilter """ - super(ObjectReplicationPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.rule_id = rule_id self.source_container = source_container self.destination_container = destination_container self.filters = filters -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -4739,10 +4529,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -4764,14 +4554,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2021_04_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -4785,10 +4575,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -4810,14 +4600,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -4825,24 +4615,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2021_04_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -4852,20 +4637,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -4889,25 +4670,28 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_04_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -4925,13 +4709,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.storage.v2021_04_01.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """List of private endpoint connection associated with the specified storage account. :ivar value: Array of private endpoint connections. @@ -4939,20 +4723,15 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4978,39 +4757,34 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "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, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): """ :keyword required_zone_names: The private link resource Private link DNS zone name. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. @@ -5018,28 +4792,23 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.storage.v2021_04_01.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", and "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -5050,9 +4819,9 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'action_required': {'key': 'actionRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "action_required": {"key": "actionRequired", "type": "str"}, } def __init__( @@ -5065,7 +4834,7 @@ def __init__( ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", and "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -5074,13 +4843,13 @@ def __init__( updates on the consumer. :paramtype action_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.action_required = action_required -class ProtocolSettings(msrest.serialization.Model): +class ProtocolSettings(_serialization.Model): """Protocol settings for file service. :ivar smb: Setting for SMB protocol. @@ -5088,20 +4857,15 @@ class ProtocolSettings(msrest.serialization.Model): """ _attribute_map = { - 'smb': {'key': 'smb', 'type': 'SmbSetting'}, + "smb": {"key": "smb", "type": "SmbSetting"}, } - def __init__( - self, - *, - smb: Optional["_models.SmbSetting"] = None, - **kwargs - ): + def __init__(self, *, smb: Optional["_models.SmbSetting"] = None, **kwargs): """ :keyword smb: Setting for SMB protocol. :paramtype smb: ~azure.mgmt.storage.v2021_04_01.models.SmbSetting """ - super(ProtocolSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.smb = smb @@ -5125,35 +4889,30 @@ class QueueServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Queue service. :paramtype cors: ~azure.mgmt.storage.v2021_04_01.models.CorsRules """ - super(QueueServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class ResourceAccessRule(msrest.serialization.Model): +class ResourceAccessRule(_serialization.Model): """Resource Access Rule. :ivar tenant_id: Tenant Id. @@ -5163,36 +4922,30 @@ class ResourceAccessRule(msrest.serialization.Model): """ _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__( - self, - *, - tenant_id: Optional[str] = None, - resource_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tenant_id: Optional[str] = None, resource_id: Optional[str] = None, **kwargs): """ :keyword tenant_id: Tenant Id. :paramtype tenant_id: str :keyword resource_id: Resource Id. :paramtype resource_id: str """ - super(ResourceAccessRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.tenant_id = tenant_id self.resource_id = resource_id -class RestorePolicyProperties(msrest.serialization.Model): +class RestorePolicyProperties(_serialization.Model): """The blob service properties for blob restore policy. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Blob restore is enabled if set to true. + :ivar enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool :ivar days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. @@ -5204,41 +4957,35 @@ class RestorePolicyProperties(msrest.serialization.Model): """ _validation = { - 'enabled': {'required': True}, - 'days': {'maximum': 365, 'minimum': 1}, - 'last_enabled_time': {'readonly': True}, - 'min_restore_time': {'readonly': True}, + "enabled": {"required": True}, + "days": {"maximum": 365, "minimum": 1}, + "last_enabled_time": {"readonly": True}, + "min_restore_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'min_restore_time': {'key': 'minRestoreTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "min_restore_time": {"key": "minRestoreTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: bool, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: bool, days: Optional[int] = None, **kwargs): """ - :keyword enabled: Required. Blob restore is enabled if set to true. + :keyword enabled: Blob restore is enabled if set to true. Required. :paramtype enabled: bool :keyword days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. :paramtype days: int """ - super(RestorePolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days self.last_enabled_time = None self.min_restore_time = None -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -5251,45 +4998,40 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_04_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_04_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class RoutingPreference(msrest.serialization.Model): +class RoutingPreference(_serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_04_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5300,9 +5042,9 @@ class RoutingPreference(msrest.serialization.Model): """ _attribute_map = { - 'routing_choice': {'key': 'routingChoice', 'type': 'str'}, - 'publish_microsoft_endpoints': {'key': 'publishMicrosoftEndpoints', 'type': 'bool'}, - 'publish_internet_endpoints': {'key': 'publishInternetEndpoints', 'type': 'bool'}, + "routing_choice": {"key": "routingChoice", "type": "str"}, + "publish_microsoft_endpoints": {"key": "publishMicrosoftEndpoints", "type": "bool"}, + "publish_internet_endpoints": {"key": "publishInternetEndpoints", "type": "bool"}, } def __init__( @@ -5315,7 +5057,7 @@ def __init__( ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_04_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5324,72 +5066,66 @@ def __init__( storage endpoints are to be published. :paramtype publish_internet_endpoints: bool """ - super(RoutingPreference, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_choice = routing_choice self.publish_microsoft_endpoints = publish_microsoft_endpoints self.publish_internet_endpoints = publish_internet_endpoints -class SasPolicy(msrest.serialization.Model): +class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :ivar sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str - :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :ivar expiration_action: The SAS expiration action. Can only be Log. "Log" :vartype expiration_action: str or ~azure.mgmt.storage.v2021_04_01.models.ExpirationAction """ _validation = { - 'sas_expiration_period': {'required': True}, - 'expiration_action': {'required': True}, + "sas_expiration_period": {"required": True}, + "expiration_action": {"required": True}, } _attribute_map = { - 'sas_expiration_period': {'key': 'sasExpirationPeriod', 'type': 'str'}, - 'expiration_action': {'key': 'expirationAction', 'type': 'str'}, + "sas_expiration_period": {"key": "sasExpirationPeriod", "type": "str"}, + "expiration_action": {"key": "expirationAction", "type": "str"}, } def __init__( - self, - *, - sas_expiration_period: str, - expiration_action: Union[str, "_models.ExpirationAction"] = "Log", - **kwargs + self, *, sas_expiration_period: str, expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs ): """ - :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :keyword sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :paramtype sas_expiration_period: str - :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :keyword expiration_action: The SAS expiration action. Can only be Log. "Log" :paramtype expiration_action: str or ~azure.mgmt.storage.v2021_04_01.models.ExpirationAction """ - super(SasPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_expiration_period = sas_expiration_period self.expiration_action = expiration_action -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2021_04_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_04_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_04_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -5421,29 +5157,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, - } - - _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, + } + + _attribute_map = { + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -5470,20 +5206,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_04_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_04_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_04_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -5514,7 +5251,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -5535,7 +5272,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -5544,25 +5281,20 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2021_04_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class SignedIdentifier(msrest.serialization.Model): +class SignedIdentifier(_serialization.Model): """SignedIdentifier. :ivar id: An unique identifier of the stored access policy. @@ -5572,14 +5304,14 @@ class SignedIdentifier(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'access_policy': {'key': 'accessPolicy', 'type': 'AccessPolicy'}, + "id": {"key": "id", "type": "str"}, + "access_policy": {"key": "accessPolicy", "type": "AccessPolicy"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin access_policy: Optional["_models.AccessPolicy"] = None, **kwargs ): @@ -5589,57 +5321,52 @@ def __init__( :keyword access_policy: Access policy. :paramtype access_policy: ~azure.mgmt.storage.v2021_04_01.models.AccessPolicy """ - super(SignedIdentifier, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.access_policy = access_policy -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_04_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_04_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_04_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -5652,45 +5379,41 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Storage SKU and its properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_04_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_04_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -5704,22 +5427,22 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -5730,16 +5453,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_04_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2021_04_01.models.Restriction] """ - super(SkuInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -5749,7 +5472,7 @@ def __init__( self.restrictions = restrictions -class SmbSetting(msrest.serialization.Model): +class SmbSetting(_serialization.Model): """Setting for SMB protocol. :ivar multichannel: Multichannel setting. Applies to Premium FileStorage only. @@ -5769,11 +5492,11 @@ class SmbSetting(msrest.serialization.Model): """ _attribute_map = { - 'multichannel': {'key': 'multichannel', 'type': 'Multichannel'}, - 'versions': {'key': 'versions', 'type': 'str'}, - 'authentication_methods': {'key': 'authenticationMethods', 'type': 'str'}, - 'kerberos_ticket_encryption': {'key': 'kerberosTicketEncryption', 'type': 'str'}, - 'channel_encryption': {'key': 'channelEncryption', 'type': 'str'}, + "multichannel": {"key": "multichannel", "type": "Multichannel"}, + "versions": {"key": "versions", "type": "str"}, + "authentication_methods": {"key": "authenticationMethods", "type": "str"}, + "kerberos_ticket_encryption": {"key": "kerberosTicketEncryption", "type": "str"}, + "channel_encryption": {"key": "channelEncryption", "type": "str"}, } def __init__( @@ -5802,7 +5525,7 @@ def __init__( AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. :paramtype channel_encryption: str """ - super(SmbSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.multichannel = multichannel self.versions = versions self.authentication_methods = authentication_methods @@ -5825,46 +5548,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -5879,21 +5596,21 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_04_01.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_04_01.models.Identity :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_04_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_04_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -5902,7 +5619,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_04_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -5914,7 +5631,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_04_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -5934,7 +5651,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2021_04_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -5952,7 +5669,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -5969,7 +5686,7 @@ class StorageAccount(TrackedResource): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -5984,77 +5701,83 @@ class StorageAccount(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'sas_policy': {'readonly': True}, - 'key_policy': {'readonly': True}, - 'key_creation_time': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'blob_restore_status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'key_creation_time': {'key': 'properties.keyCreationTime', 'type': 'KeyCreationTime'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'blob_restore_status': {'key': 'properties.blobRestoreStatus', 'type': 'BlobRestoreStatus'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "sas_policy": {"readonly": True}, + "key_policy": {"readonly": True}, + "key_creation_time": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "blob_restore_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "key_creation_time": {"key": "properties.keyCreationTime", "type": "KeyCreationTime"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "blob_restore_status": {"key": "properties.blobRestoreStatus", "type": "BlobRestoreStatus"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -6074,9 +5797,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_04_01.models.Identity @@ -6092,7 +5815,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6103,7 +5826,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6116,7 +5839,7 @@ def __init__( The default interpretation is true for this property. :paramtype allow_cross_tenant_replication: bool """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -6153,69 +5876,64 @@ def __init__( self.allow_cross_tenant_replication = allow_cross_tenant_replication -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_04_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str :ivar extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :vartype extended_location: ~azure.mgmt.storage.v2021_04_01.models.ExtendedLocation - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_04_01.models.Identity @@ -6233,7 +5951,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_04_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6245,7 +5963,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6256,7 +5974,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6271,34 +5989,37 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, } def __init__( @@ -6329,24 +6050,24 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2021_04_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str :keyword extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :paramtype extended_location: ~azure.mgmt.storage.v2021_04_01.models.ExtendedLocation - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_04_01.models.Identity @@ -6364,7 +6085,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_04_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6376,7 +6097,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6387,7 +6108,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6400,7 +6121,7 @@ def __init__( The default interpretation is true for this property. :paramtype allow_cross_tenant_replication: bool """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -6425,7 +6146,7 @@ def __init__( self.allow_cross_tenant_replication = allow_cross_tenant_replication -class StorageAccountInternetEndpoints(msrest.serialization.Model): +class StorageAccountInternetEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -6441,33 +6162,29 @@ class StorageAccountInternetEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountInternetEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.file = None self.web = None self.dfs = None -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -6477,40 +6194,36 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_04_01.models.KeyPermission :ivar creation_time: Creation time of the key, in round trip date format. :vartype creation_time: ~datetime.datetime """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, - 'creation_time': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, + "creation_time": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None self.creation_time = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -6521,24 +6234,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -6551,27 +6260,23 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): +class StorageAccountMicrosoftEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -6591,30 +6296,26 @@ class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountMicrosoftEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -6623,55 +6324,50 @@ def __init__( self.dfs = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2, kerb1, kerb2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2, kerb1, kerb2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2021_04_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_04_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6685,7 +6381,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar key_policy: KeyPolicy assigned to the storage account. :vartype key_policy: ~azure.mgmt.storage.v2021_04_01.models.KeyPolicy :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6696,7 +6392,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_04_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6707,7 +6403,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6720,24 +6416,27 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, } def __init__( @@ -6768,16 +6467,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2021_04_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_04_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_04_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6791,7 +6490,7 @@ def __init__( :keyword key_policy: KeyPolicy assigned to the storage account. :paramtype key_policy: ~azure.mgmt.storage.v2021_04_01.models.KeyPolicy :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_04_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6803,7 +6502,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_04_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_04_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6814,7 +6513,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_04_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6825,7 +6524,7 @@ def __init__( The default interpretation is true for this property. :paramtype allow_cross_tenant_replication: bool """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -6868,36 +6567,31 @@ class StorageQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'approximate_message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "approximate_message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'approximate_message_count': {'key': 'properties.approximateMessageCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "approximate_message_count": {"key": "properties.approximateMessageCount", "type": "int"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(StorageQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata self.approximate_message_count = None -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -6907,49 +6601,45 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuInformation]'}, + "value": {"key": "value", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_04_01.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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_04_01.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'}, + "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__( @@ -6967,19 +6657,19 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_04_01.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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_04_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -7006,26 +6696,22 @@ class Table(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'table_name': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "table_name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Table, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.table_name = None @@ -7049,86 +6735,74 @@ class TableServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Table service. :paramtype cors: ~azure.mgmt.storage.v2021_04_01.models.CorsRules """ - super(TableServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class TagFilter(msrest.serialization.Model): +class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. All required parameters must be populated in order to send to Azure. - :ivar name: Required. This is the filter tag name, it can have 1 - 128 characters. + :ivar name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str - :ivar op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :ivar op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :vartype op: str - :ivar value: Required. This is the filter tag value field used for tag based filtering, it can - have 0 - 256 characters. + :ivar value: This is the filter tag value field used for tag based filtering, it can have 0 - + 256 characters. Required. :vartype value: str """ _validation = { - 'name': {'required': True, 'max_length': 128, 'min_length': 1}, - 'op': {'required': True}, - 'value': {'required': True, 'max_length': 256, 'min_length': 0}, + "name": {"required": True, "max_length": 128, "min_length": 1}, + "op": {"required": True}, + "value": {"required": True, "max_length": 256}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'op': {'key': 'op', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "op": {"key": "op", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - op: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, op: str, value: str, **kwargs): """ - :keyword name: Required. This is the filter tag name, it can have 1 - 128 characters. + :keyword name: This is the filter tag name, it can have 1 - 128 characters. Required. :paramtype name: str - :keyword op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :keyword op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :paramtype op: str - :keyword value: Required. This is the filter tag value field used for tag based filtering, it - can have 0 - 256 characters. + :keyword value: This is the filter tag value field used for tag based filtering, it can have 0 + - 256 characters. Required. :paramtype value: str """ - super(TagFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.op = op self.value = value -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -7146,28 +6820,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -7175,13 +6845,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -7198,30 +6868,26 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -7230,13 +6896,13 @@ def __init__( self.upn = None -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_04_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -7247,33 +6913,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -7281,24 +6943,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2021_04_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -7310,27 +6967,23 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """UserAssignedIdentity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -7342,72 +6995,68 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", - "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_04_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", - "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_04_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py index 4ed75f87460f..1cc67b349f96 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -25,10 +25,13 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobInventoryPolicyName.""" DEFAULT = "default" + class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - @@ -39,6 +42,7 @@ class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): COMPLETE = "Complete" FAILED = "Failed" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -50,7 +54,9 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CorsRuleAllowedMethodsItem.""" DELETE = "DELETE" GET = "GET" @@ -60,25 +66,25 @@ class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): OPTIONS = "OPTIONS" PUT = "PUT" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default share permission for users using Kerberos authentication if RBAC role is not assigned. - """ + """Default share permission for users using Kerberos authentication if RBAC role is not assigned.""" NONE = "None" STORAGE_FILE_DATA_SMB_SHARE_READER = "StorageFileDataSmbShareReader" @@ -86,14 +92,15 @@ class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" STORAGE_FILE_DATA_SMB_SHARE_OWNER = "StorageFileDataSmbShareOwner" + class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the directory service used. - """ + """Indicates the directory service used.""" NONE = "None" AADDS = "AADDS" AD = "AD" + class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. @@ -102,6 +109,7 @@ class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): SMB = "SMB" NFS = "NFS" + class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. @@ -110,32 +118,39 @@ class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. - """ + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + +class Enum35(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Enum35.""" + + DEFAULT = "default" + + class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SAS expiration action. Can only be Log. - """ + """The SAS expiration action. Can only be Log.""" LOG = "Log" + class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation. - """ + """The type of extendedLocation.""" EDGE_ZONE = "EdgeZone" + class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is a required field, it specifies the format for the inventory files. - """ + """This is a required field, it specifies the format for the inventory files.""" CSV = "Csv" PARQUET = "Parquet" + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -148,29 +163,30 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type. - """ + """The identity type.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -180,27 +196,29 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Inventory - """ + """The valid value is Inventory.""" INVENTORY = "Inventory" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service @@ -210,9 +228,9 @@ class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SERVICE = "Service" ACCOUNT = "Account" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -220,22 +238,23 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - """ + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -245,19 +264,19 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -265,21 +284,26 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListContainersInclude.""" DELETED = "deleted" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property denotes the container level immutability to object level immutability migration state. @@ -288,6 +312,7 @@ class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): IN_PROGRESS = "InProgress" COMPLETED = "Completed" + class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. @@ -297,12 +322,13 @@ class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" + class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only - """ + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only.""" ACCESS_TIME_TRACKING = "AccessTimeTracking" + class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field specifies the scope of the inventory created either at the blob or container level. @@ -311,6 +337,7 @@ class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): BLOB = "Blob" CONTAINER = "Container" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -325,39 +352,40 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state. - """ + """The current provisioning state.""" SUCCEEDED = "Succeeded" CREATING = "Creating" DELETING = "Deleting" FAILED = "Failed" + class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status. - """ + """The private endpoint connection status.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -366,6 +394,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -376,34 +405,35 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The property is for NFS share only. The default is NoRootSquash. - """ + """The property is for NFS share only. The default is NoRootSquash.""" NO_ROOT_SQUASH = "NoRootSquash" ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" + class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Routing Choice defines the kind of network routing opted by the user. - """ + """Routing Choice defines the kind of network routing opted by the user.""" MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" + class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Lifecycle - """ + """The valid value is Lifecycle.""" LIFECYCLE = "Lifecycle" + class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is a required field. This field is used to schedule an inventory formation. - """ + """This is a required field. This field is used to schedule an inventory formation.""" DAILY = "Daily" WEEKLY = "Weekly" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -414,6 +444,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. @@ -424,6 +455,7 @@ class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): COOL = "Cool" PREMIUM = "Premium" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -434,6 +466,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -444,6 +477,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -458,16 +492,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SKU tier. This is based on the SKU name. - """ + """The SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "Provisioning" DEPROVISIONING = "Deprovisioning" @@ -475,14 +509,16 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "Failed" NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" + class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountExpand.""" GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/__init__.py index 9a63fd415725..a7c5747747ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/__init__.py @@ -29,26 +29,27 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_operations.py index 0fe8469bf04d..af68776f3b97 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_containers_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,13 +29,20 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -36,361 +50,307 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum35], subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum35], subscription_id: str, *, if_match: Optional[str] = None, @@ -399,43 +359,42 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum35], subscription_id: str, *, if_match: str, @@ -444,36 +403,34 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -488,34 +445,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -525,132 +481,113 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_object_level_worm_request_initial( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any +def build_object_level_worm_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobContainersOperations: """ @@ -671,7 +608,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -679,18 +615,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> Iterable[_models.ListContainerItems]: + ) -> Iterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -699,35 +635,39 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_04_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -735,18 +675,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -763,10 +702,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -776,19 +713,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -796,37 +733,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -836,7 +860,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -844,10 +869,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -855,63 +879,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -921,7 +1031,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -929,72 +1040,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1002,72 +1109,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1075,10 +1178,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1088,16 +1190,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1105,37 +1208,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1145,7 +1335,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1153,80 +1344,166 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') - - request = build_clear_legal_hold_request( - resource_group_name=resource_group_name, - account_name=account_name, - container_name=container_name, - subscription_id=self._config.subscription_id, + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_04_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + request = build_clear_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1234,51 +1511,55 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum35], if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. @@ -1286,44 +1567,144 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum35], + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + immutability_policy_name: Union[str, _models.Enum35], + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, + subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1331,10 +1712,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1342,17 +1722,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1360,6 +1739,7 @@ def get_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum35], if_match: Optional[str] = None, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1367,52 +1747,52 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If omitted, this operation will always be applied. Default value is None. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1420,10 +1800,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1431,17 +1810,16 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( @@ -1449,6 +1827,7 @@ def delete_immutability_policy( resource_group_name: str, account_name: str, container_name: str, + immutability_policy_name: Union[str, _models.Enum35], if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: @@ -1458,52 +1837,52 @@ def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str + :param immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. "default" Required. + :type immutability_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str - :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the - specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is - "default". Note that overriding this default value may result in unsupported behavior. - :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, - subscription_id=self._config.subscription_id, immutability_policy_name=immutability_policy_name, - api_version=api_version, + subscription_id=self._config.subscription_id, if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1511,10 +1890,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1522,71 +1900,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1594,10 +1968,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1605,19 +1978,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1625,6 +1997,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1632,56 +2006,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1689,10 +2162,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1700,65 +2172,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1768,7 +2326,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1776,52 +2335,48 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_object_level_worm_request_initial( + request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata['url'], + template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1829,10 +2384,9 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1842,16 +2396,11 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore - + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace - def begin_object_level_worm( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> LROPoller[None]: """This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites require a container level immutability policy either in locked @@ -1859,16 +2408,16 @@ def begin_object_level_worm( # pylint: disable=inconsistent-return-statements on the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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. @@ -1880,53 +2429,48 @@ def begin_object_level_worm( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_operations.py index f719d88f7d56..d4c31d3341e9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_inventory_policies_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,167 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - *, - json: Optional[_models.BlobInventoryPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobInventoryPoliciesOperations: """ @@ -207,52 +208,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -260,10 +262,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -271,68 +272,151 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy 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 - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -340,10 +424,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -351,61 +434,62 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -413,10 +497,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -427,51 +510,50 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -479,15 +561,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -504,10 +588,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -518,8 +600,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_operations.py index 3701f5f85d47..93ee00ac47a0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_blob_services_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,134 +27,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum35], subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum35], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -168,47 +170,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -216,15 +220,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -241,10 +247,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -254,66 +258,149 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + blob_services_name: Union[str, _models.Enum35], parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum35], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + blob_services_name: Union[str, _models.Enum35], + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties 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 + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -321,72 +408,67 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, blob_services_name: Union[str, _models.Enum35], **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword blob_services_name: The name of the blob Service within the specified storage account. - Blob Service Name must be 'default'. Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype blob_services_name: str + :param blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. "default" Required. + :type blob_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + blob_services_name=blob_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -394,22 +476,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_operations.py index 6dc10284acda..445649678633 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_deleted_accounts_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,81 +27,74 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_get_request( - deleted_account_name: str, - location: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(deleted_account_name: str, location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), - "location": _SERIALIZER.url("location", location, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "deletedAccountName": _SERIALIZER.url( + "deleted_account_name", deleted_account_name, "str", max_length=24, min_length=3 + ), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DeletedAccountsOperations: """ @@ -115,38 +115,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DeletedAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -154,13 +152,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -177,10 +179,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -191,48 +191,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace - def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,10 +235,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,12 +245,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_operations.py index 800cc124e5f7..5717486ebcf5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_encryption_scopes_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,181 +27,164 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_put_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EncryptionScopesOperations: """ @@ -215,14 +205,15 @@ def __init__(self, *args, **kwargs): 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 + @overload def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -230,47 +221,137 @@ def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -278,10 +359,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -290,73 +370,160 @@ def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace + @overload def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -364,10 +531,9 @@ def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,62 +541,59 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -438,10 +601,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,58 +611,54 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.EncryptionScopeListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -508,15 +666,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -533,10 +693,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -546,8 +704,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_operations.py index 88fabc70358c..8b930cde6af8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum35], subscription_id: str, - *, - json: Optional[_models.FileServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum35], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class FileServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,10 +211,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -225,70 +221,153 @@ def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + file_services_name: Union[str, _models.Enum35], parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :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: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum35], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + file_services_name: Union[str, _models.Enum35], + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties 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 + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -296,10 +375,9 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,62 +385,58 @@ def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, file_services_name: Union[str, _models.Enum35], **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword file_services_name: The name of the file Service within the specified storage account. - File Service Name must be "default". Default value is "default". Note that overriding this - default value may result in unsupported behavior. - :paramtype file_services_name: str + :param file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". "default" Required. + :type file_services_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + file_services_name=file_services_name, subscription_id=self._config.subscription_id, api_version=api_version, - file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -370,10 +444,9 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -381,12 +454,11 @@ def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_operations.py index b61b17fcd38d..61aa44a82abd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_file_shares_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -40,38 +54,37 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( @@ -80,95 +93,80 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: Optional[_models.FileShare] = None, - content: Any = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -184,37 +182,36 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -230,84 +227,73 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_restore_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.DeletedShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( @@ -316,48 +302,44 @@ def build_lease_request( share_name: str, subscription_id: str, *, - json: Optional[_models.LeaseShareRequest] = None, - content: Any = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class FileSharesOperations: """ @@ -378,7 +360,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -388,15 +369,15 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.FileShareItems]: + ) -> Iterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -409,32 +390,36 @@ def list( None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -442,18 +427,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -470,10 +454,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -484,13 +466,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, @@ -498,6 +478,8 @@ def create( share_name: str, file_share: _models.FileShare, expand: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -505,51 +487,147 @@ def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -557,10 +635,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -569,63 +646,149 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_04_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -635,7 +798,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -643,10 +807,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,15 +817,14 @@ def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def get( @@ -677,16 +839,16 @@ def get( """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. Default value is None. @@ -695,31 +857,33 @@ def get( None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -727,10 +891,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,15 +901,14 @@ def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -761,16 +923,16 @@ def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str @@ -779,34 +941,37 @@ def delete( # pylint: disable=inconsistent-return-statements snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the - file share contains any snapshots (leased or unleased), the deletion fails. + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. :type include: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -814,10 +979,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -828,52 +992,135 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace + @overload def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_04_01.models.DeletedShare + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_04_01.models.DeletedShare 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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -883,7 +1130,8 @@ def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -891,10 +1139,9 @@ def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -905,10 +1152,9 @@ def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - @distributed_trace + @overload def lease( self, resource_group_name: str, @@ -916,60 +1162,156 @@ def lease( share_name: str, x_ms_snapshot: Optional[str] = None, parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse, or the result of cls(response) + :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseShareResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseShareRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, api_version=api_version, content_type=content_type, json=_json, - x_ms_snapshot=x_ms_snapshot, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -977,10 +1319,9 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -989,14 +1330,13 @@ def lease( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_operations.py index 516e52b97c57..a5311adf81df 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,130 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,52 +169,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -215,78 +223,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy 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 - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -294,71 +384,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_04_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -366,10 +456,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +468,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_operations.py index 37e6a248834e..2aaef7ed7123 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_object_replication_policies_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,161 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - *, - json: Optional[_models.ObjectReplicationPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ObjectReplicationPoliciesOperations: """ @@ -207,49 +202,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +252,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +279,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -296,58 +291,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -355,10 +346,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -366,70 +356,156 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy 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 - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -437,10 +513,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -448,62 +523,59 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -511,10 +583,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -525,5 +596,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_operations.py index 0190ffba694b..eb1fdd36d6ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_endpoint_connections_operations.py index 3d33ad8c0399..46727bb37a3e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,173 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -207,49 +214,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +264,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +291,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,56 +302,52 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -352,10 +355,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,67 +365,148 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace + @overload def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection 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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -431,10 +514,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,60 +524,57 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -503,10 +582,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -517,5 +595,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_link_resources_operations.py index a85a982fe8cc..8a626348ae37 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,52 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_storage_account_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,46 +91,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -128,22 +136,20 @@ def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_operations.py index 46875398aaea..0bd38cba099a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,183 +27,188 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( @@ -211,36 +223,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueOperations: """ @@ -261,60 +273,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -322,10 +419,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -333,69 +429,154 @@ def create( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -403,10 +584,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,62 +594,57 @@ def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.StorageQueue: + def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -477,10 +652,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -488,62 +662,59 @@ def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -551,10 +722,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -565,8 +735,7 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -576,15 +745,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.ListQueueResource]: + ) -> Iterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -593,31 +762,35 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -625,17 +798,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -652,10 +825,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -666,8 +837,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_operations.py index 147443fdcd2b..4a5ddb60251e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_queue_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum35], subscription_id: str, - *, - json: Optional[_models.QueueServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum35], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,10 +211,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -225,70 +221,154 @@ def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + queue_service_name: Union[str, _models.Enum35], parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :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: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum35], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + queue_service_name: Union[str, _models.Enum35], + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties 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 + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -296,10 +376,9 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,62 +386,58 @@ def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_service_name: Union[str, _models.Enum35], **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword queue_service_name: The name of the Queue Service within the specified storage - account. Queue Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype queue_service_name: str + :param queue_service_name: The name of the Queue Service within the specified storage account. + Queue Service Name must be 'default'. "default" Required. + :type queue_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + queue_service_name=queue_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -370,10 +445,9 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -381,12 +455,11 @@ def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_operations.py index c0756b3c437d..435ff77ffdc0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_operations.py index d00d0f717126..857f8ab649ed 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +29,110 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,153 +140,129 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -304,280 +270,238 @@ def build_list_keys_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "kerb", + expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_restore_blob_ranges_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobRestoreParameters] = None, - content: Any = None, - **kwargs: Any +def build_restore_blob_ranges_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revoke_user_delegation_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: """ @@ -598,45 +522,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2021_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -644,55 +621,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -700,10 +685,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -712,22 +696,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -736,14 +721,17 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCreateParameters + :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 @@ -755,20 +743,98 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -776,79 +842,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -856,10 +917,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -869,15 +929,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -885,40 +944,43 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_04_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -926,32 +988,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -964,32 +1026,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountUpdateParameters + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -998,7 +1145,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1006,58 +1154,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1065,13 +1210,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1088,10 +1237,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1101,49 +1248,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1151,14 +1294,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1175,10 +1321,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1188,57 +1332,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1246,65 +1386,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_04_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1313,7 +1526,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1321,63 +1535,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.AccountSasParameters + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1386,7 +1673,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1394,63 +1682,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1459,7 +1818,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1467,50 +1827,47 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1518,10 +1875,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1531,26 +1887,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1562,85 +1912,90 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1648,10 +2003,9 @@ def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1659,38 +2013,80 @@ def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace + @overload def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1702,20 +2098,54 @@ def begin_restore_blob_ranges( :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.BlobRestoreParameters 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. + :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_04_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1723,79 +2153,76 @@ def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1803,10 +2230,9 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1816,5 +2242,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_operations.py index e5298760cbac..a41551d04dd5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,204 +27,194 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableOperations: """ @@ -238,52 +235,47 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def create(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -291,10 +283,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -302,61 +293,56 @@ def create( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -364,10 +350,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,61 +360,56 @@ def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -437,10 +417,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -448,61 +427,58 @@ def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -510,10 +486,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -524,49 +499,47 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -574,15 +547,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -599,10 +574,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -613,8 +586,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_operations.py index 26314e3c4195..bf0a135aaaf9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_table_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,129 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum35], subscription_id: str, - *, - json: Optional[_models.TableServiceProperties] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum35], subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableServicesOperations: """ @@ -167,46 +168,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,10 +211,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -225,70 +221,154 @@ def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, + table_service_name: Union[str, _models.Enum35], parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :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: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum35], + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + table_service_name: Union[str, _models.Enum35], + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties 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 + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -296,10 +376,9 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,62 +386,58 @@ def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_service_name: Union[str, _models.Enum35], **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :keyword table_service_name: The name of the Table Service within the specified storage - account. Table Service Name must be 'default'. Default value is "default". Note that overriding - this default value may result in unsupported behavior. - :paramtype table_service_name: str + :param table_service_name: The name of the Table Service within the specified storage account. + Table Service Name must be 'default'. "default" Required. + :type table_service_name: str or ~azure.mgmt.storage.v2021_04_01.models.Enum35 :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_04_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, + table_service_name=table_service_name, subscription_id=self._config.subscription_id, api_version=api_version, - table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -370,10 +445,9 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -381,12 +455,11 @@ def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_operations.py index 3c54ff25e637..b9af8473a413 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_04_01/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,41 +87,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_04_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-04-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-04-01")) # type: Literal["2021-04-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -122,14 +128,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -146,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -159,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_configuration.py index 0b960f8a50b5..e5dbadb9960b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-06-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", "2021-06-01") # type: Literal["2021-06-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json index fc9fc818b993..8934d6bc7510 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -117,4 +117,4 @@ "table_services": "TableServicesOperations", "table": "TableOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py index cea141fe7836..5d1a44a08d3e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_storage_management_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -69,9 +89,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_06_01.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_06_01.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -89,28 +109,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -129,37 +145,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -168,7 +163,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_configuration.py index 2c8f748487c3..ecab28e1a4aa 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-06-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-06-01") # type: str + api_version = kwargs.pop("api_version", "2021-06-01") # type: Literal["2021-06-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py index f7cfd4bca959..289ba72eacc7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/_storage_management_client.py @@ -9,20 +9,40 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -72,9 +92,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_06_01.aio.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_06_01.aio.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -92,28 +112,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -132,37 +148,16 @@ def __init__( self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -171,7 +166,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/__init__.py index 9a63fd415725..a7c5747747ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/__init__.py @@ -29,26 +29,27 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_operations.py index 4e3e22fd0c90..f8e72dcae426 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_containers_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,31 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_object_level_worm_request_initial, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_object_level_worm_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -45,7 +75,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,18 +82,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListContainerItems]: + ) -> AsyncIterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -73,36 +102,40 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_06_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -110,18 +143,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -138,10 +170,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,19 +181,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -171,37 +201,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -211,7 +328,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -219,10 +337,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -230,63 +347,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -296,7 +499,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -304,72 +508,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -377,72 +577,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -450,10 +646,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -463,16 +658,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -480,37 +676,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -520,7 +803,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -528,70 +812,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -601,7 +970,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -609,27 +979,25 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, @@ -637,22 +1005,24 @@ async def create_or_update_immutability_policy( container_name: str, if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -661,44 +1031,149 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy or IO :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: 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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -706,10 +1181,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -717,17 +1191,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -742,16 +1215,16 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -762,32 +1235,34 @@ async def get_immutability_policy( "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -795,10 +1270,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -806,26 +1280,20 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this @@ -833,52 +1301,54 @@ async def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -886,10 +1356,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -897,71 +1366,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -969,10 +1434,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -980,19 +1444,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -1000,6 +1463,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1007,56 +1472,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1064,10 +1628,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1075,65 +1638,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1143,7 +1792,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1151,52 +1801,48 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_object_level_worm_request_initial( + request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata['url'], + template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1204,10 +1850,9 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1217,16 +1862,11 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore - + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace_async - async def begin_object_level_worm( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + async def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites require a container level immutability policy either in locked @@ -1234,16 +1874,16 @@ async def begin_object_level_worm( # pylint: disable=inconsistent-return-statem on the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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. @@ -1255,53 +1895,48 @@ async def begin_object_level_worm( # pylint: disable=inconsistent-return-statem 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_operations.py index 3ce4f7088a6e..a39e7af9a4a8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_inventory_policies_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_inventory_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._blob_inventory_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobInventoryPoliciesOperations: """ .. warning:: @@ -43,52 +63,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +117,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,68 +127,151 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy 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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -176,10 +279,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,61 +289,62 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -249,10 +352,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -263,51 +365,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -315,15 +416,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -340,10 +443,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -354,8 +455,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_operations.py index bf424e27e298..d3fc32b7c54b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_blob_services_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -43,48 +62,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,56 +150,139 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties or IO + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: 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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -189,7 +292,8 @@ async def set_service_properties( blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -197,72 +301,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -270,22 +371,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_operations.py index 9c475c0cac47..14a6acee2eaf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_deleted_accounts_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DeletedAccountsOperations: """ .. warning:: @@ -43,38 +58,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) + :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -82,13 +96,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -105,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -119,48 +135,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async - async def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -168,10 +179,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,12 +189,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_operations.py index 9afb811e3823..5612f3250d73 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_encryption_scopes_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._encryption_scopes_operations import build_get_request, build_list_request, build_patch_request, build_put_request -T = TypeVar('T') +from ...operations._encryption_scopes_operations import ( + build_get_request, + build_list_request, + build_patch_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EncryptionScopesOperations: """ .. warning:: @@ -43,14 +63,15 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -58,47 +79,137 @@ async def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -106,10 +217,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -118,73 +228,160 @@ async def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace_async + @overload async def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +389,9 @@ async def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,62 +399,59 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -266,10 +459,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -277,58 +469,57 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EncryptionScopeListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) + :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -336,15 +527,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -361,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -374,8 +565,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_operations.py index a8efd54c9524..8297353b0056 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,10 +102,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,60 +112,143 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties or IO + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: 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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -162,7 +258,8 @@ async def set_service_properties( file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -170,10 +267,9 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,62 +277,60 @@ async def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -244,10 +338,9 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,12 +348,11 @@ async def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_operations.py index d620d3224e70..00f949504e52 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_file_shares_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,24 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_shares_operations import build_create_request, build_delete_request, build_get_request, build_lease_request, build_list_request, build_restore_request, build_update_request -T = TypeVar('T') +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_lease_request, + build_list_request, + build_restore_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileSharesOperations: """ .. warning:: @@ -43,7 +66,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,15 +75,15 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.FileShareItems]: + ) -> AsyncIterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -74,33 +96,37 @@ def list( None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) + :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -108,18 +134,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -136,10 +161,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -150,13 +173,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, @@ -164,6 +185,8 @@ async def create( share_name: str, file_share: _models.FileShare, expand: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -171,51 +194,147 @@ async def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -223,10 +342,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -235,63 +353,149 @@ async def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -301,7 +505,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -309,10 +514,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -320,15 +524,14 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def get( @@ -343,16 +546,16 @@ async def get( """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. Default value is None. @@ -361,31 +564,33 @@ async def get( None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -393,10 +598,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -404,15 +608,14 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -427,16 +630,16 @@ async def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str @@ -445,34 +648,37 @@ async def delete( # pylint: disable=inconsistent-return-statements snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the - file share contains any snapshots (leased or unleased), the deletion fails. + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. :type include: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -480,10 +686,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -494,52 +699,135 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace_async + @overload async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_06_01.models.DeletedShare + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_06_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -549,7 +837,8 @@ async def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -557,10 +846,9 @@ async def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -571,10 +859,9 @@ async def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, @@ -582,60 +869,156 @@ async def lease( share_name: str, x_ms_snapshot: Optional[str] = None, parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse, or the result of cls(response) + :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseShareResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseShareRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, api_version=api_version, content_type=content_type, json=_json, - x_ms_snapshot=x_ms_snapshot, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -643,10 +1026,9 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -655,14 +1037,13 @@ async def lease( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_operations.py index 5c7da837000c..f4b00f74898d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,52 +59,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -94,78 +113,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy + :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: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -173,71 +274,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -245,10 +346,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -258,5 +358,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_operations.py index 112d004426d9..ab21ecbc6395 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_object_replication_policies_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._object_replication_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._object_replication_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ObjectReplicationPoliciesOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,58 +152,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -191,10 +207,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,70 +217,156 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy 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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -273,10 +374,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -284,62 +384,59 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -347,10 +444,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -361,5 +457,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_operations.py index 72a2041dd560..84bf51a01a37 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_endpoint_connections_operations.py index 5f77426cbbfb..fd8ca64f0438 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request, build_get_request, build_list_request, build_put_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +151,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +204,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +214,148 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection 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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +363,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +373,57 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +431,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,5 +444,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_link_resources_operations.py index 252b6a0cc627..44a9e43b7dfc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,46 +55,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -88,22 +100,20 @@ async def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_operations.py index e919bdb0ddd6..7036bf0354ab 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._queue_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueOperations: """ .. warning:: @@ -43,60 +64,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue 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 - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -104,10 +210,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -115,69 +220,154 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -185,10 +375,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -196,62 +385,59 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -259,10 +445,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -270,62 +455,59 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -333,10 +515,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -347,8 +528,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -358,15 +538,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListQueueResource]: + ) -> AsyncIterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -375,32 +555,36 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) + :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -408,17 +592,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -435,10 +619,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -449,8 +631,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_operations.py index 946572fc3453..c232b53eebdf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_queue_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._queue_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,10 +102,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,60 +112,144 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties or IO + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: 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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -162,7 +259,8 @@ async def set_service_properties( queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -170,10 +268,9 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,62 +278,60 @@ async def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -244,10 +339,9 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,12 +349,11 @@ async def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_operations.py index 66012f9ed807..2523c5ff59ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) + :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +95,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +133,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_operations.py index 0586c28e08d5..132b4a7bd107 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,33 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_abort_hierarchical_namespace_migration_request_initial, build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_hierarchical_namespace_migration_request_initial, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_restore_blob_ranges_request_initial, build_revoke_user_delegation_keys_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_abort_hierarchical_namespace_migration_request, + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_hierarchical_namespace_migration_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_restore_blob_ranges_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: # pylint: disable=too-many-public-methods """ .. warning:: @@ -45,45 +77,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2021_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +176,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +240,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +251,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +276,17 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCreateParameters + :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 @@ -203,20 +299,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCreateParameters 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. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +400,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +475,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,15 +487,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -333,40 +502,43 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_06_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,32 +546,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -412,32 +584,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -446,7 +703,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -454,58 +712,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -513,13 +769,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -536,10 +796,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,49 +807,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -599,14 +856,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -623,10 +883,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -636,57 +894,53 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -694,65 +948,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_06_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -761,7 +1088,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -769,63 +1097,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -834,7 +1235,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -842,63 +1244,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ServiceSasParameters + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -907,7 +1380,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -915,50 +1389,47 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -966,10 +1437,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -979,26 +1449,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1010,82 +1474,75 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_hierarchical_namespace_migration_request_initial( + request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, request_type=request_type, - template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + api_version=api_version, + template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1093,43 +1550,38 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - + _hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace_async - async def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + async def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param request_type: Required. Hierarchical namespace migration type can either be a hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the - hydration request will migrate the account. + hydration request will migrate the account. Required. :type request_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. @@ -1141,81 +1593,75 @@ async def begin_hierarchical_namespace_migration( # pylint: disable=inconsisten 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + begin_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_abort_hierarchical_namespace_migration_request_initial( + request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1223,37 +1669,33 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore - + _abort_hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + async def begin_abort_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Abort live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1265,85 +1707,90 @@ async def begin_abort_hierarchical_namespace_migration( # pylint: disable=incon 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1351,10 +1798,9 @@ async def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1362,38 +1808,81 @@ async def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace_async + @overload async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1406,20 +1895,55 @@ async def begin_restore_blob_ranges( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobRestoreParameters 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. + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1427,79 +1951,76 @@ async def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1507,10 +2028,9 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1520,5 +2040,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_operations.py index eb08ed4751c2..4fee569a159e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._table_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableOperations: """ .. warning:: @@ -43,52 +64,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +114,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,61 +124,58 @@ async def create( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -169,10 +183,9 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -180,61 +193,56 @@ async def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -242,10 +250,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -253,61 +260,58 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -315,10 +319,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -329,50 +332,47 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -380,15 +380,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -405,10 +407,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -419,8 +419,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_operations.py index 2ebb110ba266..5ffb7acc9d24 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_table_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._table_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,10 +102,9 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -99,60 +112,144 @@ async def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties or IO + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: 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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -162,7 +259,8 @@ async def set_service_properties( table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -170,10 +268,9 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -181,62 +278,60 @@ async def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -244,10 +339,9 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -255,12 +349,11 @@ async def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_operations.py index e7deccd855fb..7fc9848a31ef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,42 +57,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_06_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -85,14 +98,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -109,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -122,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/__init__.py index cac552f15595..443b6ec23dbc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/__init__.py @@ -148,274 +148,272 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountImmutabilityPolicyState, - AccountStatus, - BlobInventoryPolicyName, - BlobRestoreProgressStatus, - Bypass, - CorsRuleAllowedMethodsItem, - CreatedByType, - DefaultAction, - DefaultSharePermission, - DirectoryServiceOptions, - EnabledProtocols, - EncryptionScopeSource, - EncryptionScopeState, - ExpirationAction, - ExtendedLocationTypes, - Format, - GeoReplicationStatus, - HttpProtocol, - IdentityType, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - InventoryRuleType, - KeyPermission, - KeySource, - KeyType, - Kind, - LargeFileSharesState, - LeaseContainerRequestAction, - LeaseDuration, - LeaseShareAction, - LeaseState, - LeaseStatus, - ListContainersInclude, - ManagementPolicyName, - MigrationState, - MinimumTlsVersion, - Name, - ObjectType, - Permissions, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisioningState, - PublicAccess, - PublicNetworkAccess, - Reason, - ReasonCode, - RootSquashType, - RoutingChoice, - RuleType, - Schedule, - Services, - ShareAccessTier, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - StorageAccountExpand, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountImmutabilityPolicyState +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import BlobInventoryPolicyName +from ._storage_management_client_enums import BlobRestoreProgressStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CorsRuleAllowedMethodsItem +from ._storage_management_client_enums import CreatedByType +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DefaultSharePermission +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import EnabledProtocols +from ._storage_management_client_enums import EncryptionScopeSource +from ._storage_management_client_enums import EncryptionScopeState +from ._storage_management_client_enums import ExpirationAction +from ._storage_management_client_enums import ExtendedLocationTypes +from ._storage_management_client_enums import Format +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import IdentityType +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import InventoryRuleType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import KeyType +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseShareAction +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ListContainersInclude +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MigrationState +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Name +from ._storage_management_client_enums import ObjectType +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._storage_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import PublicNetworkAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RootSquashType +from ._storage_management_client_enums import RoutingChoice +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Schedule +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import ShareAccessTier +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import StorageAccountExpand +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessPolicy', - 'AccountImmutabilityPolicyProperties', - 'AccountSasParameters', - 'ActiveDirectoryProperties', - 'AzureEntityResource', - 'AzureFilesIdentityBasedAuthentication', - 'BlobContainer', - 'BlobInventoryPolicy', - 'BlobInventoryPolicyDefinition', - 'BlobInventoryPolicyFilter', - 'BlobInventoryPolicyRule', - 'BlobInventoryPolicySchema', - 'BlobRestoreParameters', - 'BlobRestoreRange', - 'BlobRestoreStatus', - 'BlobServiceItems', - 'BlobServiceProperties', - 'ChangeFeed', - 'CheckNameAvailabilityResult', - 'CloudErrorAutoGenerated', - 'CloudErrorBody', - 'CloudErrorBodyAutoGenerated', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DateAfterCreation', - 'DateAfterModification', - 'DeleteRetentionPolicy', - 'DeletedAccount', - 'DeletedAccountListResult', - 'DeletedShare', - 'Dimension', - 'Encryption', - 'EncryptionIdentity', - 'EncryptionScope', - 'EncryptionScopeKeyVaultProperties', - 'EncryptionScopeListResult', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'ErrorResponse', - 'ErrorResponseBody', - 'ExtendedLocation', - 'FileServiceItems', - 'FileServiceProperties', - 'FileShare', - 'FileShareItem', - 'FileShareItems', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'ImmutableStorageAccount', - 'ImmutableStorageWithVersioning', - 'KeyCreationTime', - 'KeyPolicy', - 'KeyVaultProperties', - 'LastAccessTimeTrackingPolicy', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LeaseShareRequest', - 'LeaseShareResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListBlobInventoryPolicy', - 'ListContainerItem', - 'ListContainerItems', - 'ListQueue', - 'ListQueueResource', - 'ListQueueServices', - 'ListServiceSasResponse', - 'ListTableResource', - 'ListTableServices', - 'ManagementPolicy', - 'ManagementPolicyAction', - 'ManagementPolicyBaseBlob', - 'ManagementPolicyDefinition', - 'ManagementPolicyFilter', - 'ManagementPolicyRule', - 'ManagementPolicySchema', - 'ManagementPolicySnapShot', - 'ManagementPolicyVersion', - 'MetricSpecification', - 'Multichannel', - 'NetworkRuleSet', - 'ObjectReplicationPolicies', - 'ObjectReplicationPolicy', - 'ObjectReplicationPolicyFilter', - 'ObjectReplicationPolicyRule', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProtectedAppendWritesHistory', - 'ProtocolSettings', - 'ProxyResource', - 'QueueServiceProperties', - 'Resource', - 'ResourceAccessRule', - 'RestorePolicyProperties', - 'Restriction', - 'RoutingPreference', - 'SKUCapability', - 'SasPolicy', - 'ServiceSasParameters', - 'ServiceSpecification', - 'SignedIdentifier', - 'Sku', - 'SkuInformation', - 'SmbSetting', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountInternetEndpoints', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountMicrosoftEndpoints', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageQueue', - 'StorageSkuListResult', - 'SystemData', - 'Table', - 'TableServiceProperties', - 'TagFilter', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'UserAssignedIdentity', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountImmutabilityPolicyState', - 'AccountStatus', - 'BlobInventoryPolicyName', - 'BlobRestoreProgressStatus', - 'Bypass', - 'CorsRuleAllowedMethodsItem', - 'CreatedByType', - 'DefaultAction', - 'DefaultSharePermission', - 'DirectoryServiceOptions', - 'EnabledProtocols', - 'EncryptionScopeSource', - 'EncryptionScopeState', - 'ExpirationAction', - 'ExtendedLocationTypes', - 'Format', - 'GeoReplicationStatus', - 'HttpProtocol', - 'IdentityType', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'InventoryRuleType', - 'KeyPermission', - 'KeySource', - 'KeyType', - 'Kind', - 'LargeFileSharesState', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseShareAction', - 'LeaseState', - 'LeaseStatus', - 'ListContainersInclude', - 'ManagementPolicyName', - 'MigrationState', - 'MinimumTlsVersion', - 'Name', - 'ObjectType', - 'Permissions', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'ProvisioningState', - 'PublicAccess', - 'PublicNetworkAccess', - 'Reason', - 'ReasonCode', - 'RootSquashType', - 'RoutingChoice', - 'RuleType', - 'Schedule', - 'Services', - 'ShareAccessTier', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'StorageAccountExpand', - 'UsageUnit', + "AccessPolicy", + "AccountImmutabilityPolicyProperties", + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobInventoryPolicy", + "BlobInventoryPolicyDefinition", + "BlobInventoryPolicyFilter", + "BlobInventoryPolicyRule", + "BlobInventoryPolicySchema", + "BlobRestoreParameters", + "BlobRestoreRange", + "BlobRestoreStatus", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorAutoGenerated", + "CloudErrorBody", + "CloudErrorBodyAutoGenerated", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "DeletedAccount", + "DeletedAccountListResult", + "DeletedShare", + "Dimension", + "Encryption", + "EncryptionIdentity", + "EncryptionScope", + "EncryptionScopeKeyVaultProperties", + "EncryptionScopeListResult", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ErrorResponse", + "ErrorResponseBody", + "ExtendedLocation", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "ImmutableStorageAccount", + "ImmutableStorageWithVersioning", + "KeyCreationTime", + "KeyPolicy", + "KeyVaultProperties", + "LastAccessTimeTrackingPolicy", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LeaseShareRequest", + "LeaseShareResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListBlobInventoryPolicy", + "ListContainerItem", + "ListContainerItems", + "ListQueue", + "ListQueueResource", + "ListQueueServices", + "ListServiceSasResponse", + "ListTableResource", + "ListTableServices", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "ManagementPolicyVersion", + "MetricSpecification", + "Multichannel", + "NetworkRuleSet", + "ObjectReplicationPolicies", + "ObjectReplicationPolicy", + "ObjectReplicationPolicyFilter", + "ObjectReplicationPolicyRule", + "Operation", + "OperationDisplay", + "OperationListResult", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProtectedAppendWritesHistory", + "ProtocolSettings", + "ProxyResource", + "QueueServiceProperties", + "Resource", + "ResourceAccessRule", + "RestorePolicyProperties", + "Restriction", + "RoutingPreference", + "SKUCapability", + "SasPolicy", + "ServiceSasParameters", + "ServiceSpecification", + "SignedIdentifier", + "Sku", + "SkuInformation", + "SmbSetting", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountInternetEndpoints", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountMicrosoftEndpoints", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageQueue", + "StorageSkuListResult", + "SystemData", + "Table", + "TableServiceProperties", + "TagFilter", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "UserAssignedIdentity", + "VirtualNetworkRule", + "AccessTier", + "AccountImmutabilityPolicyState", + "AccountStatus", + "BlobInventoryPolicyName", + "BlobRestoreProgressStatus", + "Bypass", + "CorsRuleAllowedMethodsItem", + "CreatedByType", + "DefaultAction", + "DefaultSharePermission", + "DirectoryServiceOptions", + "EnabledProtocols", + "EncryptionScopeSource", + "EncryptionScopeState", + "ExpirationAction", + "ExtendedLocationTypes", + "Format", + "GeoReplicationStatus", + "HttpProtocol", + "IdentityType", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "InventoryRuleType", + "KeyPermission", + "KeySource", + "KeyType", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseShareAction", + "LeaseState", + "LeaseStatus", + "ListContainersInclude", + "ManagementPolicyName", + "MigrationState", + "MinimumTlsVersion", + "Name", + "ObjectType", + "Permissions", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicAccess", + "PublicNetworkAccess", + "Reason", + "ReasonCode", + "RootSquashType", + "RoutingChoice", + "RuleType", + "Schedule", + "Services", + "ShareAccessTier", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "StorageAccountExpand", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py index e8ef4643dd7e..b5c807cbdbc6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccessPolicy(msrest.serialization.Model): +class AccessPolicy(_serialization.Model): """AccessPolicy. :ivar start_time: Start time of the access policy. @@ -29,9 +35,9 @@ class AccessPolicy(msrest.serialization.Model): """ _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'permission': {'key': 'permission', 'type': 'str'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "permission": {"key": "permission", "type": "str"}, } def __init__( @@ -50,13 +56,13 @@ def __init__( :keyword permission: List of abbreviated permissions. :paramtype permission: str """ - super(AccessPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_time = start_time self.expiry_time = expiry_time self.permission = permission -class AccountImmutabilityPolicyProperties(msrest.serialization.Model): +class AccountImmutabilityPolicyProperties(_serialization.Model): """This defines account-level immutability policy properties. :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the @@ -68,7 +74,7 @@ class AccountImmutabilityPolicyProperties(msrest.serialization.Model): increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", - "Locked", "Disabled". + "Locked", and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_06_01.models.AccountImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for disabled and unlocked time-based retention policies. When enabled, new blocks can be written to an append @@ -78,13 +84,13 @@ class AccountImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'immutability_period_since_creation_in_days': {'maximum': 146000, 'minimum': 1}, + "immutability_period_since_creation_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'allowProtectedAppendWrites', 'type': 'bool'}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "state": {"key": "state", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -105,7 +111,7 @@ def __init__( increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", - "Locked", "Disabled". + "Locked", and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_06_01.models.AccountImmutabilityPolicyState :keyword allow_protected_append_writes: This property can only be changed for disabled and unlocked time-based retention policies. When enabled, new blocks can be written to an append @@ -113,60 +119,60 @@ def __init__( any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes: bool """ - super(AccountImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = state self.allow_protected_append_writes = allow_protected_append_writes -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2021_06_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_06_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -183,33 +189,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2021_06_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_06_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -220,42 +227,42 @@ def __init__( self.key_to_sign = key_to_sign -class ActiveDirectoryProperties(msrest.serialization.Model): +class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). All required parameters must be populated in order to send to Azure. - :ivar domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :vartype domain_name: str - :ivar net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. Required. :vartype net_bios_domain_name: str - :ivar forest_name: Required. Specifies the Active Directory forest to get. + :ivar forest_name: Specifies the Active Directory forest to get. Required. :vartype forest_name: str - :ivar domain_guid: Required. Specifies the domain GUID. + :ivar domain_guid: Specifies the domain GUID. Required. :vartype domain_guid: str - :ivar domain_sid: Required. Specifies the security identifier (SID). + :ivar domain_sid: Specifies the security identifier (SID). Required. :vartype domain_sid: str - :ivar azure_storage_sid: Required. Specifies the security identifier (SID) for Azure Storage. + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. Required. :vartype azure_storage_sid: str """ _validation = { - 'domain_name': {'required': True}, - 'net_bios_domain_name': {'required': True}, - 'forest_name': {'required': True}, - 'domain_guid': {'required': True}, - 'domain_sid': {'required': True}, - 'azure_storage_sid': {'required': True}, + "domain_name": {"required": True}, + "net_bios_domain_name": {"required": True}, + "forest_name": {"required": True}, + "domain_guid": {"required": True}, + "domain_sid": {"required": True}, + "azure_storage_sid": {"required": True}, } _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'net_bios_domain_name': {'key': 'netBiosDomainName', 'type': 'str'}, - 'forest_name': {'key': 'forestName', 'type': 'str'}, - 'domain_guid': {'key': 'domainGuid', 'type': 'str'}, - 'domain_sid': {'key': 'domainSid', 'type': 'str'}, - 'azure_storage_sid': {'key': 'azureStorageSid', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, } def __init__( @@ -270,22 +277,22 @@ def __init__( **kwargs ): """ - :keyword domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :paramtype domain_name: str - :keyword net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. Required. :paramtype net_bios_domain_name: str - :keyword forest_name: Required. Specifies the Active Directory forest to get. + :keyword forest_name: Specifies the Active Directory forest to get. Required. :paramtype forest_name: str - :keyword domain_guid: Required. Specifies the domain GUID. + :keyword domain_guid: Specifies the domain GUID. Required. :paramtype domain_guid: str - :keyword domain_sid: Required. Specifies the security identifier (SID). + :keyword domain_sid: Specifies the security identifier (SID). Required. :paramtype domain_sid: str - :keyword azure_storage_sid: Required. Specifies the security identifier (SID) for Azure - Storage. + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + Required. :paramtype azure_storage_sid: str """ - super(ActiveDirectoryProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.net_bios_domain_name = net_bios_domain_name self.forest_name = forest_name @@ -294,7 +301,7 @@ def __init__( self.azure_storage_sid = azure_storage_sid -class Resource(msrest.serialization.Model): +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. @@ -310,24 +317,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -351,36 +354,32 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): +class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Known values - are: "None", "AADDS", "AD". + :ivar directory_service_options: Indicates the directory service used. Required. Known values + are: "None", "AADDS", and "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_06_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -388,20 +387,20 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): ~azure.mgmt.storage.v2021_06_01.models.ActiveDirectoryProperties :ivar default_share_permission: Default share permission for users using Kerberos authentication if RBAC role is not assigned. Known values are: "None", - "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and "StorageFileDataSmbShareElevatedContributor". :vartype default_share_permission: str or ~azure.mgmt.storage.v2021_06_01.models.DefaultSharePermission """ _validation = { - 'directory_service_options': {'required': True}, + "directory_service_options": {"required": True}, } _attribute_map = { - 'directory_service_options': {'key': 'directoryServiceOptions', 'type': 'str'}, - 'active_directory_properties': {'key': 'activeDirectoryProperties', 'type': 'ActiveDirectoryProperties'}, - 'default_share_permission': {'key': 'defaultSharePermission', 'type': 'str'}, + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, + "default_share_permission": {"key": "defaultSharePermission", "type": "str"}, } def __init__( @@ -413,8 +412,8 @@ def __init__( **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Known - values are: "None", "AADDS", "AD". + :keyword directory_service_options: Indicates the directory service used. Required. Known + values are: "None", "AADDS", and "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_06_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. @@ -422,18 +421,18 @@ def __init__( ~azure.mgmt.storage.v2021_06_01.models.ActiveDirectoryProperties :keyword default_share_permission: Default share permission for users using Kerberos authentication if RBAC role is not assigned. Known values are: "None", - "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and "StorageFileDataSmbShareElevatedContributor". :paramtype default_share_permission: str or ~azure.mgmt.storage.v2021_06_01.models.DefaultSharePermission """ - super(AzureFilesIdentityBasedAuthentication, self).__init__(**kwargs) + super().__init__(**kwargs) self.directory_service_options = directory_service_options self.active_directory_properties = active_directory_properties self.default_share_permission = default_share_permission -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -463,17 +462,18 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -503,48 +503,51 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, - 'enable_nfs_v3_root_squash': {'key': 'properties.enableNfsV3RootSquash', 'type': 'bool'}, - 'enable_nfs_v3_all_squash': {'key': 'properties.enableNfsV3AllSquash', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, } def __init__( @@ -567,7 +570,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -581,7 +584,7 @@ def __init__( :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. :paramtype enable_nfs_v3_all_squash: bool """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -625,81 +628,77 @@ class BlobInventoryPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified_time": {"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'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'BlobInventoryPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "BlobInventoryPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.BlobInventoryPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs): """ :keyword policy: The storage account blob inventory policy object. It is composed of policy rules. :paramtype policy: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicySchema """ - super(BlobInventoryPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.last_modified_time = None self.policy = policy -class BlobInventoryPolicyDefinition(msrest.serialization.Model): +class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. All required parameters must be populated in order to send to Azure. :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyFilter - :ivar format: Required. This is a required field, it specifies the format for the inventory - files. Known values are: "Csv", "Parquet". + :ivar format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". :vartype format: str or ~azure.mgmt.storage.v2021_06_01.models.Format - :ivar schedule: Required. This is a required field. This field is used to schedule an inventory - formation. Known values are: "Daily", "Weekly". + :ivar schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". :vartype schedule: str or ~azure.mgmt.storage.v2021_06_01.models.Schedule - :ivar object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Known values are: "Blob", "Container". + :ivar object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". :vartype object_type: str or ~azure.mgmt.storage.v2021_06_01.models.ObjectType - :ivar schema_fields: Required. This is a required field. This field specifies the fields and - properties of the object to be included in the inventory. The Schema field value 'Name' is - always required. The valid values for this field for the 'Blob' definition.objectType include - 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, + :ivar schema_fields: This is a required field. This field specifies the fields and properties + of the object to be included in the inventory. The Schema field value 'Name' is always + required. The valid values for this field for the 'Blob' definition.objectType include 'Name, + Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, AccessTierChangeTime, AccessTierInferred, Tags, Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime'. The valid values for 'Container' definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl' are valid only - for Hns enabled accounts.'Tags' field is only valid for non Hns accounts. + for Hns enabled accounts.'Tags' field is only valid for non Hns accounts. Required. :vartype schema_fields: list[str] """ _validation = { - 'format': {'required': True}, - 'schedule': {'required': True}, - 'object_type': {'required': True}, - 'schema_fields': {'required': True}, + "format": {"required": True}, + "schedule": {"required": True}, + "object_type": {"required": True}, + "schema_fields": {"required": True}, } _attribute_map = { - 'filters': {'key': 'filters', 'type': 'BlobInventoryPolicyFilter'}, - 'format': {'key': 'format', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'schema_fields': {'key': 'schemaFields', 'type': '[str]'}, + "filters": {"key": "filters", "type": "BlobInventoryPolicyFilter"}, + "format": {"key": "format", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "schema_fields": {"key": "schemaFields", "type": "[str]"}, } def __init__( @@ -715,16 +714,17 @@ def __init__( """ :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyFilter - :keyword format: Required. This is a required field, it specifies the format for the inventory - files. Known values are: "Csv", "Parquet". + :keyword format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". :paramtype format: str or ~azure.mgmt.storage.v2021_06_01.models.Format - :keyword schedule: Required. This is a required field. This field is used to schedule an - inventory formation. Known values are: "Daily", "Weekly". + :keyword schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". :paramtype schedule: str or ~azure.mgmt.storage.v2021_06_01.models.Schedule - :keyword object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Known values are: "Blob", "Container". + :keyword object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". :paramtype object_type: str or ~azure.mgmt.storage.v2021_06_01.models.ObjectType - :keyword schema_fields: Required. This is a required field. This field specifies the fields and + :keyword schema_fields: This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is always required. The valid values for this field for the 'Blob' definition.objectType include 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, @@ -733,10 +733,10 @@ def __init__( values for 'Container' definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl' are valid only - for Hns enabled accounts.'Tags' field is only valid for non Hns accounts. + for Hns enabled accounts.'Tags' field is only valid for non Hns accounts. Required. :paramtype schema_fields: list[str] """ - super(BlobInventoryPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.filters = filters self.format = format self.schedule = schedule @@ -744,7 +744,7 @@ def __init__( self.schema_fields = schema_fields -class BlobInventoryPolicyFilter(msrest.serialization.Model): +class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. For 'Blob' definition.objectType all filter properties are applicable, 'blobTypes' is required and others are optional. For 'Container' definition.objectType only prefixMatch is applicable and is optional. :ivar prefix_match: An array of strings for blob prefixes to be matched. @@ -764,10 +764,10 @@ class BlobInventoryPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'include_blob_versions': {'key': 'includeBlobVersions', 'type': 'bool'}, - 'include_snapshots': {'key': 'includeSnapshots', 'type': 'bool'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "include_blob_versions": {"key": "includeBlobVersions", "type": "bool"}, + "include_snapshots": {"key": "includeSnapshots", "type": "bool"}, } def __init__( @@ -795,42 +795,42 @@ def __init__( else it must be excluded. :paramtype include_snapshots: bool """ - super(BlobInventoryPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.include_blob_versions = include_blob_versions self.include_snapshots = include_snapshots -class BlobInventoryPolicyRule(msrest.serialization.Model): +class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Rule is enabled when set to true. + :ivar enabled: Rule is enabled when set to true. Required. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :ivar destination: Container name where blob inventory files are stored. Must be pre-created. + Required. :vartype destination: str - :ivar definition: Required. An object that defines the blob inventory policy rule. + :ivar definition: An object that defines the blob inventory policy rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyDefinition """ _validation = { - 'enabled': {'required': True}, - 'name': {'required': True}, - 'destination': {'required': True}, - 'definition': {'required': True}, + "enabled": {"required": True}, + "name": {"required": True}, + "destination": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'destination': {'key': 'destination', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'BlobInventoryPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "destination": {"key": "destination", "type": "str"}, + "definition": {"key": "definition", "type": "BlobInventoryPolicyDefinition"}, } def __init__( @@ -843,48 +843,48 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Rule is enabled when set to true. + :keyword enabled: Rule is enabled when set to true. Required. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :keyword destination: Container name where blob inventory files are stored. Must be + pre-created. Required. :paramtype destination: str - :keyword definition: Required. An object that defines the blob inventory policy rule. + :keyword definition: An object that defines the blob inventory policy rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyDefinition """ - super(BlobInventoryPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.destination = destination self.definition = definition -class BlobInventoryPolicySchema(msrest.serialization.Model): +class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Policy is enabled if set to true. + :ivar enabled: Policy is enabled if set to true. Required. :vartype enabled: bool - :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". + :ivar type: The valid value is Inventory. Required. "Inventory" :vartype type: str or ~azure.mgmt.storage.v2021_06_01.models.InventoryRuleType - :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :ivar rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :vartype rules: list[~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyRule] """ _validation = { - 'enabled': {'required': True}, - 'type': {'required': True}, - 'rules': {'required': True}, + "enabled": {"required": True}, + "type": {"required": True}, + "rules": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rules': {'key': 'rules', 'type': '[BlobInventoryPolicyRule]'}, + "enabled": {"key": "enabled", "type": "bool"}, + "type": {"key": "type", "type": "str"}, + "rules": {"key": "rules", "type": "[BlobInventoryPolicyRule]"}, } def __init__( @@ -896,99 +896,87 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Policy is enabled if set to true. + :keyword enabled: Policy is enabled if set to true. Required. :paramtype enabled: bool - :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". + :keyword type: The valid value is Inventory. Required. "Inventory" :paramtype type: str or ~azure.mgmt.storage.v2021_06_01.models.InventoryRuleType - :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :keyword rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :paramtype rules: list[~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyRule] """ - super(BlobInventoryPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.type = type self.rules = rules -class BlobRestoreParameters(msrest.serialization.Model): +class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. All required parameters must be populated in order to send to Azure. - :ivar time_to_restore: Required. Restore blob to the specified time. + :ivar time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime - :ivar blob_ranges: Required. Blob ranges to restore. + :ivar blob_ranges: Blob ranges to restore. Required. :vartype blob_ranges: list[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreRange] """ _validation = { - 'time_to_restore': {'required': True}, - 'blob_ranges': {'required': True}, + "time_to_restore": {"required": True}, + "blob_ranges": {"required": True}, } _attribute_map = { - 'time_to_restore': {'key': 'timeToRestore', 'type': 'iso-8601'}, - 'blob_ranges': {'key': 'blobRanges', 'type': '[BlobRestoreRange]'}, + "time_to_restore": {"key": "timeToRestore", "type": "iso-8601"}, + "blob_ranges": {"key": "blobRanges", "type": "[BlobRestoreRange]"}, } - def __init__( - self, - *, - time_to_restore: datetime.datetime, - blob_ranges: List["_models.BlobRestoreRange"], - **kwargs - ): + def __init__(self, *, time_to_restore: datetime.datetime, blob_ranges: List["_models.BlobRestoreRange"], **kwargs): """ - :keyword time_to_restore: Required. Restore blob to the specified time. + :keyword time_to_restore: Restore blob to the specified time. Required. :paramtype time_to_restore: ~datetime.datetime - :keyword blob_ranges: Required. Blob ranges to restore. + :keyword blob_ranges: Blob ranges to restore. Required. :paramtype blob_ranges: list[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreRange] """ - super(BlobRestoreParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_to_restore = time_to_restore self.blob_ranges = blob_ranges -class BlobRestoreRange(msrest.serialization.Model): +class BlobRestoreRange(_serialization.Model): """Blob range. All required parameters must be populated in order to send to Azure. - :ivar start_range: Required. Blob start range. This is inclusive. Empty means account start. + :ivar start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str - :ivar end_range: Required. Blob end range. This is exclusive. Empty means account end. + :ivar end_range: Blob end range. This is exclusive. Empty means account end. Required. :vartype end_range: str """ _validation = { - 'start_range': {'required': True}, - 'end_range': {'required': True}, + "start_range": {"required": True}, + "end_range": {"required": True}, } _attribute_map = { - 'start_range': {'key': 'startRange', 'type': 'str'}, - 'end_range': {'key': 'endRange', 'type': 'str'}, + "start_range": {"key": "startRange", "type": "str"}, + "end_range": {"key": "endRange", "type": "str"}, } - def __init__( - self, - *, - start_range: str, - end_range: str, - **kwargs - ): + def __init__(self, *, start_range: str, end_range: str, **kwargs): """ - :keyword start_range: Required. Blob start range. This is inclusive. Empty means account start. + :keyword start_range: Blob start range. This is inclusive. Empty means account start. Required. :paramtype start_range: str - :keyword end_range: Required. Blob end range. This is exclusive. Empty means account end. + :keyword end_range: Blob end range. This is exclusive. Empty means account end. Required. :paramtype end_range: str """ - super(BlobRestoreRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_range = start_range self.end_range = end_range -class BlobRestoreStatus(msrest.serialization.Model): +class BlobRestoreStatus(_serialization.Model): """Blob restore status. Variables are only populated by the server, and will be ignored when sending a request. @@ -996,7 +984,7 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", - "Complete", "Failed". + "Complete", and "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_06_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -1007,33 +995,29 @@ class BlobRestoreStatus(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'restore_id': {'readonly': True}, - 'parameters': {'readonly': True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "restore_id": {"readonly": True}, + "parameters": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'restore_id': {'key': 'restoreId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'BlobRestoreParameters'}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "restore_id": {"key": "restoreId", "type": "str"}, + "parameters": {"key": "parameters", "type": "BlobRestoreParameters"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobRestoreStatus, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.failure_reason = None self.restore_id = None self.parameters = None -class BlobServiceItems(msrest.serialization.Model): +class BlobServiceItems(_serialization.Model): """BlobServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -1043,24 +1027,20 @@ class BlobServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobServiceProperties]'}, + "value": {"key": "value", "type": "[BlobServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class BlobServiceProperties(Resource): +class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attributes """The properties of a storage account’s Blob service. Variables are only populated by the server, and will be ignored when sending a request. @@ -1103,26 +1083,32 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'is_versioning_enabled': {'key': 'properties.isVersioningEnabled', 'type': 'bool'}, - 'automatic_snapshot_policy_enabled': {'key': 'properties.automaticSnapshotPolicyEnabled', 'type': 'bool'}, - 'change_feed': {'key': 'properties.changeFeed', 'type': 'ChangeFeed'}, - 'restore_policy': {'key': 'properties.restorePolicy', 'type': 'RestorePolicyProperties'}, - 'container_delete_retention_policy': {'key': 'properties.containerDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'last_access_time_tracking_policy': {'key': 'properties.lastAccessTimeTrackingPolicy', 'type': 'LastAccessTimeTrackingPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "is_versioning_enabled": {"key": "properties.isVersioningEnabled", "type": "bool"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, + "restore_policy": {"key": "properties.restorePolicy", "type": "RestorePolicyProperties"}, + "container_delete_retention_policy": { + "key": "properties.containerDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "last_access_time_tracking_policy": { + "key": "properties.lastAccessTimeTrackingPolicy", + "type": "LastAccessTimeTrackingPolicy", + }, } def __init__( @@ -1169,7 +1155,7 @@ def __init__( :paramtype last_access_time_tracking_policy: ~azure.mgmt.storage.v2021_06_01.models.LastAccessTimeTrackingPolicy """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.default_service_version = default_service_version @@ -1182,7 +1168,7 @@ def __init__( self.last_access_time_tracking_policy = last_access_time_tracking_policy -class ChangeFeed(msrest.serialization.Model): +class ChangeFeed(_serialization.Model): """The blob service properties for change feed events. :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. @@ -1194,21 +1180,15 @@ class ChangeFeed(msrest.serialization.Model): """ _validation = { - 'retention_in_days': {'maximum': 146000, 'minimum': 1}, + "retention_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_in_days': {'key': 'retentionInDays', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_in_days": {"key": "retentionInDays", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - retention_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, retention_in_days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. :paramtype enabled: bool @@ -1217,12 +1197,12 @@ def __init__( retention of the change feed. :paramtype retention_in_days: int """ - super(ChangeFeed, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.retention_in_days = retention_in_days -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1232,7 +1212,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_06_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1240,30 +1220,26 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CloudErrorAutoGenerated(msrest.serialization.Model): +class CloudErrorAutoGenerated(_serialization.Model): """An error response from the Storage service. :ivar error: An error response from the Storage service. @@ -1271,24 +1247,19 @@ class CloudErrorAutoGenerated(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'CloudErrorBodyAutoGenerated'}, + "error": {"key": "error", "type": "CloudErrorBodyAutoGenerated"}, } - def __init__( - self, - *, - error: Optional["_models.CloudErrorBodyAutoGenerated"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.CloudErrorBodyAutoGenerated"] = None, **kwargs): """ :keyword error: An error response from the Storage service. :paramtype error: ~azure.mgmt.storage.v2021_06_01.models.CloudErrorBodyAutoGenerated """ - super(CloudErrorAutoGenerated, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1305,10 +1276,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -1333,14 +1304,14 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2021_06_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CloudErrorBodyAutoGenerated(msrest.serialization.Model): +class CloudErrorBodyAutoGenerated(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1357,10 +1328,10 @@ class CloudErrorBodyAutoGenerated(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBodyAutoGenerated]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBodyAutoGenerated]"}, } def __init__( @@ -1385,50 +1356,50 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2021_06_01.models.CloudErrorBodyAutoGenerated] """ - super(CloudErrorBodyAutoGenerated, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2021_06_01.models.CorsRuleAllowedMethodsItem] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -1442,24 +1413,24 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2021_06_01.models.CorsRuleAllowedMethodsItem] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -1467,7 +1438,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -1476,31 +1447,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2021_06_01.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -1508,68 +1474,57 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DateAfterCreation(msrest.serialization.Model): +class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. All required parameters must be populated in order to send to Azure. - :ivar days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :vartype days_after_creation_greater_than: float """ _validation = { - 'days_after_creation_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, } - def __init__( - self, - *, - days_after_creation_greater_than: float, - **kwargs - ): + def __init__(self, *, days_after_creation_greater_than: float, **kwargs): """ - :keyword days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :paramtype days_after_creation_greater_than: float """ - super(DateAfterCreation, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_creation_greater_than = days_after_creation_greater_than -class DateAfterModification(msrest.serialization.Model): +class DateAfterModification(_serialization.Model): """Object to define the number of days after object last modification Or last access. Properties daysAfterModificationGreaterThan and daysAfterLastAccessTimeGreaterThan are mutually exclusive. :ivar days_after_modification_greater_than: Value indicating the age in days after last @@ -1582,13 +1537,13 @@ class DateAfterModification(msrest.serialization.Model): """ _validation = { - 'days_after_modification_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_last_access_time_greater_than': {'minimum': 0, 'multiple': 1}, + "days_after_modification_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_access_time_greater_than": {"minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'float'}, - 'days_after_last_access_time_greater_than': {'key': 'daysAfterLastAccessTimeGreaterThan', 'type': 'float'}, + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, + "days_after_last_access_time_greater_than": {"key": "daysAfterLastAccessTimeGreaterThan", "type": "float"}, } def __init__( @@ -1607,7 +1562,7 @@ def __init__( policy. :paramtype days_after_last_access_time_greater_than: float """ - super(DateAfterModification, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_modification_greater_than = days_after_modification_greater_than self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than @@ -1628,24 +1583,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class DeletedAccount(ProxyResource): @@ -1675,34 +1626,30 @@ class DeletedAccount(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'storage_account_resource_id': {'readonly': True}, - 'location': {'readonly': True}, - 'restore_reference': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'deletion_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'location': {'key': 'properties.location', 'type': 'str'}, - 'restore_reference': {'key': 'properties.restoreReference', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, - 'deletion_time': {'key': 'properties.deletionTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccount, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "storage_account_resource_id": {"readonly": True}, + "location": {"readonly": True}, + "restore_reference": {"readonly": True}, + "creation_time": {"readonly": True}, + "deletion_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "location": {"key": "properties.location", "type": "str"}, + "restore_reference": {"key": "properties.restoreReference", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "str"}, + "deletion_time": {"key": "properties.deletionTime", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_account_resource_id = None self.location = None self.restore_reference = None @@ -1710,7 +1657,7 @@ def __init__( self.deletion_time = None -class DeletedAccountListResult(msrest.serialization.Model): +class DeletedAccountListResult(_serialization.Model): """The response from the List Deleted Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1723,70 +1670,60 @@ class DeletedAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeletedAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeletedAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DeletedShare(msrest.serialization.Model): +class DeletedShare(_serialization.Model): """The deleted share to be restored. All required parameters must be populated in order to send to Azure. - :ivar deleted_share_name: Required. Required. Identify the name of the deleted share that will - be restored. + :ivar deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :vartype deleted_share_name: str - :ivar deleted_share_version: Required. Required. Identify the version of the deleted share that - will be restored. + :ivar deleted_share_version: Required. Identify the version of the deleted share that will be + restored. Required. :vartype deleted_share_version: str """ _validation = { - 'deleted_share_name': {'required': True}, - 'deleted_share_version': {'required': True}, + "deleted_share_name": {"required": True}, + "deleted_share_version": {"required": True}, } _attribute_map = { - 'deleted_share_name': {'key': 'deletedShareName', 'type': 'str'}, - 'deleted_share_version': {'key': 'deletedShareVersion', 'type': 'str'}, + "deleted_share_name": {"key": "deletedShareName", "type": "str"}, + "deleted_share_version": {"key": "deletedShareVersion", "type": "str"}, } - def __init__( - self, - *, - deleted_share_name: str, - deleted_share_version: str, - **kwargs - ): + def __init__(self, *, deleted_share_name: str, deleted_share_version: str, **kwargs): """ - :keyword deleted_share_name: Required. Required. Identify the name of the deleted share that - will be restored. + :keyword deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :paramtype deleted_share_name: str - :keyword deleted_share_version: Required. Required. Identify the version of the deleted share - that will be restored. + :keyword deleted_share_version: Required. Identify the version of the deleted share that will + be restored. Required. :paramtype deleted_share_version: str """ - super(DeletedShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.deleted_share_name = deleted_share_name self.deleted_share_version = deleted_share_version -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. @@ -1797,21 +1734,15 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled. :paramtype enabled: bool @@ -1819,12 +1750,12 @@ def __init__( minimum specified value can be 1 and the maximum value can be 365. :paramtype days: int """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -1834,38 +1765,32 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_06_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2021_06_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1877,15 +1802,15 @@ class Encryption(msrest.serialization.Model): """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, - 'encryption_identity': {'key': 'identity', 'type': 'EncryptionIdentity'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, + "encryption_identity": {"key": "identity", "type": "EncryptionIdentity"}, } def __init__( @@ -1901,9 +1826,9 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_06_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2021_06_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1913,7 +1838,7 @@ def __init__( :keyword encryption_identity: The identity to be used with service-side encryption at rest. :paramtype encryption_identity: ~azure.mgmt.storage.v2021_06_01.models.EncryptionIdentity """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption @@ -1921,7 +1846,7 @@ def __init__( self.encryption_identity = encryption_identity -class EncryptionIdentity(msrest.serialization.Model): +class EncryptionIdentity(_serialization.Model): """Encryption identity for the storage account. :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be @@ -1930,21 +1855,16 @@ class EncryptionIdentity(msrest.serialization.Model): """ _attribute_map = { - 'encryption_user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, + "encryption_user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, } - def __init__( - self, - *, - encryption_user_assigned_identity: Optional[str] = None, - **kwargs - ): + def __init__(self, *, encryption_user_assigned_identity: Optional[str] = None, **kwargs): """ :keyword encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be associated with server-side encryption on the storage account. :paramtype encryption_user_assigned_identity: str """ - super(EncryptionIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.encryption_user_assigned_identity = encryption_user_assigned_identity @@ -1962,11 +1882,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Known values are: "Enabled", "Disabled". + Disabled. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1983,23 +1903,23 @@ class EncryptionScope(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'EncryptionScopeKeyVaultProperties'}, - 'require_infrastructure_encryption': {'key': 'properties.requireInfrastructureEncryption', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "EncryptionScopeKeyVaultProperties"}, + "require_infrastructure_encryption": {"key": "properties.requireInfrastructureEncryption", "type": "bool"}, } def __init__( @@ -2013,11 +1933,11 @@ def __init__( ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Known values are: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -2027,7 +1947,7 @@ def __init__( applies a secondary layer of encryption with platform managed keys for data at rest. :paramtype require_infrastructure_encryption: bool """ - super(EncryptionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.state = state self.creation_time = None @@ -2036,7 +1956,7 @@ def __init__( self.require_infrastructure_encryption = require_infrastructure_encryption -class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): +class EncryptionScopeKeyVaultProperties(_serialization.Model): """The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. Variables are only populated by the server, and will be ignored when sending a request. @@ -2053,35 +1973,30 @@ class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_uri': {'key': 'keyUri', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_uri": {"key": "keyUri", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_uri: Optional[str] = None, **kwargs): """ :keyword key_uri: The object identifier for a key vault key object. When applied, the encryption scope will use the key referenced by the identifier to enable customer-managed key support on this encryption scope. :paramtype key_uri: str """ - super(EncryptionScopeKeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_uri = key_uri self.current_versioned_key_identifier = None self.last_key_rotation_timestamp = None -class EncryptionScopeListResult(msrest.serialization.Model): +class EncryptionScopeListResult(_serialization.Model): """List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. Variables are only populated by the server, and will be ignored when sending a request. @@ -2094,27 +2009,23 @@ class EncryptionScopeListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EncryptionScope]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EncryptionScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(EncryptionScopeListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -2128,26 +2039,22 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Known values are: "Service", "Account". + default service key is used. Known values are: "Service" and "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_06_01.models.KeyType """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'key_type': {'key': 'keyType', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "key_type": {"key": "keyType", "type": "str"}, } def __init__( - self, - *, - enabled: Optional[bool] = None, - key_type: Optional[Union[str, "_models.KeyType"]] = None, - **kwargs + self, *, enabled: Optional[bool] = None, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is @@ -2155,16 +2062,16 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Known values are: "Service", "Account". + that a default service key is used. Known values are: "Service" and "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_06_01.models.KeyType """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None self.key_type = key_type -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. :ivar blob: The encryption function of the blob storage service. @@ -2178,10 +2085,10 @@ class EncryptionServices(msrest.serialization.Model): """ _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -2203,14 +2110,14 @@ def __init__( :keyword queue: The encryption function of the queue storage service. :paramtype queue: ~azure.mgmt.storage.v2021_06_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = table self.queue = queue -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -2236,23 +2143,23 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, - 'microsoft_endpoints': {'key': 'microsoftEndpoints', 'type': 'StorageAccountMicrosoftEndpoints'}, - 'internet_endpoints': {'key': 'internetEndpoints', 'type': 'StorageAccountInternetEndpoints'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + "microsoft_endpoints": {"key": "microsoftEndpoints", "type": "StorageAccountMicrosoftEndpoints"}, + "internet_endpoints": {"key": "internetEndpoints", "type": "StorageAccountInternetEndpoints"}, } def __init__( @@ -2270,7 +2177,7 @@ def __init__( :paramtype internet_endpoints: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountInternetEndpoints """ - super(Endpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -2281,7 +2188,7 @@ def __init__( self.internet_endpoints = internet_endpoints -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the storage resource provider. :ivar error: Azure Storage Resource Provider error response body. @@ -2289,24 +2196,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure Storage Resource Provider error response body. :paramtype error: ~azure.mgmt.storage.v2021_06_01.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """Error response body contract. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -2318,17 +2220,11 @@ class ErrorResponseBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. @@ -2337,23 +2233,23 @@ def __init__( interface. :paramtype message: str """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ExtendedLocation(msrest.serialization.Model): +class ExtendedLocation(_serialization.Model): """The complex type of the extended location. :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Known values are: "EdgeZone". + :ivar type: The type of the extended location. "EdgeZone" :vartype type: str or ~azure.mgmt.storage.v2021_06_01.models.ExtendedLocationTypes """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -2366,15 +2262,15 @@ def __init__( """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Known values are: "EdgeZone". + :keyword type: The type of the extended location. "EdgeZone" :paramtype type: str or ~azure.mgmt.storage.v2021_06_01.models.ExtendedLocationTypes """ - super(ExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class FileServiceItems(msrest.serialization.Model): +class FileServiceItems(_serialization.Model): """FileServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -2384,20 +2280,16 @@ class FileServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileServiceProperties]'}, + "value": {"key": "value", "type": "[FileServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -2428,20 +2320,23 @@ class FileServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'share_delete_retention_policy': {'key': 'properties.shareDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'protocol_settings': {'key': 'properties.protocolSettings', 'type': 'ProtocolSettings'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "share_delete_retention_policy": { + "key": "properties.shareDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "protocol_settings": {"key": "properties.protocolSettings", "type": "ProtocolSettings"}, } def __init__( @@ -2463,14 +2358,14 @@ def __init__( :keyword protocol_settings: Protocol settings for file service. :paramtype protocol_settings: ~azure.mgmt.storage.v2021_06_01.models.ProtocolSettings """ - super(FileServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.share_delete_retention_policy = share_delete_retention_policy self.protocol_settings = protocol_settings -class FileShare(AzureEntityResource): +class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the file share, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -2493,10 +2388,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_06_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_06_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2508,7 +2403,7 @@ class FileShare(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2516,14 +2411,14 @@ class FileShare(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseStatus :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Known values are: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_06_01.models.SignedIdentifier] @@ -2533,48 +2428,48 @@ class FileShare(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2595,19 +2490,19 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_06_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_06_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_06_01.models.SignedIdentifier] """ - super(FileShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2628,7 +2523,7 @@ def __init__( self.snapshot_time = None -class FileShareItem(AzureEntityResource): +class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The file share properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -2651,10 +2546,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_06_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_06_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2666,7 +2561,7 @@ class FileShareItem(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2674,14 +2569,14 @@ class FileShareItem(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseStatus :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Known values are: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_06_01.models.SignedIdentifier] @@ -2691,48 +2586,48 @@ class FileShareItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2753,19 +2648,19 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_06_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_06_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_06_01.models.SignedIdentifier] """ - super(FileShareItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2786,7 +2681,7 @@ def __init__( self.snapshot_time = None -class FileShareItems(msrest.serialization.Model): +class FileShareItems(_serialization.Model): """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. Variables are only populated by the server, and will be ignored when sending a request. @@ -2799,27 +2694,23 @@ class FileShareItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileShareItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileShareItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2828,7 +2719,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_06_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2841,30 +2732,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2875,8 +2762,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_06_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2886,16 +2773,16 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( @@ -2906,8 +2793,8 @@ def __init__( **kwargs ): """ - :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_06_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2915,7 +2802,7 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.storage.v2021_06_01.models.UserAssignedIdentity] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type @@ -2941,7 +2828,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2959,22 +2846,25 @@ class ImmutabilityPolicy(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'properties.allowProtectedAppendWritesAll', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -3003,14 +2893,14 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None self.allow_protected_append_writes = allow_protected_append_writes self.allow_protected_append_writes_all = allow_protected_append_writes_all -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3023,7 +2913,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -3041,18 +2931,21 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'properties.allowProtectedAppendWritesAll', 'type': 'bool'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -3081,7 +2974,7 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days @@ -3090,7 +2983,7 @@ def __init__( self.allow_protected_append_writes_all = allow_protected_append_writes_all -class ImmutableStorageAccount(msrest.serialization.Model): +class ImmutableStorageAccount(_serialization.Model): """This property enables and defines account-level immutability. Enabling the feature auto-enables Blob Versioning. :ivar enabled: A boolean flag which enables account-level immutability. All the containers @@ -3106,8 +2999,8 @@ class ImmutableStorageAccount(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'immutability_policy': {'key': 'immutabilityPolicy', 'type': 'AccountImmutabilityPolicyProperties'}, + "enabled": {"key": "enabled", "type": "bool"}, + "immutability_policy": {"key": "immutabilityPolicy", "type": "AccountImmutabilityPolicyProperties"}, } def __init__( @@ -3129,12 +3022,12 @@ def __init__( :paramtype immutability_policy: ~azure.mgmt.storage.v2021_06_01.models.AccountImmutabilityPolicyProperties """ - super(ImmutableStorageAccount, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.immutability_policy = immutability_policy -class ImmutableStorageWithVersioning(msrest.serialization.Model): +class ImmutableStorageWithVersioning(_serialization.Model): """Object level immutability properties of the container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3145,81 +3038,68 @@ class ImmutableStorageWithVersioning(msrest.serialization.Model): :ivar time_stamp: Returns the date and time the object level immutability was enabled. :vartype time_stamp: ~datetime.datetime :ivar migration_state: This property denotes the container level immutability to object level - immutability migration state. Known values are: "InProgress", "Completed". + immutability migration state. Known values are: "InProgress" and "Completed". :vartype migration_state: str or ~azure.mgmt.storage.v2021_06_01.models.MigrationState """ _validation = { - 'time_stamp': {'readonly': True}, - 'migration_state': {'readonly': True}, + "time_stamp": {"readonly": True}, + "migration_state": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'migration_state': {'key': 'migrationState', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "migration_state": {"key": "migrationState", "type": "str"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: This is an immutable property, when set to true it enables object level immutability at the container level. :paramtype enabled: bool """ - super(ImmutableStorageWithVersioning, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.time_stamp = None self.migration_state = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyCreationTime(msrest.serialization.Model): +class KeyCreationTime(_serialization.Model): """Storage account keys creation time. :ivar key1: @@ -3229,60 +3109,49 @@ class KeyCreationTime(msrest.serialization.Model): """ _attribute_map = { - 'key1': {'key': 'key1', 'type': 'iso-8601'}, - 'key2': {'key': 'key2', 'type': 'iso-8601'}, + "key1": {"key": "key1", "type": "iso-8601"}, + "key2": {"key": "key2", "type": "iso-8601"}, } - def __init__( - self, - *, - key1: Optional[datetime.datetime] = None, - key2: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, key1: Optional[datetime.datetime] = None, key2: Optional[datetime.datetime] = None, **kwargs): """ :keyword key1: :paramtype key1: ~datetime.datetime :keyword key2: :paramtype key2: ~datetime.datetime """ - super(KeyCreationTime, self).__init__(**kwargs) + super().__init__(**kwargs) self.key1 = key1 self.key2 = key2 -class KeyPolicy(msrest.serialization.Model): +class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar key_expiration_period_in_days: Required. The key expiration period in days. + :ivar key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int """ _validation = { - 'key_expiration_period_in_days': {'required': True}, + "key_expiration_period_in_days": {"required": True}, } _attribute_map = { - 'key_expiration_period_in_days': {'key': 'keyExpirationPeriodInDays', 'type': 'int'}, + "key_expiration_period_in_days": {"key": "keyExpirationPeriodInDays", "type": "int"}, } - def __init__( - self, - *, - key_expiration_period_in_days: int, - **kwargs - ): + def __init__(self, *, key_expiration_period_in_days: int, **kwargs): """ - :keyword key_expiration_period_in_days: Required. The key expiration period in days. + :keyword key_expiration_period_in_days: The key expiration period in days. Required. :paramtype key_expiration_period_in_days: int """ - super(KeyPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_expiration_period_in_days = key_expiration_period_in_days -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. Variables are only populated by the server, and will be ignored when sending a request. @@ -3301,16 +3170,16 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } def __init__( @@ -3329,7 +3198,7 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri @@ -3337,15 +3206,15 @@ def __init__( self.last_key_rotation_timestamp = None -class LastAccessTimeTrackingPolicy(msrest.serialization.Model): +class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. All required parameters must be populated in order to send to Azure. - :ivar enable: Required. When set to true last access time based tracking is enabled. + :ivar enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Known values are: "AccessTimeTracking". + read only. "AccessTimeTracking" :vartype name: str or ~azure.mgmt.storage.v2021_06_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3357,14 +3226,14 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): """ _validation = { - 'enable': {'required': True}, + "enable": {"required": True}, } _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tracking_granularity_in_days': {'key': 'trackingGranularityInDays', 'type': 'int'}, - 'blob_type': {'key': 'blobType', 'type': '[str]'}, + "enable": {"key": "enable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "tracking_granularity_in_days": {"key": "trackingGranularityInDays", "type": "int"}, + "blob_type": {"key": "blobType", "type": "[str]"}, } def __init__( @@ -3377,10 +3246,10 @@ def __init__( **kwargs ): """ - :keyword enable: Required. When set to true last access time based tracking is enabled. + :keyword enable: When set to true last access time based tracking is enabled. Required. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Known values are: "AccessTimeTracking". + currently read only. "AccessTimeTracking" :paramtype name: str or ~azure.mgmt.storage.v2021_06_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3390,20 +3259,20 @@ def __init__( supported value. This field is currently read only. :paramtype blob_type: list[str] """ - super(LastAccessTimeTrackingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enable = enable self.name = name self.tracking_granularity_in_days = tracking_granularity_in_days self.blob_type = blob_type -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3419,15 +3288,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -3441,8 +3310,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3456,7 +3325,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -3464,7 +3333,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -3475,17 +3344,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -3493,18 +3356,18 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LeaseShareRequest(msrest.serialization.Model): +class LeaseShareRequest(_serialization.Model): """Lease Share request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3520,15 +3383,15 @@ class LeaseShareRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -3542,8 +3405,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3557,7 +3420,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseShareRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -3565,7 +3428,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseShareResponse(msrest.serialization.Model): +class LeaseShareResponse(_serialization.Model): """Lease Share response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -3576,17 +3439,11 @@ class LeaseShareResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the share, or to renew, change, or release the lease. @@ -3594,12 +3451,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseShareResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3611,8 +3468,8 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] :ivar allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks @@ -3621,39 +3478,33 @@ class LegalHold(msrest.serialization.Model): """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, } - def __init__( - self, - *, - tags: List[str], - allow_protected_append_writes_all: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, tags: List[str], allow_protected_append_writes_all: Optional[bool] = None, **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes_all: bool """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags self.allow_protected_append_writes_all = allow_protected_append_writes_all -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3663,7 +3514,7 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2021_06_01.models.TagProperty] :ivar protected_append_writes_history: Protected append blob writes history. :vartype protected_append_writes_history: @@ -3671,13 +3522,16 @@ class LegalHoldProperties(msrest.serialization.Model): """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, - 'protected_append_writes_history': {'key': 'protectedAppendWritesHistory', 'type': 'ProtectedAppendWritesHistory'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, + "protected_append_writes_history": { + "key": "protectedAppendWritesHistory", + "type": "ProtectedAppendWritesHistory", + }, } def __init__( @@ -3688,19 +3542,19 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2021_06_01.models.TagProperty] :keyword protected_append_writes_history: Protected append blob writes history. :paramtype protected_append_writes_history: ~azure.mgmt.storage.v2021_06_01.models.ProtectedAppendWritesHistory """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags self.protected_append_writes_history = protected_append_writes_history -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3710,24 +3564,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListBlobInventoryPolicy(msrest.serialization.Model): +class ListBlobInventoryPolicy(_serialization.Model): """List of blob inventory policies returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3737,24 +3587,20 @@ class ListBlobInventoryPolicy(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobInventoryPolicy]'}, + "value": {"key": "value", "type": "[BlobInventoryPolicy]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListBlobInventoryPolicy, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -3784,17 +3630,18 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_06_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3824,48 +3671,51 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, - 'enable_nfs_v3_root_squash': {'key': 'properties.enableNfsV3RootSquash', 'type': 'bool'}, - 'enable_nfs_v3_all_squash': {'key': 'properties.enableNfsV3AllSquash', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, } def __init__( @@ -3888,7 +3738,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -3902,7 +3752,7 @@ def __init__( :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. :paramtype enable_nfs_v3_all_squash: bool """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -3924,7 +3774,7 @@ def __init__( self.enable_nfs_v3_all_squash = enable_nfs_v3_all_squash -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. Variables are only populated by the server, and will be ignored when sending a request. @@ -3937,22 +3787,18 @@ class ListContainerItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListContainerItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3975,33 +3821,28 @@ class ListQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(ListQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata -class ListQueueResource(msrest.serialization.Model): +class ListQueueResource(_serialization.Model): """Response schema. Contains list of queues returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -4013,27 +3854,23 @@ class ListQueueResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListQueueServices(msrest.serialization.Model): +class ListQueueServices(_serialization.Model): """ListQueueServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -4043,24 +3880,20 @@ class ListQueueServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueServiceProperties]'}, + "value": {"key": "value", "type": "[QueueServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -4070,24 +3903,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class ListTableResource(msrest.serialization.Model): +class ListTableResource(_serialization.Model): """Response schema. Contains list of tables returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -4099,27 +3928,23 @@ class ListTableResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Table]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Table]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListTableServices(msrest.serialization.Model): +class ListTableServices(_serialization.Model): """ListTableServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -4129,20 +3954,16 @@ class ListTableServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TableServiceProperties]'}, + "value": {"key": "value", "type": "[TableServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -4167,37 +3988,32 @@ class ManagementPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.ManagementPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :paramtype policy: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicySchema """ - super(ManagementPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.policy = policy -class ManagementPolicyAction(msrest.serialization.Model): +class ManagementPolicyAction(_serialization.Model): """Actions are applied to the filtered blobs when the execution condition is met. :ivar base_blob: The management policy action for base blob. @@ -4209,9 +4025,9 @@ class ManagementPolicyAction(msrest.serialization.Model): """ _attribute_map = { - 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, - 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, - 'version': {'key': 'version', 'type': 'ManagementPolicyVersion'}, + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, + "version": {"key": "version", "type": "ManagementPolicyVersion"}, } def __init__( @@ -4230,13 +4046,13 @@ def __init__( :keyword version: The management policy action for version. :paramtype version: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyVersion """ - super(ManagementPolicyAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_blob = base_blob self.snapshot = snapshot self.version = version -class ManagementPolicyBaseBlob(msrest.serialization.Model): +class ManagementPolicyBaseBlob(_serialization.Model): """Management policy action for base blob. :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot @@ -4253,10 +4069,10 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, - 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, - 'enable_auto_tier_to_hot_from_cool': {'key': 'enableAutoTierToHotFromCool', 'type': 'bool'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, + "enable_auto_tier_to_hot_from_cool": {"key": "enableAutoTierToHotFromCool", "type": "bool"}, } def __init__( @@ -4282,31 +4098,31 @@ def __init__( tierToCool.daysAfterLastAccessTimeGreaterThan. :paramtype enable_auto_tier_to_hot_from_cool: bool """ - super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool -class ManagementPolicyDefinition(msrest.serialization.Model): +class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. All required parameters must be populated in order to send to Azure. - :ivar actions: Required. An object that defines the action set. + :ivar actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyAction :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyFilter """ _validation = { - 'actions': {'required': True}, + "actions": {"required": True}, } _attribute_map = { - 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, - 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, } def __init__( @@ -4317,25 +4133,25 @@ def __init__( **kwargs ): """ - :keyword actions: Required. An object that defines the action set. + :keyword actions: An object that defines the action set. Required. :paramtype actions: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyAction :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyFilter """ - super(ManagementPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.filters = filters -class ManagementPolicyFilter(msrest.serialization.Model): +class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :ivar blob_types: An array of predefined enum values. Currently blockBlob supports all tiering + and delete actions. Only delete actions are supported for appendBlob. Required. :vartype blob_types: list[str] :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. @@ -4343,13 +4159,13 @@ class ManagementPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'blob_index_match': {'key': 'blobIndexMatch', 'type': '[TagFilter]'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "blob_index_match": {"key": "blobIndexMatch", "type": "[TagFilter]"}, } def __init__( @@ -4363,46 +4179,46 @@ def __init__( """ :keyword prefix_match: An array of strings for prefixes to be match. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :keyword blob_types: An array of predefined enum values. Currently blockBlob supports all + tiering and delete actions. Only delete actions are supported for appendBlob. Required. :paramtype blob_types: list[str] :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. :paramtype blob_index_match: list[~azure.mgmt.storage.v2021_06_01.models.TagFilter] """ - super(ManagementPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.blob_index_match = blob_index_match -class ManagementPolicyRule(msrest.serialization.Model): +class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. :ivar enabled: Rule is enabled if set to true. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" :vartype type: str or ~azure.mgmt.storage.v2021_06_01.models.RuleType - :ivar definition: Required. An object that defines the Lifecycle rule. + :ivar definition: An object that defines the Lifecycle rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyDefinition """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - 'definition': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, } def __init__( @@ -4417,55 +4233,52 @@ def __init__( """ :keyword enabled: Rule is enabled if set to true. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" :paramtype type: str or ~azure.mgmt.storage.v2021_06_01.models.RuleType - :keyword definition: Required. An object that defines the Lifecycle rule. + :keyword definition: An object that defines the Lifecycle rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyDefinition """ - super(ManagementPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.type = type self.definition = definition -class ManagementPolicySchema(msrest.serialization.Model): +class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. All required parameters must be populated in order to send to Azure. - :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :vartype rules: list[~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyRule] """ _validation = { - 'rules': {'required': True}, + "rules": {"required": True}, } _attribute_map = { - 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, } - def __init__( - self, - *, - rules: List["_models.ManagementPolicyRule"], - **kwargs - ): + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): """ - :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :paramtype rules: list[~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyRule] """ - super(ManagementPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.rules = rules -class ManagementPolicySnapShot(msrest.serialization.Model): +class ManagementPolicySnapShot(_serialization.Model): """Management policy action for snapshot. :ivar tier_to_cool: The function to tier blob snapshot to cool storage. Support blob snapshot @@ -4479,9 +4292,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -4502,13 +4315,13 @@ def __init__( :keyword delete: The function to delete the blob snapshot. :paramtype delete: ~azure.mgmt.storage.v2021_06_01.models.DateAfterCreation """ - super(ManagementPolicySnapShot, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class ManagementPolicyVersion(msrest.serialization.Model): +class ManagementPolicyVersion(_serialization.Model): """Management policy action for blob version. :ivar tier_to_cool: The function to tier blob version to cool storage. Support blob version @@ -4522,9 +4335,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -4545,13 +4358,13 @@ def __init__( :keyword delete: The function to delete the blob version. :paramtype delete: ~azure.mgmt.storage.v2021_06_01.models.DateAfterCreation """ - super(ManagementPolicyVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -4575,15 +4388,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -4620,7 +4433,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -4632,7 +4445,7 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class Multichannel(msrest.serialization.Model): +class Multichannel(_serialization.Model): """Multichannel setting. Applies to Premium FileStorage only. :ivar enabled: Indicates whether multichannel is enabled. @@ -4640,32 +4453,27 @@ class Multichannel(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Indicates whether multichannel is enabled. :paramtype enabled: bool """ - super(Multichannel, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_06_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_06_01.models.ResourceAccessRule] @@ -4673,28 +4481,28 @@ class NetworkRuleSet(msrest.serialization.Model): :vartype virtual_network_rules: list[~azure.mgmt.storage.v2021_06_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_06_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2021_06_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'resource_access_rules': {'key': 'resourceAccessRules', 'type': '[ResourceAccessRule]'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "resource_access_rules": {"key": "resourceAccessRules", "type": "[ResourceAccessRule]"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, @@ -4704,7 +4512,7 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_06_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4714,11 +4522,11 @@ def __init__( list[~azure.mgmt.storage.v2021_06_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_06_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2021_06_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.resource_access_rules = resource_access_rules self.virtual_network_rules = virtual_network_rules @@ -4726,7 +4534,7 @@ def __init__( self.default_action = default_action -class ObjectReplicationPolicies(msrest.serialization.Model): +class ObjectReplicationPolicies(_serialization.Model): """List storage account object replication policies. :ivar value: The replication policy between two storage accounts. @@ -4734,20 +4542,15 @@ class ObjectReplicationPolicies(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ObjectReplicationPolicy]'}, + "value": {"key": "value", "type": "[ObjectReplicationPolicy]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ObjectReplicationPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs): """ :keyword value: The replication policy between two storage accounts. :paramtype value: list[~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy] """ - super(ObjectReplicationPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4779,22 +4582,22 @@ class ObjectReplicationPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_id': {'readonly': True}, - 'enabled_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_id": {"readonly": True}, + "enabled_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, - 'enabled_time': {'key': 'properties.enabledTime', 'type': 'iso-8601'}, - 'source_account': {'key': 'properties.sourceAccount', 'type': 'str'}, - 'destination_account': {'key': 'properties.destinationAccount', 'type': 'str'}, - 'rules': {'key': 'properties.rules', 'type': '[ObjectReplicationPolicyRule]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "enabled_time": {"key": "properties.enabledTime", "type": "iso-8601"}, + "source_account": {"key": "properties.sourceAccount", "type": "str"}, + "destination_account": {"key": "properties.destinationAccount", "type": "str"}, + "rules": {"key": "properties.rules", "type": "[ObjectReplicationPolicyRule]"}, } def __init__( @@ -4815,7 +4618,7 @@ def __init__( :keyword rules: The storage account object replication rules. :paramtype rules: list[~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicyRule] """ - super(ObjectReplicationPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_id = None self.enabled_time = None self.source_account = source_account @@ -4823,7 +4626,7 @@ def __init__( self.rules = rules -class ObjectReplicationPolicyFilter(msrest.serialization.Model): +class ObjectReplicationPolicyFilter(_serialization.Model): """Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the filter. If multiple filters are defined, a logical AND is performed on all filters. :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin @@ -4835,17 +4638,11 @@ class ObjectReplicationPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'min_creation_time': {'key': 'minCreationTime', 'type': 'str'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "min_creation_time": {"key": "minCreationTime", "type": "str"}, } - def __init__( - self, - *, - prefix_match: Optional[List[str]] = None, - min_creation_time: Optional[str] = None, - **kwargs - ): + def __init__(self, *, prefix_match: Optional[List[str]] = None, min_creation_time: Optional[str] = None, **kwargs): """ :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. @@ -4854,12 +4651,12 @@ def __init__( It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. :paramtype min_creation_time: str """ - super(ObjectReplicationPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.min_creation_time = min_creation_time -class ObjectReplicationPolicyRule(msrest.serialization.Model): +class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. All required parameters must be populated in order to send to Azure. @@ -4867,24 +4664,24 @@ class ObjectReplicationPolicyRule(msrest.serialization.Model): :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :vartype rule_id: str - :ivar source_container: Required. Required. Source container name. + :ivar source_container: Required. Source container name. Required. :vartype source_container: str - :ivar destination_container: Required. Required. Destination container name. + :ivar destination_container: Required. Destination container name. Required. :vartype destination_container: str :ivar filters: Optional. An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicyFilter """ _validation = { - 'source_container': {'required': True}, - 'destination_container': {'required': True}, + "source_container": {"required": True}, + "destination_container": {"required": True}, } _attribute_map = { - 'rule_id': {'key': 'ruleId', 'type': 'str'}, - 'source_container': {'key': 'sourceContainer', 'type': 'str'}, - 'destination_container': {'key': 'destinationContainer', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': 'ObjectReplicationPolicyFilter'}, + "rule_id": {"key": "ruleId", "type": "str"}, + "source_container": {"key": "sourceContainer", "type": "str"}, + "destination_container": {"key": "destinationContainer", "type": "str"}, + "filters": {"key": "filters", "type": "ObjectReplicationPolicyFilter"}, } def __init__( @@ -4900,21 +4697,21 @@ def __init__( :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :paramtype rule_id: str - :keyword source_container: Required. Required. Source container name. + :keyword source_container: Required. Source container name. Required. :paramtype source_container: str - :keyword destination_container: Required. Required. Destination container name. + :keyword destination_container: Required. Destination container name. Required. :paramtype destination_container: str :keyword filters: Optional. An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicyFilter """ - super(ObjectReplicationPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.rule_id = rule_id self.source_container = source_container self.destination_container = destination_container self.filters = filters -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -4928,10 +4725,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -4953,14 +4750,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2021_06_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -4974,10 +4771,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -4999,14 +4796,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -5014,24 +4811,19 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2021_06_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -5041,20 +4833,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -5078,25 +4866,28 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_06_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -5114,13 +4905,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.storage.v2021_06_01.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """List of private endpoint connection associated with the specified storage account. :ivar value: Array of private endpoint connections. @@ -5128,20 +4919,15 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -5167,39 +4953,34 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "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, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): """ :keyword required_zone_names: The private link resource Private link DNS zone name. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. @@ -5207,28 +4988,23 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.storage.v2021_06_01.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", and "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -5239,9 +5015,9 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'action_required': {'key': 'actionRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "action_required": {"key": "actionRequired", "type": "str"}, } def __init__( @@ -5254,7 +5030,7 @@ def __init__( ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", and "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -5263,13 +5039,13 @@ def __init__( updates on the consumer. :paramtype action_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.action_required = action_required -class ProtectedAppendWritesHistory(msrest.serialization.Model): +class ProtectedAppendWritesHistory(_serialization.Model): """Protected append writes history setting for the blob container with Legal holds. Variables are only populated by the server, and will be ignored when sending a request. @@ -5283,32 +5059,27 @@ class ProtectedAppendWritesHistory(msrest.serialization.Model): """ _validation = { - 'timestamp': {'readonly': True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - allow_protected_append_writes_all: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, allow_protected_append_writes_all: Optional[bool] = None, **kwargs): """ :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes_all: bool """ - super(ProtectedAppendWritesHistory, self).__init__(**kwargs) + super().__init__(**kwargs) self.allow_protected_append_writes_all = allow_protected_append_writes_all self.timestamp = None -class ProtocolSettings(msrest.serialization.Model): +class ProtocolSettings(_serialization.Model): """Protocol settings for file service. :ivar smb: Setting for SMB protocol. @@ -5316,20 +5087,15 @@ class ProtocolSettings(msrest.serialization.Model): """ _attribute_map = { - 'smb': {'key': 'smb', 'type': 'SmbSetting'}, + "smb": {"key": "smb", "type": "SmbSetting"}, } - def __init__( - self, - *, - smb: Optional["_models.SmbSetting"] = None, - **kwargs - ): + def __init__(self, *, smb: Optional["_models.SmbSetting"] = None, **kwargs): """ :keyword smb: Setting for SMB protocol. :paramtype smb: ~azure.mgmt.storage.v2021_06_01.models.SmbSetting """ - super(ProtocolSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.smb = smb @@ -5353,35 +5119,30 @@ class QueueServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Queue service. :paramtype cors: ~azure.mgmt.storage.v2021_06_01.models.CorsRules """ - super(QueueServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class ResourceAccessRule(msrest.serialization.Model): +class ResourceAccessRule(_serialization.Model): """Resource Access Rule. :ivar tenant_id: Tenant Id. @@ -5391,36 +5152,30 @@ class ResourceAccessRule(msrest.serialization.Model): """ _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__( - self, - *, - tenant_id: Optional[str] = None, - resource_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tenant_id: Optional[str] = None, resource_id: Optional[str] = None, **kwargs): """ :keyword tenant_id: Tenant Id. :paramtype tenant_id: str :keyword resource_id: Resource Id. :paramtype resource_id: str """ - super(ResourceAccessRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.tenant_id = tenant_id self.resource_id = resource_id -class RestorePolicyProperties(msrest.serialization.Model): +class RestorePolicyProperties(_serialization.Model): """The blob service properties for blob restore policy. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Blob restore is enabled if set to true. + :ivar enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool :ivar days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. @@ -5432,41 +5187,35 @@ class RestorePolicyProperties(msrest.serialization.Model): """ _validation = { - 'enabled': {'required': True}, - 'days': {'maximum': 365, 'minimum': 1}, - 'last_enabled_time': {'readonly': True}, - 'min_restore_time': {'readonly': True}, + "enabled": {"required": True}, + "days": {"maximum": 365, "minimum": 1}, + "last_enabled_time": {"readonly": True}, + "min_restore_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'min_restore_time': {'key': 'minRestoreTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "min_restore_time": {"key": "minRestoreTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: bool, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: bool, days: Optional[int] = None, **kwargs): """ - :keyword enabled: Required. Blob restore is enabled if set to true. + :keyword enabled: Blob restore is enabled if set to true. Required. :paramtype enabled: bool :keyword days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. :paramtype days: int """ - super(RestorePolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days self.last_enabled_time = None self.min_restore_time = None -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -5479,45 +5228,40 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_06_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_06_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class RoutingPreference(msrest.serialization.Model): +class RoutingPreference(_serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_06_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5528,9 +5272,9 @@ class RoutingPreference(msrest.serialization.Model): """ _attribute_map = { - 'routing_choice': {'key': 'routingChoice', 'type': 'str'}, - 'publish_microsoft_endpoints': {'key': 'publishMicrosoftEndpoints', 'type': 'bool'}, - 'publish_internet_endpoints': {'key': 'publishInternetEndpoints', 'type': 'bool'}, + "routing_choice": {"key": "routingChoice", "type": "str"}, + "publish_microsoft_endpoints": {"key": "publishMicrosoftEndpoints", "type": "bool"}, + "publish_internet_endpoints": {"key": "publishInternetEndpoints", "type": "bool"}, } def __init__( @@ -5543,7 +5287,7 @@ def __init__( ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_06_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5552,72 +5296,66 @@ def __init__( storage endpoints are to be published. :paramtype publish_internet_endpoints: bool """ - super(RoutingPreference, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_choice = routing_choice self.publish_microsoft_endpoints = publish_microsoft_endpoints self.publish_internet_endpoints = publish_internet_endpoints -class SasPolicy(msrest.serialization.Model): +class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :ivar sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str - :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :ivar expiration_action: The SAS expiration action. Can only be Log. "Log" :vartype expiration_action: str or ~azure.mgmt.storage.v2021_06_01.models.ExpirationAction """ _validation = { - 'sas_expiration_period': {'required': True}, - 'expiration_action': {'required': True}, + "sas_expiration_period": {"required": True}, + "expiration_action": {"required": True}, } _attribute_map = { - 'sas_expiration_period': {'key': 'sasExpirationPeriod', 'type': 'str'}, - 'expiration_action': {'key': 'expirationAction', 'type': 'str'}, + "sas_expiration_period": {"key": "sasExpirationPeriod", "type": "str"}, + "expiration_action": {"key": "expirationAction", "type": "str"}, } def __init__( - self, - *, - sas_expiration_period: str, - expiration_action: Union[str, "_models.ExpirationAction"] = "Log", - **kwargs + self, *, sas_expiration_period: str, expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs ): """ - :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :keyword sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :paramtype sas_expiration_period: str - :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :keyword expiration_action: The SAS expiration action. Can only be Log. "Log" :paramtype expiration_action: str or ~azure.mgmt.storage.v2021_06_01.models.ExpirationAction """ - super(SasPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_expiration_period = sas_expiration_period self.expiration_action = expiration_action -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2021_06_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_06_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_06_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -5649,29 +5387,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, - } - - _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, + } + + _attribute_map = { + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -5698,20 +5436,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_06_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_06_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_06_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -5742,7 +5481,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -5763,7 +5502,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -5772,25 +5511,20 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2021_06_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class SignedIdentifier(msrest.serialization.Model): +class SignedIdentifier(_serialization.Model): """SignedIdentifier. :ivar id: An unique identifier of the stored access policy. @@ -5800,14 +5534,14 @@ class SignedIdentifier(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'access_policy': {'key': 'accessPolicy', 'type': 'AccessPolicy'}, + "id": {"key": "id", "type": "str"}, + "access_policy": {"key": "accessPolicy", "type": "AccessPolicy"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin access_policy: Optional["_models.AccessPolicy"] = None, **kwargs ): @@ -5817,57 +5551,52 @@ def __init__( :keyword access_policy: Access policy. :paramtype access_policy: ~azure.mgmt.storage.v2021_06_01.models.AccessPolicy """ - super(SignedIdentifier, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.access_policy = access_policy -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_06_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_06_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_06_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -5880,45 +5609,41 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Storage SKU and its properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_06_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_06_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -5932,22 +5657,22 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -5958,16 +5683,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_06_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2021_06_01.models.Restriction] """ - super(SkuInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -5977,7 +5702,7 @@ def __init__( self.restrictions = restrictions -class SmbSetting(msrest.serialization.Model): +class SmbSetting(_serialization.Model): """Setting for SMB protocol. :ivar multichannel: Multichannel setting. Applies to Premium FileStorage only. @@ -5997,11 +5722,11 @@ class SmbSetting(msrest.serialization.Model): """ _attribute_map = { - 'multichannel': {'key': 'multichannel', 'type': 'Multichannel'}, - 'versions': {'key': 'versions', 'type': 'str'}, - 'authentication_methods': {'key': 'authenticationMethods', 'type': 'str'}, - 'kerberos_ticket_encryption': {'key': 'kerberosTicketEncryption', 'type': 'str'}, - 'channel_encryption': {'key': 'channelEncryption', 'type': 'str'}, + "multichannel": {"key": "multichannel", "type": "Multichannel"}, + "versions": {"key": "versions", "type": "str"}, + "authentication_methods": {"key": "authenticationMethods", "type": "str"}, + "kerberos_ticket_encryption": {"key": "kerberosTicketEncryption", "type": "str"}, + "channel_encryption": {"key": "channelEncryption", "type": "str"}, } def __init__( @@ -6030,7 +5755,7 @@ def __init__( AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. :paramtype channel_encryption: str """ - super(SmbSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.multichannel = multichannel self.versions = versions self.authentication_methods = authentication_methods @@ -6053,46 +5778,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -6107,21 +5826,21 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_06_01.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_06_01.models.Identity :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_06_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_06_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -6130,7 +5849,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_06_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -6142,7 +5861,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_06_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -6162,7 +5881,7 @@ class StorageAccount(TrackedResource): unencrypted. :vartype encryption: ~azure.mgmt.storage.v2021_06_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6180,7 +5899,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -6197,7 +5916,7 @@ class StorageAccount(TrackedResource): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6213,7 +5932,7 @@ class StorageAccount(TrackedResource): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess @@ -6225,80 +5944,89 @@ class StorageAccount(TrackedResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'sas_policy': {'readonly': True}, - 'key_policy': {'readonly': True}, - 'key_creation_time': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'blob_restore_status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'key_creation_time': {'key': 'properties.keyCreationTime', 'type': 'KeyCreationTime'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'blob_restore_status': {'key': 'properties.blobRestoreStatus', 'type': 'BlobRestoreStatus'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "sas_policy": {"readonly": True}, + "key_policy": {"readonly": True}, + "key_creation_time": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "blob_restore_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "key_creation_time": {"key": "properties.keyCreationTime", "type": "KeyCreationTime"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "blob_restore_status": {"key": "properties.blobRestoreStatus", "type": "BlobRestoreStatus"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -6321,9 +6049,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_06_01.models.Identity @@ -6339,7 +6067,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6350,7 +6078,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6367,7 +6095,7 @@ def __init__( :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess :keyword immutable_storage_with_versioning: The property is immutable and can only be set to @@ -6376,7 +6104,7 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_06_01.models.ImmutableStorageAccount """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -6416,74 +6144,69 @@ def __init__( self.immutable_storage_with_versioning = immutable_storage_with_versioning -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_06_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str :ivar extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :vartype extended_location: ~azure.mgmt.storage.v2021_06_01.models.ExtendedLocation - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_06_01.models.Identity :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess @@ -6501,7 +6224,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_06_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6513,7 +6236,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6524,7 +6247,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6547,40 +6270,46 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, - } - - def __init__( + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + } + + def __init__( # pylint: disable=too-many-locals self, *, sku: "_models.Sku", @@ -6611,30 +6340,30 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2021_06_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str :keyword extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :paramtype extended_location: ~azure.mgmt.storage.v2021_06_01.models.ExtendedLocation - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_06_01.models.Identity :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess :keyword sas_policy: SasPolicy assigned to the storage account. @@ -6651,7 +6380,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_06_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6663,7 +6392,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6674,7 +6403,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6695,7 +6424,7 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_06_01.models.ImmutableStorageAccount """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -6723,7 +6452,7 @@ def __init__( self.immutable_storage_with_versioning = immutable_storage_with_versioning -class StorageAccountInternetEndpoints(msrest.serialization.Model): +class StorageAccountInternetEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -6739,33 +6468,29 @@ class StorageAccountInternetEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountInternetEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.file = None self.web = None self.dfs = None -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -6775,40 +6500,36 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_06_01.models.KeyPermission :ivar creation_time: Creation time of the key, in round trip date format. :vartype creation_time: ~datetime.datetime """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, - 'creation_time': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, + "creation_time": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None self.creation_time = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -6819,24 +6540,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -6849,27 +6566,23 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): +class StorageAccountMicrosoftEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -6889,30 +6602,26 @@ class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountMicrosoftEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -6921,55 +6630,50 @@ def __init__( self.dfs = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2, kerb1, kerb2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2, kerb1, kerb2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2021_06_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_06_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -6983,7 +6687,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar key_policy: KeyPolicy assigned to the storage account. :vartype key_policy: ~azure.mgmt.storage.v2021_06_01.models.KeyPolicy :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6994,7 +6698,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_06_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -7005,7 +6709,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7019,7 +6723,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess @@ -7031,27 +6735,33 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, } def __init__( @@ -7085,16 +6795,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2021_06_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_06_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_06_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7108,7 +6818,7 @@ def __init__( :keyword key_policy: KeyPolicy assigned to the storage account. :paramtype key_policy: ~azure.mgmt.storage.v2021_06_01.models.KeyPolicy :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_06_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7120,7 +6830,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_06_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_06_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -7131,7 +6841,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_06_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7146,7 +6856,7 @@ def __init__( :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_06_01.models.PublicNetworkAccess :keyword immutable_storage_with_versioning: The property is immutable and can only be set to @@ -7155,7 +6865,7 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_06_01.models.ImmutableStorageAccount """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -7201,36 +6911,31 @@ class StorageQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'approximate_message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "approximate_message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'approximate_message_count': {'key': 'properties.approximateMessageCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "approximate_message_count": {"key": "properties.approximateMessageCount", "type": "int"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(StorageQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata self.approximate_message_count = None -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -7240,49 +6945,45 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuInformation]'}, + "value": {"key": "value", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_06_01.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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_06_01.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'}, + "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__( @@ -7300,19 +7001,19 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_06_01.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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_06_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -7339,26 +7040,22 @@ class Table(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'table_name': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "table_name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Table, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.table_name = None @@ -7382,86 +7079,74 @@ class TableServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Table service. :paramtype cors: ~azure.mgmt.storage.v2021_06_01.models.CorsRules """ - super(TableServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class TagFilter(msrest.serialization.Model): +class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. All required parameters must be populated in order to send to Azure. - :ivar name: Required. This is the filter tag name, it can have 1 - 128 characters. + :ivar name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str - :ivar op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :ivar op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :vartype op: str - :ivar value: Required. This is the filter tag value field used for tag based filtering, it can - have 0 - 256 characters. + :ivar value: This is the filter tag value field used for tag based filtering, it can have 0 - + 256 characters. Required. :vartype value: str """ _validation = { - 'name': {'required': True, 'max_length': 128, 'min_length': 1}, - 'op': {'required': True}, - 'value': {'required': True, 'max_length': 256, 'min_length': 0}, + "name": {"required": True, "max_length": 128, "min_length": 1}, + "op": {"required": True}, + "value": {"required": True, "max_length": 256}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'op': {'key': 'op', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "op": {"key": "op", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - op: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, op: str, value: str, **kwargs): """ - :keyword name: Required. This is the filter tag name, it can have 1 - 128 characters. + :keyword name: This is the filter tag name, it can have 1 - 128 characters. Required. :paramtype name: str - :keyword op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :keyword op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :paramtype op: str - :keyword value: Required. This is the filter tag value field used for tag based filtering, it - can have 0 - 256 characters. + :keyword value: This is the filter tag value field used for tag based filtering, it can have 0 + - 256 characters. Required. :paramtype value: str """ - super(TagFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.op = op self.value = value -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -7479,28 +7164,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -7508,13 +7189,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -7544,23 +7225,23 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -7585,7 +7266,7 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -7596,13 +7277,13 @@ def __init__( self.allow_protected_append_writes_all = allow_protected_append_writes_all -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_06_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -7613,33 +7294,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -7647,24 +7324,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2021_06_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -7676,27 +7348,23 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """UserAssignedIdentity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -7708,72 +7376,68 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", - "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_06_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", - "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_06_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py index 12c5d9f67712..48ddfa311098 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the policy, Unlocked state allows increase and decrease of immutability retention time and also @@ -30,6 +30,7 @@ class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMet LOCKED = "Locked" DISABLED = "Disabled" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -38,10 +39,13 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobInventoryPolicyName.""" DEFAULT = "default" + class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - @@ -52,6 +56,7 @@ class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): COMPLETE = "Complete" FAILED = "Failed" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -63,7 +68,9 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CorsRuleAllowedMethodsItem.""" DELETE = "DELETE" GET = "GET" @@ -73,39 +80,40 @@ class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): OPTIONS = "OPTIONS" PUT = "PUT" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default share permission for users using Kerberos authentication if RBAC role is not assigned. - """ + """Default share permission for users using Kerberos authentication if RBAC role is not assigned.""" NONE = "None" STORAGE_FILE_DATA_SMB_SHARE_READER = "StorageFileDataSmbShareReader" STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = "StorageFileDataSmbShareContributor" STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" + class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the directory service used. - """ + """Indicates the directory service used.""" NONE = "None" AADDS = "AADDS" AD = "AD" + class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. @@ -114,6 +122,7 @@ class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): SMB = "SMB" NFS = "NFS" + class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. @@ -122,32 +131,33 @@ class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. - """ + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SAS expiration action. Can only be Log. - """ + """The SAS expiration action. Can only be Log.""" LOG = "Log" + class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation. - """ + """The type of extendedLocation.""" EDGE_ZONE = "EdgeZone" + class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is a required field, it specifies the format for the inventory files. - """ + """This is a required field, it specifies the format for the inventory files.""" CSV = "Csv" PARQUET = "Parquet" + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -160,29 +170,30 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type. - """ + """The identity type.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -192,27 +203,29 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Inventory - """ + """The valid value is Inventory.""" INVENTORY = "Inventory" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service @@ -222,9 +235,9 @@ class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SERVICE = "Service" ACCOUNT = "Account" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -232,22 +245,23 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - """ + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -257,19 +271,19 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -277,21 +291,26 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListContainersInclude.""" DELETED = "deleted" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property denotes the container level immutability to object level immutability migration state. @@ -300,6 +319,7 @@ class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): IN_PROGRESS = "InProgress" COMPLETED = "Completed" + class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. @@ -309,12 +329,13 @@ class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" + class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only - """ + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only.""" ACCESS_TIME_TRACKING = "AccessTimeTracking" + class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field specifies the scope of the inventory created either at the blob or container level. @@ -323,6 +344,7 @@ class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): BLOB = "Blob" CONTAINER = "Container" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -337,39 +359,40 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state. - """ + """The current provisioning state.""" SUCCEEDED = "Succeeded" CREATING = "Creating" DELETING = "Deleting" FAILED = "Failed" + class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status. - """ + """The private endpoint connection status.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. @@ -378,6 +401,7 @@ class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): ENABLED = "Enabled" DISABLED = "Disabled" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -386,6 +410,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -396,34 +421,35 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The property is for NFS share only. The default is NoRootSquash. - """ + """The property is for NFS share only. The default is NoRootSquash.""" NO_ROOT_SQUASH = "NoRootSquash" ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" + class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Routing Choice defines the kind of network routing opted by the user. - """ + """Routing Choice defines the kind of network routing opted by the user.""" MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" + class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Lifecycle - """ + """The valid value is Lifecycle.""" LIFECYCLE = "Lifecycle" + class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is a required field. This field is used to schedule an inventory formation. - """ + """This is a required field. This field is used to schedule an inventory formation.""" DAILY = "Daily" WEEKLY = "Weekly" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -434,6 +460,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. @@ -444,6 +471,7 @@ class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): COOL = "Cool" PREMIUM = "Premium" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -454,6 +482,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -464,6 +493,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -478,16 +508,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SKU tier. This is based on the SKU name. - """ + """The SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "Provisioning" DEPROVISIONING = "Deprovisioning" @@ -495,14 +525,16 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "Failed" NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" + class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountExpand.""" GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/__init__.py index 9a63fd415725..a7c5747747ae 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/__init__.py @@ -29,26 +29,27 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_operations.py index a67ce07b6113..e0170cd5a824 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_containers_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,13 +29,20 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -36,303 +50,253 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( @@ -341,50 +305,45 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( @@ -399,37 +358,36 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( @@ -444,36 +402,35 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -488,34 +445,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -525,132 +481,113 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_object_level_worm_request_initial( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any +def build_object_level_worm_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobContainersOperations: """ @@ -671,7 +608,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -679,18 +615,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> Iterable[_models.ListContainerItems]: + ) -> Iterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -699,35 +635,39 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_06_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -735,18 +675,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -763,10 +702,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -776,19 +713,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -796,37 +733,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -836,7 +860,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -844,10 +869,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -855,63 +879,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -921,7 +1031,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -929,72 +1040,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1002,72 +1109,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1075,10 +1178,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1088,16 +1190,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1105,37 +1208,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1145,7 +1335,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1153,80 +1344,166 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') - - request = build_clear_legal_hold_request( - resource_group_name=resource_group_name, - account_name=account_name, - container_name=container_name, - subscription_id=self._config.subscription_id, + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_06_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + request = build_clear_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1234,27 +1511,25 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, @@ -1262,22 +1537,24 @@ def create_or_update_immutability_policy( container_name: str, if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -1286,44 +1563,149 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy or IO + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: 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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1331,10 +1713,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1342,17 +1723,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1367,16 +1747,16 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -1387,32 +1767,34 @@ def get_immutability_policy( "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1420,10 +1802,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1431,26 +1812,20 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this @@ -1458,52 +1833,54 @@ def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1511,10 +1888,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1522,71 +1898,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1594,10 +1966,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1605,19 +1976,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1625,6 +1995,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1632,56 +2004,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1689,10 +2160,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1700,65 +2170,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1768,7 +2324,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1776,52 +2333,48 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_object_level_worm_request_initial( + request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata['url'], + template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1829,10 +2382,9 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1842,16 +2394,11 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore - + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace - def begin_object_level_worm( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> LROPoller[None]: """This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites require a container level immutability policy either in locked @@ -1859,16 +2406,16 @@ def begin_object_level_worm( # pylint: disable=inconsistent-return-statements on the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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. @@ -1880,53 +2427,48 @@ def begin_object_level_worm( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_operations.py index 0cacc54f5511..54e7b3ab010a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_inventory_policies_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,167 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - *, - json: Optional[_models.BlobInventoryPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobInventoryPoliciesOperations: """ @@ -207,52 +208,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -260,10 +262,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -271,68 +272,151 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy 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 - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -340,10 +424,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -351,61 +434,62 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -413,10 +497,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -427,51 +510,50 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -479,15 +561,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -504,10 +588,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -518,8 +600,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_operations.py index 0590d72ac237..89284b7ba48d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_blob_services_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,134 +27,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -168,47 +164,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -216,15 +214,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -241,10 +241,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -254,56 +252,139 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties or IO + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: 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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -313,7 +394,8 @@ def set_service_properties( blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -321,72 +403,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -394,22 +473,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_operations.py index d5bf59ffacbf..4da75c7b8e61 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_deleted_accounts_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,81 +27,74 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_get_request( - deleted_account_name: str, - location: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(deleted_account_name: str, location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), - "location": _SERIALIZER.url("location", location, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "deletedAccountName": _SERIALIZER.url( + "deleted_account_name", deleted_account_name, "str", max_length=24, min_length=3 + ), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DeletedAccountsOperations: """ @@ -115,38 +115,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DeletedAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -154,13 +152,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -177,10 +179,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -191,48 +191,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace - def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,10 +235,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,12 +245,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_operations.py index ea4e8b99fc12..98c38bdf89a7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_encryption_scopes_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,181 +27,164 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_put_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EncryptionScopesOperations: """ @@ -215,14 +205,15 @@ def __init__(self, *args, **kwargs): 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 + @overload def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -230,47 +221,137 @@ def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -278,10 +359,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -290,73 +370,160 @@ def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace + @overload def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -364,10 +531,9 @@ def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,62 +541,59 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -438,10 +601,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,58 +611,54 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.EncryptionScopeListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -508,15 +666,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -533,10 +693,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -546,8 +704,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_operations.py index 0c928451c2f4..ca301e887da5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.FileServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class FileServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,10 +205,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -225,60 +215,143 @@ def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties or IO + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: 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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -288,7 +361,8 @@ def set_service_properties( file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -296,10 +370,9 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,62 +380,60 @@ def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -370,10 +441,9 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -381,12 +451,11 @@ def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_operations.py index ec4819cec2b5..40a6be4404ec 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_file_shares_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -40,38 +54,37 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( @@ -80,95 +93,80 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: Optional[_models.FileShare] = None, - content: Any = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -184,37 +182,36 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -230,84 +227,73 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_restore_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.DeletedShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( @@ -316,48 +302,44 @@ def build_lease_request( share_name: str, subscription_id: str, *, - json: Optional[_models.LeaseShareRequest] = None, - content: Any = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class FileSharesOperations: """ @@ -378,7 +360,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -388,15 +369,15 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.FileShareItems]: + ) -> Iterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -409,32 +390,36 @@ def list( None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -442,18 +427,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -470,10 +454,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -484,13 +466,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, @@ -498,6 +478,8 @@ def create( share_name: str, file_share: _models.FileShare, expand: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -505,51 +487,147 @@ def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -557,10 +635,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -569,63 +646,149 @@ def create( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_06_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -635,7 +798,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -643,10 +807,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -654,15 +817,14 @@ def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def get( @@ -677,16 +839,16 @@ def get( """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. Default value is None. @@ -695,31 +857,33 @@ def get( None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -727,10 +891,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -738,15 +901,14 @@ def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -761,16 +923,16 @@ def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str @@ -779,34 +941,37 @@ def delete( # pylint: disable=inconsistent-return-statements snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the - file share contains any snapshots (leased or unleased), the deletion fails. + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. :type include: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -814,10 +979,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -828,52 +992,135 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace + @overload def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_06_01.models.DeletedShare + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_06_01.models.DeletedShare 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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -883,7 +1130,8 @@ def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -891,10 +1139,9 @@ def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -905,10 +1152,9 @@ def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - @distributed_trace + @overload def lease( self, resource_group_name: str, @@ -916,60 +1162,156 @@ def lease( share_name: str, x_ms_snapshot: Optional[str] = None, parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse, or the result of cls(response) + :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseShareResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseShareRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, api_version=api_version, content_type=content_type, json=_json, - x_ms_snapshot=x_ms_snapshot, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -977,10 +1319,9 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -989,14 +1330,13 @@ def lease( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_operations.py index ffba69a28298..ae255ad1bed6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,130 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,52 +169,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -215,78 +223,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy 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 - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -294,71 +384,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_06_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -366,10 +456,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +468,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_operations.py index 9b6acecffee4..ba36289b5ff1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_object_replication_policies_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,161 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - *, - json: Optional[_models.ObjectReplicationPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ObjectReplicationPoliciesOperations: """ @@ -207,49 +202,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +252,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +279,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -296,58 +291,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -355,10 +346,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -366,70 +356,156 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy 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 - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -437,10 +513,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -448,62 +523,59 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -511,10 +583,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -525,5 +596,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_operations.py index fe318d413696..088c2c71f437 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_endpoint_connections_operations.py index c2cb8ab73d74..c323a52b50ee 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,173 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -207,49 +214,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +264,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +291,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,56 +302,52 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -352,10 +355,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,67 +365,148 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace + @overload def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection 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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -431,10 +514,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,60 +524,57 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -503,10 +582,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -517,5 +595,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_link_resources_operations.py index cd7ddbe8d21d..1cc3bbbbcc9a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,52 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_storage_account_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,46 +91,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -128,22 +136,20 @@ def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_operations.py index dcc7ed1805f5..f07788e8e16a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,183 +27,188 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( @@ -211,36 +223,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueOperations: """ @@ -261,60 +273,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -322,10 +419,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -333,69 +429,154 @@ def create( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -403,10 +584,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -414,62 +594,57 @@ def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.StorageQueue: + def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -477,10 +652,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -488,62 +662,59 @@ def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -551,10 +722,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -565,8 +735,7 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -576,15 +745,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.ListQueueResource]: + ) -> Iterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -593,31 +762,35 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -625,17 +798,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -652,10 +825,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -666,8 +837,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_operations.py index 3695d3d020da..d588f303ed58 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_queue_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.QueueServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,10 +205,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -225,60 +215,144 @@ def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties or IO + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: 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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -288,7 +362,8 @@ def set_service_properties( queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -296,10 +371,9 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,62 +381,60 @@ def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -370,10 +442,9 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -381,12 +452,11 @@ def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_operations.py index 80ca5b61ace1..3bb98c1618f6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_operations.py index e24bb747b506..dea1ba1c4487 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +29,110 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,153 +140,129 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -304,357 +270,305 @@ def build_list_keys_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "kerb", + expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_hierarchical_namespace_migration_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - request_type: str, - **kwargs: Any +def build_hierarchical_namespace_migration_request( + resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['requestType'] = _SERIALIZER.query("request_type", request_type, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["requestType"] = _SERIALIZER.query("request_type", request_type, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_abort_hierarchical_namespace_migration_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_abort_hierarchical_namespace_migration_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_blob_ranges_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobRestoreParameters] = None, - content: Any = None, - **kwargs: Any + +def build_restore_blob_ranges_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revoke_user_delegation_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: # pylint: disable=too-many-public-methods """ @@ -675,45 +589,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2021_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -721,55 +688,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -777,10 +752,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -789,22 +763,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -813,14 +788,17 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCreateParameters + :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 @@ -832,20 +810,98 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -853,79 +909,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -933,10 +984,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -946,15 +996,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -962,40 +1011,43 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_06_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -1003,32 +1055,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1041,32 +1093,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountUpdateParameters + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1075,7 +1212,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1083,58 +1221,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1142,13 +1277,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1165,10 +1304,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1178,49 +1315,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1228,14 +1361,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1252,10 +1388,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1265,57 +1399,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1323,65 +1453,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_06_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1390,7 +1593,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1398,63 +1602,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.AccountSasParameters 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 - :return: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1463,7 +1740,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1471,63 +1749,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.ServiceSasParameters 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 - :return: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1536,7 +1885,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1544,50 +1894,47 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1595,10 +1942,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1608,26 +1954,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1639,82 +1979,75 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_hierarchical_namespace_migration_request_initial( + request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, request_type=request_type, - template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + api_version=api_version, + template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1722,43 +2055,38 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - + _hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace - def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> LROPoller[None]: """Live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param request_type: Required. Hierarchical namespace migration type can either be a hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the - hydration request will migrate the account. + hydration request will migrate the account. Required. :type request_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. @@ -1770,81 +2098,75 @@ def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-retu 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + begin_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_abort_hierarchical_namespace_migration_request_initial( + request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1852,37 +2174,33 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore - + _abort_hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + def begin_abort_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Abort live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1894,85 +2212,90 @@ def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsisten 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1980,10 +2303,9 @@ def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1991,38 +2313,117 @@ def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace + @overload def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.BlobRestoreParameters 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 @@ -2034,20 +2435,17 @@ def begin_restore_blob_ranges( :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_06_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -2055,79 +2453,76 @@ def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -2135,10 +2530,9 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2148,5 +2542,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_operations.py index 13a6678cde56..27b9f40afa90 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,204 +27,194 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableOperations: """ @@ -238,52 +235,47 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def create(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -291,10 +283,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -302,61 +293,56 @@ def create( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -364,10 +350,9 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,61 +360,56 @@ def update( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -437,10 +417,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -448,61 +427,58 @@ def get( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -510,10 +486,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -524,49 +499,47 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -574,15 +547,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -599,10 +574,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -613,8 +586,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_operations.py index bf081f5a8a3b..cdabe252252e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_table_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.TableServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,10 +205,9 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -225,60 +215,144 @@ def list( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties or IO + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: 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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -288,7 +362,8 @@ def set_service_properties( table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -296,10 +371,9 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -307,62 +381,60 @@ def set_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_06_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -370,10 +442,9 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -381,12 +452,11 @@ def get_service_properties( error = self._deserialize.failsafe_deserialize(_models.CloudErrorAutoGenerated, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_operations.py index 734198914c3f..280fe5db7f04 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_06_01/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,41 +87,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_06_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-06-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-06-01")) # type: Literal["2021-06-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -122,14 +128,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -146,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -159,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_configuration.py index 1eb91a925ec3..8d181a0ff0d1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-08-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + api_version = kwargs.pop("api_version", "2021-08-01") # type: Literal["2021-08-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json index 2fe0e6c61c67..28b4957c537c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -118,4 +118,4 @@ "table_services": "TableServicesOperations", "table": "TableOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py index fd8b1be60d8d..5d767e9baebe 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_storage_management_client.py @@ -9,20 +9,41 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, LocalUsersOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + LocalUsersOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -71,9 +92,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_08_01.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_08_01.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -91,28 +112,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -128,43 +145,20 @@ def __init__( self.object_replication_policies = ObjectReplicationPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.local_users = LocalUsersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -173,7 +167,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_configuration.py index 0200f3c9da50..acbc04f6ccd1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-08-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-08-01") # type: str + api_version = kwargs.pop("api_version", "2021-08-01") # type: Literal["2021-08-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py index 70166161a2d2..416158711a8b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/_storage_management_client.py @@ -9,20 +9,41 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, LocalUsersOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + LocalUsersOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -74,9 +95,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_08_01.aio.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_08_01.aio.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -94,28 +115,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -131,43 +148,20 @@ def __init__( self.object_replication_policies = ObjectReplicationPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.local_users = LocalUsersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -176,7 +170,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/__init__.py index 22f9808d440a..b58975e023a9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/__init__.py @@ -30,27 +30,28 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'LocalUsersOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "LocalUsersOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_operations.py index cd30eb60675b..f3ff99e29435 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_containers_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,31 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_object_level_worm_request_initial, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_object_level_worm_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -45,7 +75,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,18 +82,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListContainerItems]: + ) -> AsyncIterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -73,36 +102,40 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_08_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -110,18 +143,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -138,10 +170,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,19 +181,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -171,37 +201,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -211,7 +328,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -219,10 +337,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -230,63 +347,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -296,7 +499,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -304,72 +508,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -377,72 +577,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -450,10 +646,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -463,16 +658,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -480,37 +676,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -520,7 +803,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -528,70 +812,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -601,7 +970,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -609,27 +979,25 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, @@ -637,22 +1005,24 @@ async def create_or_update_immutability_policy( container_name: str, if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -661,44 +1031,149 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy or IO :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: 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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -706,10 +1181,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -717,17 +1191,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -742,16 +1215,16 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -762,32 +1235,34 @@ async def get_immutability_policy( "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -795,10 +1270,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -806,26 +1280,20 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this @@ -833,52 +1301,54 @@ async def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -886,10 +1356,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -897,71 +1366,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -969,10 +1434,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -980,19 +1444,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -1000,6 +1463,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1007,56 +1472,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1064,10 +1628,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1075,65 +1638,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1143,7 +1792,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1151,52 +1801,48 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_object_level_worm_request_initial( + request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata['url'], + template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1204,10 +1850,9 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1217,16 +1862,11 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore - + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace_async - async def begin_object_level_worm( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + async def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites require a container level immutability policy either in locked @@ -1234,16 +1874,16 @@ async def begin_object_level_worm( # pylint: disable=inconsistent-return-statem on the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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. @@ -1255,53 +1895,48 @@ async def begin_object_level_worm( # pylint: disable=inconsistent-return-statem 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_operations.py index 13020e1dc0f1..e512e9f314b5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_inventory_policies_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_inventory_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._blob_inventory_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobInventoryPoliciesOperations: """ .. warning:: @@ -43,52 +63,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -96,10 +117,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -107,68 +127,151 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy 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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -176,10 +279,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -187,61 +289,62 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -249,10 +352,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -263,51 +365,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -315,15 +416,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -340,10 +443,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -354,8 +455,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_operations.py index f9062d91d543..931e0c5046fe 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_blob_services_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -43,48 +62,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,56 +150,139 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties or IO + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: 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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -189,7 +292,8 @@ async def set_service_properties( blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -197,72 +301,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -270,22 +371,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_operations.py index 4a6ded96099f..e6791c834a9c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_deleted_accounts_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DeletedAccountsOperations: """ .. warning:: @@ -43,38 +58,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) + :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -82,13 +96,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -105,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -119,48 +135,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async - async def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -168,10 +179,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,12 +189,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_operations.py index 4432d4a78ef1..e1d21fc52c7e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_encryption_scopes_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._encryption_scopes_operations import build_get_request, build_list_request, build_patch_request, build_put_request -T = TypeVar('T') +from ...operations._encryption_scopes_operations import ( + build_get_request, + build_list_request, + build_patch_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EncryptionScopesOperations: """ .. warning:: @@ -43,14 +63,15 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -58,47 +79,137 @@ async def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -106,10 +217,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -118,73 +228,160 @@ async def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace_async + @overload async def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +389,9 @@ async def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,62 +399,59 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -266,10 +459,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -277,58 +469,57 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EncryptionScopeListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) + :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -336,15 +527,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -361,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -374,8 +565,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_operations.py index 118124f3b4d3..3566e894d2b0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,70 +102,152 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties or IO + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: 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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -161,7 +257,8 @@ async def set_service_properties( file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +266,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +336,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_operations.py index 358669b19aa2..8f7a872dcb22 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_file_shares_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,24 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_shares_operations import build_create_request, build_delete_request, build_get_request, build_lease_request, build_list_request, build_restore_request, build_update_request -T = TypeVar('T') +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_lease_request, + build_list_request, + build_restore_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileSharesOperations: """ .. warning:: @@ -43,7 +66,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,15 +75,15 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.FileShareItems]: + ) -> AsyncIterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -74,33 +96,37 @@ def list( None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) + :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -108,18 +134,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -136,10 +161,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,13 +172,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, @@ -163,6 +184,8 @@ async def create( share_name: str, file_share: _models.FileShare, expand: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -170,51 +193,147 @@ async def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -222,10 +341,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -233,63 +351,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -299,7 +503,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -307,25 +512,23 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def get( @@ -340,16 +543,16 @@ async def get( """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. Default value is None. @@ -358,31 +561,33 @@ async def get( None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -390,25 +595,23 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -423,16 +626,16 @@ async def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str @@ -441,34 +644,37 @@ async def delete( # pylint: disable=inconsistent-return-statements snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the - file share contains any snapshots (leased or unleased), the deletion fails. + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. :type include: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -476,10 +682,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -489,52 +694,135 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace_async + @overload async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_08_01.models.DeletedShare + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_08_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -544,7 +832,8 @@ async def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -552,10 +841,9 @@ async def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,10 +853,9 @@ async def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, @@ -576,60 +863,156 @@ async def lease( share_name: str, x_ms_snapshot: Optional[str] = None, parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse, or the result of cls(response) + :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseShareResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseShareRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, api_version=api_version, content_type=content_type, json=_json, - x_ms_snapshot=x_ms_snapshot, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -637,10 +1020,9 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -648,14 +1030,13 @@ async def lease( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_operations.py index 215a0d505182..65c12208ff86 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_local_users_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._local_users_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_keys_request, build_list_request, build_regenerate_password_request -T = TypeVar('T') +from ...operations._local_users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_keys_request, + build_list_request, + build_regenerate_password_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class LocalUsersOperations: """ .. warning:: @@ -43,48 +65,46 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.LocalUsers]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.LocalUser"]: """List the local users associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 LocalUsers or the result of cls(response) + :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.LocalUsers] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.LocalUser] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUsers] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +151,50 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any - ) -> _models.LocalUser: + async def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +202,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +212,148 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, username: str, properties: _models.LocalUser, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str - :param properties: The local user associated with a storage account. + :param properties: The local user associated with a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_08_01.models.LocalUser + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: IO + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: Union[_models.LocalUser, IO], + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Is either a model type or + a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.LocalUser 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 - :return: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - _json = self._serialize.body(properties, 'LocalUser') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalUser") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +361,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +371,57 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> None: """Deletes the local user associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +429,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,53 +442,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserKeys: """List SSH authorized keys and shared key of the local user. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserKeys, or the result of cls(response) + :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -407,10 +493,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,60 +503,57 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserKeys', pipeline_response) + deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore @distributed_trace_async async def regenerate_password( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserRegeneratePasswordResult: """Regenerate the local user SSH password. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserRegeneratePasswordResult, or the result of cls(response) + :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserRegeneratePasswordResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] - request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata['url'], + template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) @@ -479,10 +561,9 @@ async def regenerate_password( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -490,12 +571,11 @@ async def regenerate_password( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserRegeneratePasswordResult', pipeline_response) + deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore - + regenerate_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_operations.py index df7cd03b7e22..cf33a6e3083d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,52 +59,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -94,78 +113,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy + :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: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -173,71 +274,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -245,10 +346,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -258,5 +358,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_operations.py index 655bbd755a4d..9d9798ce3dff 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_object_replication_policies_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._object_replication_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._object_replication_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ObjectReplicationPoliciesOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,58 +152,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -191,10 +207,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,70 +217,156 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy 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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -273,10 +374,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -284,62 +384,59 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -347,10 +444,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -361,5 +457,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_operations.py index 935e67a6107c..ce2501a3f1a8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_endpoint_connections_operations.py index ba79a8065ff9..fe594e2f24d0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request, build_get_request, build_list_request, build_put_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +151,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +204,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +214,148 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection 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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +363,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +373,57 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +431,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,5 +444,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_link_resources_operations.py index 20eef9671813..4e09e82b01b0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,46 +55,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -88,22 +100,20 @@ async def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_operations.py index be32f7e40c76..4a8d8659eb51 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._queue_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueOperations: """ .. warning:: @@ -43,60 +64,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue 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 - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -104,79 +210,163 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -184,72 +374,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -257,72 +443,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -330,10 +512,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -343,8 +524,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -354,15 +534,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListQueueResource]: + ) -> AsyncIterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -371,32 +551,36 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) + :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -404,17 +588,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -431,10 +615,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -444,8 +626,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_operations.py index dc655d36f50e..c2ae8e6293aa 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_queue_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._queue_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,70 +102,153 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties or IO + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: 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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -161,7 +258,8 @@ async def set_service_properties( queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +267,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +337,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_operations.py index aaba7b75630d..2e785ec3a283 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) + :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +95,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +133,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_operations.py index 533da9740361..15f1c827551b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,33 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_abort_hierarchical_namespace_migration_request_initial, build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_hierarchical_namespace_migration_request_initial, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_restore_blob_ranges_request_initial, build_revoke_user_delegation_keys_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_abort_hierarchical_namespace_migration_request, + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_hierarchical_namespace_migration_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_restore_blob_ranges_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: # pylint: disable=too-many-public-methods """ .. warning:: @@ -45,45 +77,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2021_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +176,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +240,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +251,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +276,17 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCreateParameters + :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 @@ -203,20 +299,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCreateParameters 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. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +400,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +475,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,15 +487,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -333,40 +502,43 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_08_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,32 +546,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -412,32 +584,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -446,7 +703,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -454,58 +712,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -513,13 +769,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -536,10 +796,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,49 +807,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -599,14 +856,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -623,10 +883,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -636,57 +894,53 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -694,65 +948,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_08_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -761,7 +1088,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -769,63 +1097,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -834,7 +1235,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -842,63 +1244,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ServiceSasParameters + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -907,7 +1380,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -915,50 +1389,47 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -966,10 +1437,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -979,26 +1449,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1010,82 +1474,75 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_hierarchical_namespace_migration_request_initial( + request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, request_type=request_type, - template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + api_version=api_version, + template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1093,43 +1550,38 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - + _hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace_async - async def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + async def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param request_type: Required. Hierarchical namespace migration type can either be a hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the - hydration request will migrate the account. + hydration request will migrate the account. Required. :type request_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. @@ -1141,81 +1593,75 @@ async def begin_hierarchical_namespace_migration( # pylint: disable=inconsisten 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + begin_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_abort_hierarchical_namespace_migration_request_initial( + request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1223,37 +1669,33 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore - + _abort_hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + async def begin_abort_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Abort live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1265,85 +1707,90 @@ async def begin_abort_hierarchical_namespace_migration( # pylint: disable=incon 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1351,10 +1798,9 @@ async def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1362,38 +1808,81 @@ async def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace_async + @overload async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1406,20 +1895,55 @@ async def begin_restore_blob_ranges( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobRestoreParameters 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. + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1427,79 +1951,76 @@ async def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1507,10 +2028,9 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1520,5 +2040,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_operations.py index 01d7321aab4b..b2e228cfba2e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._table_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableOperations: """ .. warning:: @@ -43,52 +64,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -96,71 +114,67 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -168,71 +182,65 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,71 +248,67 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -312,10 +316,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -325,50 +328,47 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -376,15 +376,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -401,10 +403,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -414,8 +414,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_operations.py index dd94f24cedb5..9c95d401163a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_table_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._table_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,70 +102,153 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties or IO + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: 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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -161,7 +258,8 @@ async def set_service_properties( table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +267,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +337,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_operations.py index 9fb8e3b05185..47591ac795b0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,42 +57,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_08_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -85,14 +98,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -109,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -122,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/__init__.py index 17ffc8c85bb4..6c99e9febb1d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/__init__.py @@ -152,282 +152,280 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountImmutabilityPolicyState, - AccountStatus, - ActiveDirectoryPropertiesAccountType, - AllowedCopyScope, - BlobInventoryPolicyName, - BlobRestoreProgressStatus, - Bypass, - CorsRuleAllowedMethodsItem, - CreatedByType, - DefaultAction, - DefaultSharePermission, - DirectoryServiceOptions, - EnabledProtocols, - EncryptionScopeSource, - EncryptionScopeState, - ExpirationAction, - ExtendedLocationTypes, - Format, - GeoReplicationStatus, - HttpProtocol, - IdentityType, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - InventoryRuleType, - KeyPermission, - KeySource, - KeyType, - Kind, - LargeFileSharesState, - LeaseContainerRequestAction, - LeaseDuration, - LeaseShareAction, - LeaseState, - LeaseStatus, - ListContainersInclude, - ManagementPolicyName, - MigrationState, - MinimumTlsVersion, - Name, - ObjectType, - Permissions, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisioningState, - PublicAccess, - PublicNetworkAccess, - Reason, - ReasonCode, - RootSquashType, - RoutingChoice, - RuleType, - Schedule, - Services, - ShareAccessTier, - SignedResource, - SignedResourceTypes, - SkuName, - SkuTier, - State, - StorageAccountExpand, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountImmutabilityPolicyState +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import ActiveDirectoryPropertiesAccountType +from ._storage_management_client_enums import AllowedCopyScope +from ._storage_management_client_enums import BlobInventoryPolicyName +from ._storage_management_client_enums import BlobRestoreProgressStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CorsRuleAllowedMethodsItem +from ._storage_management_client_enums import CreatedByType +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DefaultSharePermission +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import EnabledProtocols +from ._storage_management_client_enums import EncryptionScopeSource +from ._storage_management_client_enums import EncryptionScopeState +from ._storage_management_client_enums import ExpirationAction +from ._storage_management_client_enums import ExtendedLocationTypes +from ._storage_management_client_enums import Format +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import IdentityType +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import InventoryRuleType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import KeyType +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseShareAction +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ListContainersInclude +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MigrationState +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Name +from ._storage_management_client_enums import ObjectType +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._storage_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import PublicNetworkAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RootSquashType +from ._storage_management_client_enums import RoutingChoice +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Schedule +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import ShareAccessTier +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import StorageAccountExpand +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessPolicy', - 'AccountImmutabilityPolicyProperties', - 'AccountSasParameters', - 'ActiveDirectoryProperties', - 'AzureEntityResource', - 'AzureFilesIdentityBasedAuthentication', - 'BlobContainer', - 'BlobInventoryPolicy', - 'BlobInventoryPolicyDefinition', - 'BlobInventoryPolicyFilter', - 'BlobInventoryPolicyRule', - 'BlobInventoryPolicySchema', - 'BlobRestoreParameters', - 'BlobRestoreRange', - 'BlobRestoreStatus', - 'BlobServiceItems', - 'BlobServiceProperties', - 'ChangeFeed', - 'CheckNameAvailabilityResult', - 'CloudErrorBody', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DateAfterCreation', - 'DateAfterModification', - 'DeleteRetentionPolicy', - 'DeletedAccount', - 'DeletedAccountListResult', - 'DeletedShare', - 'Dimension', - 'Encryption', - 'EncryptionIdentity', - 'EncryptionScope', - 'EncryptionScopeKeyVaultProperties', - 'EncryptionScopeListResult', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'ErrorResponse', - 'ErrorResponseBody', - 'ExtendedLocation', - 'FileServiceItems', - 'FileServiceProperties', - 'FileShare', - 'FileShareItem', - 'FileShareItems', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'ImmutableStorageAccount', - 'ImmutableStorageWithVersioning', - 'KeyCreationTime', - 'KeyPolicy', - 'KeyVaultProperties', - 'LastAccessTimeTrackingPolicy', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LeaseShareRequest', - 'LeaseShareResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListBlobInventoryPolicy', - 'ListContainerItem', - 'ListContainerItems', - 'ListQueue', - 'ListQueueResource', - 'ListQueueServices', - 'ListServiceSasResponse', - 'ListTableResource', - 'ListTableServices', - 'LocalUser', - 'LocalUserKeys', - 'LocalUserRegeneratePasswordResult', - 'LocalUsers', - 'ManagementPolicy', - 'ManagementPolicyAction', - 'ManagementPolicyBaseBlob', - 'ManagementPolicyDefinition', - 'ManagementPolicyFilter', - 'ManagementPolicyRule', - 'ManagementPolicySchema', - 'ManagementPolicySnapShot', - 'ManagementPolicyVersion', - 'MetricSpecification', - 'Multichannel', - 'NetworkRuleSet', - 'ObjectReplicationPolicies', - 'ObjectReplicationPolicy', - 'ObjectReplicationPolicyFilter', - 'ObjectReplicationPolicyRule', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PermissionScope', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProtectedAppendWritesHistory', - 'ProtocolSettings', - 'ProxyResource', - 'QueueServiceProperties', - 'Resource', - 'ResourceAccessRule', - 'RestorePolicyProperties', - 'Restriction', - 'RoutingPreference', - 'SKUCapability', - 'SasPolicy', - 'ServiceSasParameters', - 'ServiceSpecification', - 'SignedIdentifier', - 'Sku', - 'SkuInformation', - 'SmbSetting', - 'SshPublicKey', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountInternetEndpoints', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountMicrosoftEndpoints', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountUpdateParameters', - 'StorageQueue', - 'StorageSkuListResult', - 'SystemData', - 'Table', - 'TableServiceProperties', - 'TagFilter', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'UserAssignedIdentity', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountImmutabilityPolicyState', - 'AccountStatus', - 'ActiveDirectoryPropertiesAccountType', - 'AllowedCopyScope', - 'BlobInventoryPolicyName', - 'BlobRestoreProgressStatus', - 'Bypass', - 'CorsRuleAllowedMethodsItem', - 'CreatedByType', - 'DefaultAction', - 'DefaultSharePermission', - 'DirectoryServiceOptions', - 'EnabledProtocols', - 'EncryptionScopeSource', - 'EncryptionScopeState', - 'ExpirationAction', - 'ExtendedLocationTypes', - 'Format', - 'GeoReplicationStatus', - 'HttpProtocol', - 'IdentityType', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'InventoryRuleType', - 'KeyPermission', - 'KeySource', - 'KeyType', - 'Kind', - 'LargeFileSharesState', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseShareAction', - 'LeaseState', - 'LeaseStatus', - 'ListContainersInclude', - 'ManagementPolicyName', - 'MigrationState', - 'MinimumTlsVersion', - 'Name', - 'ObjectType', - 'Permissions', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'ProvisioningState', - 'PublicAccess', - 'PublicNetworkAccess', - 'Reason', - 'ReasonCode', - 'RootSquashType', - 'RoutingChoice', - 'RuleType', - 'Schedule', - 'Services', - 'ShareAccessTier', - 'SignedResource', - 'SignedResourceTypes', - 'SkuName', - 'SkuTier', - 'State', - 'StorageAccountExpand', - 'UsageUnit', + "AccessPolicy", + "AccountImmutabilityPolicyProperties", + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobInventoryPolicy", + "BlobInventoryPolicyDefinition", + "BlobInventoryPolicyFilter", + "BlobInventoryPolicyRule", + "BlobInventoryPolicySchema", + "BlobRestoreParameters", + "BlobRestoreRange", + "BlobRestoreStatus", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorBody", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "DeletedAccount", + "DeletedAccountListResult", + "DeletedShare", + "Dimension", + "Encryption", + "EncryptionIdentity", + "EncryptionScope", + "EncryptionScopeKeyVaultProperties", + "EncryptionScopeListResult", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ErrorResponse", + "ErrorResponseBody", + "ExtendedLocation", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "ImmutableStorageAccount", + "ImmutableStorageWithVersioning", + "KeyCreationTime", + "KeyPolicy", + "KeyVaultProperties", + "LastAccessTimeTrackingPolicy", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LeaseShareRequest", + "LeaseShareResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListBlobInventoryPolicy", + "ListContainerItem", + "ListContainerItems", + "ListQueue", + "ListQueueResource", + "ListQueueServices", + "ListServiceSasResponse", + "ListTableResource", + "ListTableServices", + "LocalUser", + "LocalUserKeys", + "LocalUserRegeneratePasswordResult", + "LocalUsers", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "ManagementPolicyVersion", + "MetricSpecification", + "Multichannel", + "NetworkRuleSet", + "ObjectReplicationPolicies", + "ObjectReplicationPolicy", + "ObjectReplicationPolicyFilter", + "ObjectReplicationPolicyRule", + "Operation", + "OperationDisplay", + "OperationListResult", + "PermissionScope", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProtectedAppendWritesHistory", + "ProtocolSettings", + "ProxyResource", + "QueueServiceProperties", + "Resource", + "ResourceAccessRule", + "RestorePolicyProperties", + "Restriction", + "RoutingPreference", + "SKUCapability", + "SasPolicy", + "ServiceSasParameters", + "ServiceSpecification", + "SignedIdentifier", + "Sku", + "SkuInformation", + "SmbSetting", + "SshPublicKey", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountInternetEndpoints", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountMicrosoftEndpoints", + "StorageAccountRegenerateKeyParameters", + "StorageAccountUpdateParameters", + "StorageQueue", + "StorageSkuListResult", + "SystemData", + "Table", + "TableServiceProperties", + "TagFilter", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "UserAssignedIdentity", + "VirtualNetworkRule", + "AccessTier", + "AccountImmutabilityPolicyState", + "AccountStatus", + "ActiveDirectoryPropertiesAccountType", + "AllowedCopyScope", + "BlobInventoryPolicyName", + "BlobRestoreProgressStatus", + "Bypass", + "CorsRuleAllowedMethodsItem", + "CreatedByType", + "DefaultAction", + "DefaultSharePermission", + "DirectoryServiceOptions", + "EnabledProtocols", + "EncryptionScopeSource", + "EncryptionScopeState", + "ExpirationAction", + "ExtendedLocationTypes", + "Format", + "GeoReplicationStatus", + "HttpProtocol", + "IdentityType", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "InventoryRuleType", + "KeyPermission", + "KeySource", + "KeyType", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseShareAction", + "LeaseState", + "LeaseStatus", + "ListContainersInclude", + "ManagementPolicyName", + "MigrationState", + "MinimumTlsVersion", + "Name", + "ObjectType", + "Permissions", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicAccess", + "PublicNetworkAccess", + "Reason", + "ReasonCode", + "RootSquashType", + "RoutingChoice", + "RuleType", + "Schedule", + "Services", + "ShareAccessTier", + "SignedResource", + "SignedResourceTypes", + "SkuName", + "SkuTier", + "State", + "StorageAccountExpand", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py index 028df747ec12..3576c63b911b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccessPolicy(msrest.serialization.Model): +class AccessPolicy(_serialization.Model): """AccessPolicy. :ivar start_time: Start time of the access policy. @@ -29,9 +35,9 @@ class AccessPolicy(msrest.serialization.Model): """ _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'permission': {'key': 'permission', 'type': 'str'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "permission": {"key": "permission", "type": "str"}, } def __init__( @@ -50,13 +56,13 @@ def __init__( :keyword permission: List of abbreviated permissions. :paramtype permission: str """ - super(AccessPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_time = start_time self.expiry_time = expiry_time self.permission = permission -class AccountImmutabilityPolicyProperties(msrest.serialization.Model): +class AccountImmutabilityPolicyProperties(_serialization.Model): """This defines account-level immutability policy properties. :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the @@ -68,7 +74,7 @@ class AccountImmutabilityPolicyProperties(msrest.serialization.Model): increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", - "Locked", "Disabled". + "Locked", and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_08_01.models.AccountImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for disabled and unlocked time-based retention policies. When enabled, new blocks can be written to an append @@ -78,13 +84,13 @@ class AccountImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'immutability_period_since_creation_in_days': {'maximum': 146000, 'minimum': 1}, + "immutability_period_since_creation_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'allowProtectedAppendWrites', 'type': 'bool'}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "state": {"key": "state", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -105,7 +111,7 @@ def __init__( increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", - "Locked", "Disabled". + "Locked", and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_08_01.models.AccountImmutabilityPolicyState :keyword allow_protected_append_writes: This property can only be changed for disabled and unlocked time-based retention policies. When enabled, new blocks can be written to an append @@ -113,60 +119,60 @@ def __init__( any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes: bool """ - super(AccountImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = state self.allow_protected_append_writes = allow_protected_append_writes -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2021_08_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_08_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_08_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_08_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -183,33 +189,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2021_08_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_08_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_08_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_08_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -220,50 +227,50 @@ def __init__( self.key_to_sign = key_to_sign -class ActiveDirectoryProperties(msrest.serialization.Model): +class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). All required parameters must be populated in order to send to Azure. - :ivar domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :vartype domain_name: str - :ivar net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. Required. :vartype net_bios_domain_name: str - :ivar forest_name: Required. Specifies the Active Directory forest to get. + :ivar forest_name: Specifies the Active Directory forest to get. Required. :vartype forest_name: str - :ivar domain_guid: Required. Specifies the domain GUID. + :ivar domain_guid: Specifies the domain GUID. Required. :vartype domain_guid: str - :ivar domain_sid: Required. Specifies the security identifier (SID). + :ivar domain_sid: Specifies the security identifier (SID). Required. :vartype domain_sid: str - :ivar azure_storage_sid: Required. Specifies the security identifier (SID) for Azure Storage. + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. Required. :vartype azure_storage_sid: str :ivar sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. :vartype sam_account_name: str :ivar account_type: Specifies the Active Directory account type for Azure Storage. Known values - are: "User", "Computer". + are: "User" and "Computer". :vartype account_type: str or ~azure.mgmt.storage.v2021_08_01.models.ActiveDirectoryPropertiesAccountType """ _validation = { - 'domain_name': {'required': True}, - 'net_bios_domain_name': {'required': True}, - 'forest_name': {'required': True}, - 'domain_guid': {'required': True}, - 'domain_sid': {'required': True}, - 'azure_storage_sid': {'required': True}, + "domain_name": {"required": True}, + "net_bios_domain_name": {"required": True}, + "forest_name": {"required": True}, + "domain_guid": {"required": True}, + "domain_sid": {"required": True}, + "azure_storage_sid": {"required": True}, } _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'net_bios_domain_name': {'key': 'netBiosDomainName', 'type': 'str'}, - 'forest_name': {'key': 'forestName', 'type': 'str'}, - 'domain_guid': {'key': 'domainGuid', 'type': 'str'}, - 'domain_sid': {'key': 'domainSid', 'type': 'str'}, - 'azure_storage_sid': {'key': 'azureStorageSid', 'type': 'str'}, - 'sam_account_name': {'key': 'samAccountName', 'type': 'str'}, - 'account_type': {'key': 'accountType', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, + "sam_account_name": {"key": "samAccountName", "type": "str"}, + "account_type": {"key": "accountType", "type": "str"}, } def __init__( @@ -280,28 +287,28 @@ def __init__( **kwargs ): """ - :keyword domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :paramtype domain_name: str - :keyword net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. Required. :paramtype net_bios_domain_name: str - :keyword forest_name: Required. Specifies the Active Directory forest to get. + :keyword forest_name: Specifies the Active Directory forest to get. Required. :paramtype forest_name: str - :keyword domain_guid: Required. Specifies the domain GUID. + :keyword domain_guid: Specifies the domain GUID. Required. :paramtype domain_guid: str - :keyword domain_sid: Required. Specifies the security identifier (SID). + :keyword domain_sid: Specifies the security identifier (SID). Required. :paramtype domain_sid: str - :keyword azure_storage_sid: Required. Specifies the security identifier (SID) for Azure - Storage. + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + Required. :paramtype azure_storage_sid: str :keyword sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. :paramtype sam_account_name: str :keyword account_type: Specifies the Active Directory account type for Azure Storage. Known - values are: "User", "Computer". + values are: "User" and "Computer". :paramtype account_type: str or ~azure.mgmt.storage.v2021_08_01.models.ActiveDirectoryPropertiesAccountType """ - super(ActiveDirectoryProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.net_bios_domain_name = net_bios_domain_name self.forest_name = forest_name @@ -312,7 +319,7 @@ def __init__( self.account_type = account_type -class Resource(msrest.serialization.Model): +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. @@ -328,24 +335,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -369,36 +372,32 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): +class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Known values - are: "None", "AADDS", "AD". + :ivar directory_service_options: Indicates the directory service used. Required. Known values + are: "None", "AADDS", and "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_08_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -406,20 +405,20 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): ~azure.mgmt.storage.v2021_08_01.models.ActiveDirectoryProperties :ivar default_share_permission: Default share permission for users using Kerberos authentication if RBAC role is not assigned. Known values are: "None", - "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and "StorageFileDataSmbShareElevatedContributor". :vartype default_share_permission: str or ~azure.mgmt.storage.v2021_08_01.models.DefaultSharePermission """ _validation = { - 'directory_service_options': {'required': True}, + "directory_service_options": {"required": True}, } _attribute_map = { - 'directory_service_options': {'key': 'directoryServiceOptions', 'type': 'str'}, - 'active_directory_properties': {'key': 'activeDirectoryProperties', 'type': 'ActiveDirectoryProperties'}, - 'default_share_permission': {'key': 'defaultSharePermission', 'type': 'str'}, + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, + "default_share_permission": {"key": "defaultSharePermission", "type": "str"}, } def __init__( @@ -431,8 +430,8 @@ def __init__( **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Known - values are: "None", "AADDS", "AD". + :keyword directory_service_options: Indicates the directory service used. Required. Known + values are: "None", "AADDS", and "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_08_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. @@ -440,18 +439,18 @@ def __init__( ~azure.mgmt.storage.v2021_08_01.models.ActiveDirectoryProperties :keyword default_share_permission: Default share permission for users using Kerberos authentication if RBAC role is not assigned. Known values are: "None", - "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and "StorageFileDataSmbShareElevatedContributor". :paramtype default_share_permission: str or ~azure.mgmt.storage.v2021_08_01.models.DefaultSharePermission """ - super(AzureFilesIdentityBasedAuthentication, self).__init__(**kwargs) + super().__init__(**kwargs) self.directory_service_options = directory_service_options self.active_directory_properties = active_directory_properties self.default_share_permission = default_share_permission -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -481,17 +480,18 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -521,48 +521,51 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, - 'enable_nfs_v3_root_squash': {'key': 'properties.enableNfsV3RootSquash', 'type': 'bool'}, - 'enable_nfs_v3_all_squash': {'key': 'properties.enableNfsV3AllSquash', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, } def __init__( @@ -585,7 +588,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -599,7 +602,7 @@ def __init__( :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. :paramtype enable_nfs_v3_all_squash: bool """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -643,81 +646,77 @@ class BlobInventoryPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified_time": {"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'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'BlobInventoryPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "BlobInventoryPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.BlobInventoryPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs): """ :keyword policy: The storage account blob inventory policy object. It is composed of policy rules. :paramtype policy: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicySchema """ - super(BlobInventoryPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.last_modified_time = None self.policy = policy -class BlobInventoryPolicyDefinition(msrest.serialization.Model): +class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. All required parameters must be populated in order to send to Azure. :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyFilter - :ivar format: Required. This is a required field, it specifies the format for the inventory - files. Known values are: "Csv", "Parquet". + :ivar format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". :vartype format: str or ~azure.mgmt.storage.v2021_08_01.models.Format - :ivar schedule: Required. This is a required field. This field is used to schedule an inventory - formation. Known values are: "Daily", "Weekly". + :ivar schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". :vartype schedule: str or ~azure.mgmt.storage.v2021_08_01.models.Schedule - :ivar object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Known values are: "Blob", "Container". + :ivar object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". :vartype object_type: str or ~azure.mgmt.storage.v2021_08_01.models.ObjectType - :ivar schema_fields: Required. This is a required field. This field specifies the fields and - properties of the object to be included in the inventory. The Schema field value 'Name' is - always required. The valid values for this field for the 'Blob' definition.objectType include - 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, + :ivar schema_fields: This is a required field. This field specifies the fields and properties + of the object to be included in the inventory. The Schema field value 'Name' is always + required. The valid values for this field for the 'Blob' definition.objectType include 'Name, + Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, AccessTierChangeTime, AccessTierInferred, Tags, Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime'. The valid values for 'Container' definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl' are valid only - for Hns enabled accounts.'Tags' field is only valid for non Hns accounts. + for Hns enabled accounts.'Tags' field is only valid for non Hns accounts. Required. :vartype schema_fields: list[str] """ _validation = { - 'format': {'required': True}, - 'schedule': {'required': True}, - 'object_type': {'required': True}, - 'schema_fields': {'required': True}, + "format": {"required": True}, + "schedule": {"required": True}, + "object_type": {"required": True}, + "schema_fields": {"required": True}, } _attribute_map = { - 'filters': {'key': 'filters', 'type': 'BlobInventoryPolicyFilter'}, - 'format': {'key': 'format', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'schema_fields': {'key': 'schemaFields', 'type': '[str]'}, + "filters": {"key": "filters", "type": "BlobInventoryPolicyFilter"}, + "format": {"key": "format", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "schema_fields": {"key": "schemaFields", "type": "[str]"}, } def __init__( @@ -733,16 +732,17 @@ def __init__( """ :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyFilter - :keyword format: Required. This is a required field, it specifies the format for the inventory - files. Known values are: "Csv", "Parquet". + :keyword format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". :paramtype format: str or ~azure.mgmt.storage.v2021_08_01.models.Format - :keyword schedule: Required. This is a required field. This field is used to schedule an - inventory formation. Known values are: "Daily", "Weekly". + :keyword schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". :paramtype schedule: str or ~azure.mgmt.storage.v2021_08_01.models.Schedule - :keyword object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Known values are: "Blob", "Container". + :keyword object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". :paramtype object_type: str or ~azure.mgmt.storage.v2021_08_01.models.ObjectType - :keyword schema_fields: Required. This is a required field. This field specifies the fields and + :keyword schema_fields: This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is always required. The valid values for this field for the 'Blob' definition.objectType include 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, @@ -751,10 +751,10 @@ def __init__( values for 'Container' definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl' are valid only - for Hns enabled accounts.'Tags' field is only valid for non Hns accounts. + for Hns enabled accounts.'Tags' field is only valid for non Hns accounts. Required. :paramtype schema_fields: list[str] """ - super(BlobInventoryPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.filters = filters self.format = format self.schedule = schedule @@ -762,7 +762,7 @@ def __init__( self.schema_fields = schema_fields -class BlobInventoryPolicyFilter(msrest.serialization.Model): +class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. For 'Blob' definition.objectType all filter properties are applicable, 'blobTypes' is required and others are optional. For 'Container' definition.objectType only prefixMatch is applicable and is optional. :ivar prefix_match: An array of strings for blob prefixes to be matched. @@ -782,10 +782,10 @@ class BlobInventoryPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'include_blob_versions': {'key': 'includeBlobVersions', 'type': 'bool'}, - 'include_snapshots': {'key': 'includeSnapshots', 'type': 'bool'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "include_blob_versions": {"key": "includeBlobVersions", "type": "bool"}, + "include_snapshots": {"key": "includeSnapshots", "type": "bool"}, } def __init__( @@ -813,42 +813,42 @@ def __init__( else it must be excluded. :paramtype include_snapshots: bool """ - super(BlobInventoryPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.include_blob_versions = include_blob_versions self.include_snapshots = include_snapshots -class BlobInventoryPolicyRule(msrest.serialization.Model): +class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Rule is enabled when set to true. + :ivar enabled: Rule is enabled when set to true. Required. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :ivar destination: Container name where blob inventory files are stored. Must be pre-created. + Required. :vartype destination: str - :ivar definition: Required. An object that defines the blob inventory policy rule. + :ivar definition: An object that defines the blob inventory policy rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyDefinition """ _validation = { - 'enabled': {'required': True}, - 'name': {'required': True}, - 'destination': {'required': True}, - 'definition': {'required': True}, + "enabled": {"required": True}, + "name": {"required": True}, + "destination": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'destination': {'key': 'destination', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'BlobInventoryPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "destination": {"key": "destination", "type": "str"}, + "definition": {"key": "definition", "type": "BlobInventoryPolicyDefinition"}, } def __init__( @@ -861,48 +861,48 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Rule is enabled when set to true. + :keyword enabled: Rule is enabled when set to true. Required. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :keyword destination: Container name where blob inventory files are stored. Must be + pre-created. Required. :paramtype destination: str - :keyword definition: Required. An object that defines the blob inventory policy rule. + :keyword definition: An object that defines the blob inventory policy rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyDefinition """ - super(BlobInventoryPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.destination = destination self.definition = definition -class BlobInventoryPolicySchema(msrest.serialization.Model): +class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Policy is enabled if set to true. + :ivar enabled: Policy is enabled if set to true. Required. :vartype enabled: bool - :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". + :ivar type: The valid value is Inventory. Required. "Inventory" :vartype type: str or ~azure.mgmt.storage.v2021_08_01.models.InventoryRuleType - :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :ivar rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :vartype rules: list[~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyRule] """ _validation = { - 'enabled': {'required': True}, - 'type': {'required': True}, - 'rules': {'required': True}, + "enabled": {"required": True}, + "type": {"required": True}, + "rules": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rules': {'key': 'rules', 'type': '[BlobInventoryPolicyRule]'}, + "enabled": {"key": "enabled", "type": "bool"}, + "type": {"key": "type", "type": "str"}, + "rules": {"key": "rules", "type": "[BlobInventoryPolicyRule]"}, } def __init__( @@ -914,99 +914,87 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Policy is enabled if set to true. + :keyword enabled: Policy is enabled if set to true. Required. :paramtype enabled: bool - :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". + :keyword type: The valid value is Inventory. Required. "Inventory" :paramtype type: str or ~azure.mgmt.storage.v2021_08_01.models.InventoryRuleType - :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :keyword rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :paramtype rules: list[~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyRule] """ - super(BlobInventoryPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.type = type self.rules = rules -class BlobRestoreParameters(msrest.serialization.Model): +class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. All required parameters must be populated in order to send to Azure. - :ivar time_to_restore: Required. Restore blob to the specified time. + :ivar time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime - :ivar blob_ranges: Required. Blob ranges to restore. + :ivar blob_ranges: Blob ranges to restore. Required. :vartype blob_ranges: list[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreRange] """ _validation = { - 'time_to_restore': {'required': True}, - 'blob_ranges': {'required': True}, + "time_to_restore": {"required": True}, + "blob_ranges": {"required": True}, } _attribute_map = { - 'time_to_restore': {'key': 'timeToRestore', 'type': 'iso-8601'}, - 'blob_ranges': {'key': 'blobRanges', 'type': '[BlobRestoreRange]'}, + "time_to_restore": {"key": "timeToRestore", "type": "iso-8601"}, + "blob_ranges": {"key": "blobRanges", "type": "[BlobRestoreRange]"}, } - def __init__( - self, - *, - time_to_restore: datetime.datetime, - blob_ranges: List["_models.BlobRestoreRange"], - **kwargs - ): + def __init__(self, *, time_to_restore: datetime.datetime, blob_ranges: List["_models.BlobRestoreRange"], **kwargs): """ - :keyword time_to_restore: Required. Restore blob to the specified time. + :keyword time_to_restore: Restore blob to the specified time. Required. :paramtype time_to_restore: ~datetime.datetime - :keyword blob_ranges: Required. Blob ranges to restore. + :keyword blob_ranges: Blob ranges to restore. Required. :paramtype blob_ranges: list[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreRange] """ - super(BlobRestoreParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_to_restore = time_to_restore self.blob_ranges = blob_ranges -class BlobRestoreRange(msrest.serialization.Model): +class BlobRestoreRange(_serialization.Model): """Blob range. All required parameters must be populated in order to send to Azure. - :ivar start_range: Required. Blob start range. This is inclusive. Empty means account start. + :ivar start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str - :ivar end_range: Required. Blob end range. This is exclusive. Empty means account end. + :ivar end_range: Blob end range. This is exclusive. Empty means account end. Required. :vartype end_range: str """ _validation = { - 'start_range': {'required': True}, - 'end_range': {'required': True}, + "start_range": {"required": True}, + "end_range": {"required": True}, } _attribute_map = { - 'start_range': {'key': 'startRange', 'type': 'str'}, - 'end_range': {'key': 'endRange', 'type': 'str'}, + "start_range": {"key": "startRange", "type": "str"}, + "end_range": {"key": "endRange", "type": "str"}, } - def __init__( - self, - *, - start_range: str, - end_range: str, - **kwargs - ): + def __init__(self, *, start_range: str, end_range: str, **kwargs): """ - :keyword start_range: Required. Blob start range. This is inclusive. Empty means account start. + :keyword start_range: Blob start range. This is inclusive. Empty means account start. Required. :paramtype start_range: str - :keyword end_range: Required. Blob end range. This is exclusive. Empty means account end. + :keyword end_range: Blob end range. This is exclusive. Empty means account end. Required. :paramtype end_range: str """ - super(BlobRestoreRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_range = start_range self.end_range = end_range -class BlobRestoreStatus(msrest.serialization.Model): +class BlobRestoreStatus(_serialization.Model): """Blob restore status. Variables are only populated by the server, and will be ignored when sending a request. @@ -1014,7 +1002,7 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", - "Complete", "Failed". + "Complete", and "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_08_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -1025,33 +1013,29 @@ class BlobRestoreStatus(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'restore_id': {'readonly': True}, - 'parameters': {'readonly': True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "restore_id": {"readonly": True}, + "parameters": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'restore_id': {'key': 'restoreId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'BlobRestoreParameters'}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "restore_id": {"key": "restoreId", "type": "str"}, + "parameters": {"key": "parameters", "type": "BlobRestoreParameters"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobRestoreStatus, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.failure_reason = None self.restore_id = None self.parameters = None -class BlobServiceItems(msrest.serialization.Model): +class BlobServiceItems(_serialization.Model): """BlobServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -1061,24 +1045,20 @@ class BlobServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobServiceProperties]'}, + "value": {"key": "value", "type": "[BlobServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class BlobServiceProperties(Resource): +class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attributes """The properties of a storage account’s Blob service. Variables are only populated by the server, and will be ignored when sending a request. @@ -1121,26 +1101,32 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'is_versioning_enabled': {'key': 'properties.isVersioningEnabled', 'type': 'bool'}, - 'automatic_snapshot_policy_enabled': {'key': 'properties.automaticSnapshotPolicyEnabled', 'type': 'bool'}, - 'change_feed': {'key': 'properties.changeFeed', 'type': 'ChangeFeed'}, - 'restore_policy': {'key': 'properties.restorePolicy', 'type': 'RestorePolicyProperties'}, - 'container_delete_retention_policy': {'key': 'properties.containerDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'last_access_time_tracking_policy': {'key': 'properties.lastAccessTimeTrackingPolicy', 'type': 'LastAccessTimeTrackingPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "is_versioning_enabled": {"key": "properties.isVersioningEnabled", "type": "bool"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, + "restore_policy": {"key": "properties.restorePolicy", "type": "RestorePolicyProperties"}, + "container_delete_retention_policy": { + "key": "properties.containerDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "last_access_time_tracking_policy": { + "key": "properties.lastAccessTimeTrackingPolicy", + "type": "LastAccessTimeTrackingPolicy", + }, } def __init__( @@ -1187,7 +1173,7 @@ def __init__( :paramtype last_access_time_tracking_policy: ~azure.mgmt.storage.v2021_08_01.models.LastAccessTimeTrackingPolicy """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.default_service_version = default_service_version @@ -1200,7 +1186,7 @@ def __init__( self.last_access_time_tracking_policy = last_access_time_tracking_policy -class ChangeFeed(msrest.serialization.Model): +class ChangeFeed(_serialization.Model): """The blob service properties for change feed events. :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. @@ -1212,21 +1198,15 @@ class ChangeFeed(msrest.serialization.Model): """ _validation = { - 'retention_in_days': {'maximum': 146000, 'minimum': 1}, + "retention_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_in_days': {'key': 'retentionInDays', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_in_days": {"key": "retentionInDays", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - retention_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, retention_in_days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. :paramtype enabled: bool @@ -1235,12 +1215,12 @@ def __init__( retention of the change feed. :paramtype retention_in_days: int """ - super(ChangeFeed, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.retention_in_days = retention_in_days -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1250,7 +1230,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_08_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1258,30 +1238,26 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1298,10 +1274,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -1326,50 +1302,50 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2021_08_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2021_08_01.models.CorsRuleAllowedMethodsItem] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -1383,24 +1359,24 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2021_08_01.models.CorsRuleAllowedMethodsItem] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -1408,7 +1384,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -1417,31 +1393,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2021_08_01.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -1449,68 +1420,57 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DateAfterCreation(msrest.serialization.Model): +class DateAfterCreation(_serialization.Model): """Object to define the number of days after creation. All required parameters must be populated in order to send to Azure. - :ivar days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :vartype days_after_creation_greater_than: float """ _validation = { - 'days_after_creation_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, } - def __init__( - self, - *, - days_after_creation_greater_than: float, - **kwargs - ): + def __init__(self, *, days_after_creation_greater_than: float, **kwargs): """ - :keyword days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :paramtype days_after_creation_greater_than: float """ - super(DateAfterCreation, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_creation_greater_than = days_after_creation_greater_than -class DateAfterModification(msrest.serialization.Model): +class DateAfterModification(_serialization.Model): """Object to define the number of days after object last modification Or last access. Properties daysAfterModificationGreaterThan and daysAfterLastAccessTimeGreaterThan are mutually exclusive. :ivar days_after_modification_greater_than: Value indicating the age in days after last @@ -1523,13 +1483,13 @@ class DateAfterModification(msrest.serialization.Model): """ _validation = { - 'days_after_modification_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_last_access_time_greater_than': {'minimum': 0, 'multiple': 1}, + "days_after_modification_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_access_time_greater_than": {"minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'float'}, - 'days_after_last_access_time_greater_than': {'key': 'daysAfterLastAccessTimeGreaterThan', 'type': 'float'}, + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, + "days_after_last_access_time_greater_than": {"key": "daysAfterLastAccessTimeGreaterThan", "type": "float"}, } def __init__( @@ -1548,7 +1508,7 @@ def __init__( policy. :paramtype days_after_last_access_time_greater_than: float """ - super(DateAfterModification, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_modification_greater_than = days_after_modification_greater_than self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than @@ -1569,24 +1529,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class DeletedAccount(ProxyResource): @@ -1616,34 +1572,30 @@ class DeletedAccount(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'storage_account_resource_id': {'readonly': True}, - 'location': {'readonly': True}, - 'restore_reference': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'deletion_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'location': {'key': 'properties.location', 'type': 'str'}, - 'restore_reference': {'key': 'properties.restoreReference', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, - 'deletion_time': {'key': 'properties.deletionTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccount, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "storage_account_resource_id": {"readonly": True}, + "location": {"readonly": True}, + "restore_reference": {"readonly": True}, + "creation_time": {"readonly": True}, + "deletion_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "location": {"key": "properties.location", "type": "str"}, + "restore_reference": {"key": "properties.restoreReference", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "str"}, + "deletion_time": {"key": "properties.deletionTime", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_account_resource_id = None self.location = None self.restore_reference = None @@ -1651,7 +1603,7 @@ def __init__( self.deletion_time = None -class DeletedAccountListResult(msrest.serialization.Model): +class DeletedAccountListResult(_serialization.Model): """The response from the List Deleted Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1664,70 +1616,60 @@ class DeletedAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeletedAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeletedAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DeletedShare(msrest.serialization.Model): +class DeletedShare(_serialization.Model): """The deleted share to be restored. All required parameters must be populated in order to send to Azure. - :ivar deleted_share_name: Required. Required. Identify the name of the deleted share that will - be restored. + :ivar deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :vartype deleted_share_name: str - :ivar deleted_share_version: Required. Required. Identify the version of the deleted share that - will be restored. + :ivar deleted_share_version: Required. Identify the version of the deleted share that will be + restored. Required. :vartype deleted_share_version: str """ _validation = { - 'deleted_share_name': {'required': True}, - 'deleted_share_version': {'required': True}, + "deleted_share_name": {"required": True}, + "deleted_share_version": {"required": True}, } _attribute_map = { - 'deleted_share_name': {'key': 'deletedShareName', 'type': 'str'}, - 'deleted_share_version': {'key': 'deletedShareVersion', 'type': 'str'}, + "deleted_share_name": {"key": "deletedShareName", "type": "str"}, + "deleted_share_version": {"key": "deletedShareVersion", "type": "str"}, } - def __init__( - self, - *, - deleted_share_name: str, - deleted_share_version: str, - **kwargs - ): + def __init__(self, *, deleted_share_name: str, deleted_share_version: str, **kwargs): """ - :keyword deleted_share_name: Required. Required. Identify the name of the deleted share that - will be restored. + :keyword deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :paramtype deleted_share_name: str - :keyword deleted_share_version: Required. Required. Identify the version of the deleted share - that will be restored. + :keyword deleted_share_version: Required. Identify the version of the deleted share that will + be restored. Required. :paramtype deleted_share_version: str """ - super(DeletedShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.deleted_share_name = deleted_share_name self.deleted_share_version = deleted_share_version -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. @@ -1738,21 +1680,15 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled. :paramtype enabled: bool @@ -1760,12 +1696,12 @@ def __init__( minimum specified value can be 1 and the maximum value can be 365. :paramtype days: int """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -1775,38 +1711,32 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_08_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2021_08_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1818,15 +1748,15 @@ class Encryption(msrest.serialization.Model): """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, - 'encryption_identity': {'key': 'identity', 'type': 'EncryptionIdentity'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, + "encryption_identity": {"key": "identity", "type": "EncryptionIdentity"}, } def __init__( @@ -1842,9 +1772,9 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_08_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2021_08_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1854,7 +1784,7 @@ def __init__( :keyword encryption_identity: The identity to be used with service-side encryption at rest. :paramtype encryption_identity: ~azure.mgmt.storage.v2021_08_01.models.EncryptionIdentity """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption @@ -1862,7 +1792,7 @@ def __init__( self.encryption_identity = encryption_identity -class EncryptionIdentity(msrest.serialization.Model): +class EncryptionIdentity(_serialization.Model): """Encryption identity for the storage account. :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be @@ -1875,8 +1805,8 @@ class EncryptionIdentity(msrest.serialization.Model): """ _attribute_map = { - 'encryption_user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, - 'encryption_federated_identity_client_id': {'key': 'federatedIdentityClientId', 'type': 'str'}, + "encryption_user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, + "encryption_federated_identity_client_id": {"key": "federatedIdentityClientId", "type": "str"}, } def __init__( @@ -1895,7 +1825,7 @@ def __init__( server-side encryption on the storage account. :paramtype encryption_federated_identity_client_id: str """ - super(EncryptionIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.encryption_user_assigned_identity = encryption_user_assigned_identity self.encryption_federated_identity_client_id = encryption_federated_identity_client_id @@ -1914,11 +1844,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Known values are: "Enabled", "Disabled". + Disabled. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -1935,23 +1865,23 @@ class EncryptionScope(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'EncryptionScopeKeyVaultProperties'}, - 'require_infrastructure_encryption': {'key': 'properties.requireInfrastructureEncryption', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "EncryptionScopeKeyVaultProperties"}, + "require_infrastructure_encryption": {"key": "properties.requireInfrastructureEncryption", "type": "bool"}, } def __init__( @@ -1965,11 +1895,11 @@ def __init__( ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Known values are: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -1979,7 +1909,7 @@ def __init__( applies a secondary layer of encryption with platform managed keys for data at rest. :paramtype require_infrastructure_encryption: bool """ - super(EncryptionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.state = state self.creation_time = None @@ -1988,7 +1918,7 @@ def __init__( self.require_infrastructure_encryption = require_infrastructure_encryption -class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): +class EncryptionScopeKeyVaultProperties(_serialization.Model): """The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. Variables are only populated by the server, and will be ignored when sending a request. @@ -2005,35 +1935,30 @@ class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_uri': {'key': 'keyUri', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_uri": {"key": "keyUri", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_uri: Optional[str] = None, **kwargs): """ :keyword key_uri: The object identifier for a key vault key object. When applied, the encryption scope will use the key referenced by the identifier to enable customer-managed key support on this encryption scope. :paramtype key_uri: str """ - super(EncryptionScopeKeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_uri = key_uri self.current_versioned_key_identifier = None self.last_key_rotation_timestamp = None -class EncryptionScopeListResult(msrest.serialization.Model): +class EncryptionScopeListResult(_serialization.Model): """List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. Variables are only populated by the server, and will be ignored when sending a request. @@ -2046,27 +1971,23 @@ class EncryptionScopeListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EncryptionScope]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EncryptionScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(EncryptionScopeListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -2079,26 +2000,22 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Known values are: "Service", "Account". + default service key is used. Known values are: "Service" and "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_08_01.models.KeyType """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'key_type': {'key': 'keyType', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "key_type": {"key": "keyType", "type": "str"}, } def __init__( - self, - *, - enabled: Optional[bool] = None, - key_type: Optional[Union[str, "_models.KeyType"]] = None, - **kwargs + self, *, enabled: Optional[bool] = None, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is @@ -2106,16 +2023,16 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Known values are: "Service", "Account". + that a default service key is used. Known values are: "Service" and "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_08_01.models.KeyType """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None self.key_type = key_type -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. :ivar blob: The encryption function of the blob storage service. @@ -2129,10 +2046,10 @@ class EncryptionServices(msrest.serialization.Model): """ _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -2154,14 +2071,14 @@ def __init__( :keyword queue: The encryption function of the queue storage service. :paramtype queue: ~azure.mgmt.storage.v2021_08_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = table self.queue = queue -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -2187,23 +2104,23 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, - 'microsoft_endpoints': {'key': 'microsoftEndpoints', 'type': 'StorageAccountMicrosoftEndpoints'}, - 'internet_endpoints': {'key': 'internetEndpoints', 'type': 'StorageAccountInternetEndpoints'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + "microsoft_endpoints": {"key": "microsoftEndpoints", "type": "StorageAccountMicrosoftEndpoints"}, + "internet_endpoints": {"key": "internetEndpoints", "type": "StorageAccountInternetEndpoints"}, } def __init__( @@ -2221,7 +2138,7 @@ def __init__( :paramtype internet_endpoints: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountInternetEndpoints """ - super(Endpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -2232,7 +2149,7 @@ def __init__( self.internet_endpoints = internet_endpoints -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the storage resource provider. :ivar error: Azure Storage Resource Provider error response body. @@ -2240,24 +2157,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure Storage Resource Provider error response body. :paramtype error: ~azure.mgmt.storage.v2021_08_01.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """Error response body contract. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -2269,17 +2181,11 @@ class ErrorResponseBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. @@ -2288,23 +2194,23 @@ def __init__( interface. :paramtype message: str """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ExtendedLocation(msrest.serialization.Model): +class ExtendedLocation(_serialization.Model): """The complex type of the extended location. :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Known values are: "EdgeZone". + :ivar type: The type of the extended location. "EdgeZone" :vartype type: str or ~azure.mgmt.storage.v2021_08_01.models.ExtendedLocationTypes """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -2317,15 +2223,15 @@ def __init__( """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Known values are: "EdgeZone". + :keyword type: The type of the extended location. "EdgeZone" :paramtype type: str or ~azure.mgmt.storage.v2021_08_01.models.ExtendedLocationTypes """ - super(ExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class FileServiceItems(msrest.serialization.Model): +class FileServiceItems(_serialization.Model): """FileServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -2335,20 +2241,16 @@ class FileServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileServiceProperties]'}, + "value": {"key": "value", "type": "[FileServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -2379,20 +2281,23 @@ class FileServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'share_delete_retention_policy': {'key': 'properties.shareDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'protocol_settings': {'key': 'properties.protocolSettings', 'type': 'ProtocolSettings'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "share_delete_retention_policy": { + "key": "properties.shareDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "protocol_settings": {"key": "properties.protocolSettings", "type": "ProtocolSettings"}, } def __init__( @@ -2414,14 +2319,14 @@ def __init__( :keyword protocol_settings: Protocol settings for file service. :paramtype protocol_settings: ~azure.mgmt.storage.v2021_08_01.models.ProtocolSettings """ - super(FileServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.share_delete_retention_policy = share_delete_retention_policy self.protocol_settings = protocol_settings -class FileShare(AzureEntityResource): +class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the file share, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -2444,10 +2349,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_08_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_08_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2459,7 +2364,7 @@ class FileShare(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2467,14 +2372,14 @@ class FileShare(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseStatus :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Known values are: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_08_01.models.SignedIdentifier] @@ -2484,48 +2389,48 @@ class FileShare(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2546,19 +2451,19 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_08_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_08_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_08_01.models.SignedIdentifier] """ - super(FileShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2579,7 +2484,7 @@ def __init__( self.snapshot_time = None -class FileShareItem(AzureEntityResource): +class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The file share properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -2602,10 +2507,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_08_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_08_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2617,7 +2522,7 @@ class FileShareItem(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2625,14 +2530,14 @@ class FileShareItem(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseStatus :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Known values are: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_08_01.models.SignedIdentifier] @@ -2642,48 +2547,48 @@ class FileShareItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2704,19 +2609,19 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_08_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_08_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_08_01.models.SignedIdentifier] """ - super(FileShareItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2737,7 +2642,7 @@ def __init__( self.snapshot_time = None -class FileShareItems(msrest.serialization.Model): +class FileShareItems(_serialization.Model): """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. Variables are only populated by the server, and will be ignored when sending a request. @@ -2750,27 +2655,23 @@ class FileShareItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileShareItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileShareItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2779,7 +2680,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_08_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2792,30 +2693,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2826,8 +2723,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_08_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2837,16 +2734,16 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( @@ -2857,8 +2754,8 @@ def __init__( **kwargs ): """ - :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_08_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2866,7 +2763,7 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.storage.v2021_08_01.models.UserAssignedIdentity] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type @@ -2892,7 +2789,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2910,22 +2807,25 @@ class ImmutabilityPolicy(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'properties.allowProtectedAppendWritesAll', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -2954,14 +2854,14 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None self.allow_protected_append_writes = allow_protected_append_writes self.allow_protected_append_writes_all = allow_protected_append_writes_all -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -2974,7 +2874,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2992,18 +2892,21 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'properties.allowProtectedAppendWritesAll', 'type': 'bool'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -3032,7 +2935,7 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days @@ -3041,7 +2944,7 @@ def __init__( self.allow_protected_append_writes_all = allow_protected_append_writes_all -class ImmutableStorageAccount(msrest.serialization.Model): +class ImmutableStorageAccount(_serialization.Model): """This property enables and defines account-level immutability. Enabling the feature auto-enables Blob Versioning. :ivar enabled: A boolean flag which enables account-level immutability. All the containers @@ -3057,8 +2960,8 @@ class ImmutableStorageAccount(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'immutability_policy': {'key': 'immutabilityPolicy', 'type': 'AccountImmutabilityPolicyProperties'}, + "enabled": {"key": "enabled", "type": "bool"}, + "immutability_policy": {"key": "immutabilityPolicy", "type": "AccountImmutabilityPolicyProperties"}, } def __init__( @@ -3080,12 +2983,12 @@ def __init__( :paramtype immutability_policy: ~azure.mgmt.storage.v2021_08_01.models.AccountImmutabilityPolicyProperties """ - super(ImmutableStorageAccount, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.immutability_policy = immutability_policy -class ImmutableStorageWithVersioning(msrest.serialization.Model): +class ImmutableStorageWithVersioning(_serialization.Model): """Object level immutability properties of the container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3096,81 +2999,68 @@ class ImmutableStorageWithVersioning(msrest.serialization.Model): :ivar time_stamp: Returns the date and time the object level immutability was enabled. :vartype time_stamp: ~datetime.datetime :ivar migration_state: This property denotes the container level immutability to object level - immutability migration state. Known values are: "InProgress", "Completed". + immutability migration state. Known values are: "InProgress" and "Completed". :vartype migration_state: str or ~azure.mgmt.storage.v2021_08_01.models.MigrationState """ _validation = { - 'time_stamp': {'readonly': True}, - 'migration_state': {'readonly': True}, + "time_stamp": {"readonly": True}, + "migration_state": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'migration_state': {'key': 'migrationState', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "migration_state": {"key": "migrationState", "type": "str"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: This is an immutable property, when set to true it enables object level immutability at the container level. :paramtype enabled: bool """ - super(ImmutableStorageWithVersioning, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.time_stamp = None self.migration_state = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyCreationTime(msrest.serialization.Model): +class KeyCreationTime(_serialization.Model): """Storage account keys creation time. :ivar key1: @@ -3180,60 +3070,49 @@ class KeyCreationTime(msrest.serialization.Model): """ _attribute_map = { - 'key1': {'key': 'key1', 'type': 'iso-8601'}, - 'key2': {'key': 'key2', 'type': 'iso-8601'}, + "key1": {"key": "key1", "type": "iso-8601"}, + "key2": {"key": "key2", "type": "iso-8601"}, } - def __init__( - self, - *, - key1: Optional[datetime.datetime] = None, - key2: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, key1: Optional[datetime.datetime] = None, key2: Optional[datetime.datetime] = None, **kwargs): """ :keyword key1: :paramtype key1: ~datetime.datetime :keyword key2: :paramtype key2: ~datetime.datetime """ - super(KeyCreationTime, self).__init__(**kwargs) + super().__init__(**kwargs) self.key1 = key1 self.key2 = key2 -class KeyPolicy(msrest.serialization.Model): +class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar key_expiration_period_in_days: Required. The key expiration period in days. + :ivar key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int """ _validation = { - 'key_expiration_period_in_days': {'required': True}, + "key_expiration_period_in_days": {"required": True}, } _attribute_map = { - 'key_expiration_period_in_days': {'key': 'keyExpirationPeriodInDays', 'type': 'int'}, + "key_expiration_period_in_days": {"key": "keyExpirationPeriodInDays", "type": "int"}, } - def __init__( - self, - *, - key_expiration_period_in_days: int, - **kwargs - ): + def __init__(self, *, key_expiration_period_in_days: int, **kwargs): """ - :keyword key_expiration_period_in_days: Required. The key expiration period in days. + :keyword key_expiration_period_in_days: The key expiration period in days. Required. :paramtype key_expiration_period_in_days: int """ - super(KeyPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_expiration_period_in_days = key_expiration_period_in_days -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. Variables are only populated by the server, and will be ignored when sending a request. @@ -3252,16 +3131,16 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } def __init__( @@ -3280,7 +3159,7 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri @@ -3288,15 +3167,15 @@ def __init__( self.last_key_rotation_timestamp = None -class LastAccessTimeTrackingPolicy(msrest.serialization.Model): +class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. All required parameters must be populated in order to send to Azure. - :ivar enable: Required. When set to true last access time based tracking is enabled. + :ivar enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Known values are: "AccessTimeTracking". + read only. "AccessTimeTracking" :vartype name: str or ~azure.mgmt.storage.v2021_08_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3308,14 +3187,14 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): """ _validation = { - 'enable': {'required': True}, + "enable": {"required": True}, } _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tracking_granularity_in_days': {'key': 'trackingGranularityInDays', 'type': 'int'}, - 'blob_type': {'key': 'blobType', 'type': '[str]'}, + "enable": {"key": "enable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "tracking_granularity_in_days": {"key": "trackingGranularityInDays", "type": "int"}, + "blob_type": {"key": "blobType", "type": "[str]"}, } def __init__( @@ -3328,10 +3207,10 @@ def __init__( **kwargs ): """ - :keyword enable: Required. When set to true last access time based tracking is enabled. + :keyword enable: When set to true last access time based tracking is enabled. Required. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Known values are: "AccessTimeTracking". + currently read only. "AccessTimeTracking" :paramtype name: str or ~azure.mgmt.storage.v2021_08_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3341,20 +3220,20 @@ def __init__( supported value. This field is currently read only. :paramtype blob_type: list[str] """ - super(LastAccessTimeTrackingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enable = enable self.name = name self.tracking_granularity_in_days = tracking_granularity_in_days self.blob_type = blob_type -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3370,15 +3249,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -3392,8 +3271,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3407,7 +3286,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -3415,7 +3294,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -3426,17 +3305,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -3444,18 +3317,18 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LeaseShareRequest(msrest.serialization.Model): +class LeaseShareRequest(_serialization.Model): """Lease Share request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3471,15 +3344,15 @@ class LeaseShareRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -3493,8 +3366,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3508,7 +3381,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseShareRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -3516,7 +3389,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseShareResponse(msrest.serialization.Model): +class LeaseShareResponse(_serialization.Model): """Lease Share response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -3527,17 +3400,11 @@ class LeaseShareResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the share, or to renew, change, or release the lease. @@ -3545,12 +3412,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseShareResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3562,8 +3429,8 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] :ivar allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks @@ -3572,39 +3439,33 @@ class LegalHold(msrest.serialization.Model): """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, } - def __init__( - self, - *, - tags: List[str], - allow_protected_append_writes_all: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, tags: List[str], allow_protected_append_writes_all: Optional[bool] = None, **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes_all: bool """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags self.allow_protected_append_writes_all = allow_protected_append_writes_all -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3614,7 +3475,7 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2021_08_01.models.TagProperty] :ivar protected_append_writes_history: Protected append blob writes history. :vartype protected_append_writes_history: @@ -3622,13 +3483,16 @@ class LegalHoldProperties(msrest.serialization.Model): """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, - 'protected_append_writes_history': {'key': 'protectedAppendWritesHistory', 'type': 'ProtectedAppendWritesHistory'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, + "protected_append_writes_history": { + "key": "protectedAppendWritesHistory", + "type": "ProtectedAppendWritesHistory", + }, } def __init__( @@ -3639,19 +3503,19 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2021_08_01.models.TagProperty] :keyword protected_append_writes_history: Protected append blob writes history. :paramtype protected_append_writes_history: ~azure.mgmt.storage.v2021_08_01.models.ProtectedAppendWritesHistory """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags self.protected_append_writes_history = protected_append_writes_history -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3661,24 +3525,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListBlobInventoryPolicy(msrest.serialization.Model): +class ListBlobInventoryPolicy(_serialization.Model): """List of blob inventory policies returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3688,24 +3548,20 @@ class ListBlobInventoryPolicy(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobInventoryPolicy]'}, + "value": {"key": "value", "type": "[BlobInventoryPolicy]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListBlobInventoryPolicy, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -3735,17 +3591,18 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_08_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3775,48 +3632,51 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, - 'enable_nfs_v3_root_squash': {'key': 'properties.enableNfsV3RootSquash', 'type': 'bool'}, - 'enable_nfs_v3_all_squash': {'key': 'properties.enableNfsV3AllSquash', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, } def __init__( @@ -3839,7 +3699,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -3853,7 +3713,7 @@ def __init__( :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. :paramtype enable_nfs_v3_all_squash: bool """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -3875,7 +3735,7 @@ def __init__( self.enable_nfs_v3_all_squash = enable_nfs_v3_all_squash -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. Variables are only populated by the server, and will be ignored when sending a request. @@ -3888,22 +3748,18 @@ class ListContainerItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListContainerItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -3926,33 +3782,28 @@ class ListQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(ListQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata -class ListQueueResource(msrest.serialization.Model): +class ListQueueResource(_serialization.Model): """Response schema. Contains list of queues returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3964,27 +3815,23 @@ class ListQueueResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListQueueServices(msrest.serialization.Model): +class ListQueueServices(_serialization.Model): """ListQueueServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -3994,24 +3841,20 @@ class ListQueueServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueServiceProperties]'}, + "value": {"key": "value", "type": "[QueueServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -4021,24 +3864,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class ListTableResource(msrest.serialization.Model): +class ListTableResource(_serialization.Model): """Response schema. Contains list of tables returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -4050,27 +3889,23 @@ class ListTableResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Table]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Table]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListTableServices(msrest.serialization.Model): +class ListTableServices(_serialization.Model): """ListTableServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -4080,24 +3915,20 @@ class ListTableServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TableServiceProperties]'}, + "value": {"key": "value", "type": "[TableServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class LocalUser(Resource): +class LocalUser(Resource): # pylint: disable=too-many-instance-attributes """The local user associated with the storage accounts. Variables are only populated by the server, and will be ignored when sending a request. @@ -4132,25 +3963,25 @@ class LocalUser(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'sid': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "sid": {"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'}, - 'permission_scopes': {'key': 'properties.permissionScopes', 'type': '[PermissionScope]'}, - 'home_directory': {'key': 'properties.homeDirectory', 'type': 'str'}, - 'ssh_authorized_keys': {'key': 'properties.sshAuthorizedKeys', 'type': '[SshPublicKey]'}, - 'sid': {'key': 'properties.sid', 'type': 'str'}, - 'has_shared_key': {'key': 'properties.hasSharedKey', 'type': 'bool'}, - 'has_ssh_key': {'key': 'properties.hasSshKey', 'type': 'bool'}, - 'has_ssh_password': {'key': 'properties.hasSshPassword', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "permission_scopes": {"key": "properties.permissionScopes", "type": "[PermissionScope]"}, + "home_directory": {"key": "properties.homeDirectory", "type": "str"}, + "ssh_authorized_keys": {"key": "properties.sshAuthorizedKeys", "type": "[SshPublicKey]"}, + "sid": {"key": "properties.sid", "type": "str"}, + "has_shared_key": {"key": "properties.hasSharedKey", "type": "bool"}, + "has_ssh_key": {"key": "properties.hasSshKey", "type": "bool"}, + "has_ssh_password": {"key": "properties.hasSshPassword", "type": "bool"}, } def __init__( @@ -4181,7 +4012,7 @@ def __init__( existing SSH password. :paramtype has_ssh_password: bool """ - super(LocalUser, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.permission_scopes = permission_scopes self.home_directory = home_directory @@ -4192,7 +4023,7 @@ def __init__( self.has_ssh_password = has_ssh_password -class LocalUserKeys(msrest.serialization.Model): +class LocalUserKeys(_serialization.Model): """The Storage Account Local User keys. Variables are only populated by the server, and will be ignored when sending a request. @@ -4204,30 +4035,25 @@ class LocalUserKeys(msrest.serialization.Model): """ _validation = { - 'shared_key': {'readonly': True}, + "shared_key": {"readonly": True}, } _attribute_map = { - 'ssh_authorized_keys': {'key': 'sshAuthorizedKeys', 'type': '[SshPublicKey]'}, - 'shared_key': {'key': 'sharedKey', 'type': 'str'}, + "ssh_authorized_keys": {"key": "sshAuthorizedKeys", "type": "[SshPublicKey]"}, + "shared_key": {"key": "sharedKey", "type": "str"}, } - def __init__( - self, - *, - ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, - **kwargs - ): + def __init__(self, *, ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs): """ :keyword ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. :paramtype ssh_authorized_keys: list[~azure.mgmt.storage.v2021_08_01.models.SshPublicKey] """ - super(LocalUserKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.ssh_authorized_keys = ssh_authorized_keys self.shared_key = None -class LocalUserRegeneratePasswordResult(msrest.serialization.Model): +class LocalUserRegeneratePasswordResult(_serialization.Model): """The secrets of Storage Account Local User. Variables are only populated by the server, and will be ignored when sending a request. @@ -4238,24 +4064,20 @@ class LocalUserRegeneratePasswordResult(msrest.serialization.Model): """ _validation = { - 'ssh_password': {'readonly': True}, + "ssh_password": {"readonly": True}, } _attribute_map = { - 'ssh_password': {'key': 'sshPassword', 'type': 'str'}, + "ssh_password": {"key": "sshPassword", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LocalUserRegeneratePasswordResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ssh_password = None -class LocalUsers(msrest.serialization.Model): +class LocalUsers(_serialization.Model): """List storage account local users. :ivar value: The local users associated with the storage account. @@ -4263,20 +4085,15 @@ class LocalUsers(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[LocalUser]'}, + "value": {"key": "value", "type": "[LocalUser]"}, } - def __init__( - self, - *, - value: Optional[List["_models.LocalUser"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.LocalUser"]] = None, **kwargs): """ :keyword value: The local users associated with the storage account. :paramtype value: list[~azure.mgmt.storage.v2021_08_01.models.LocalUser] """ - super(LocalUsers, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4301,37 +4118,32 @@ class ManagementPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.ManagementPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :paramtype policy: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicySchema """ - super(ManagementPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.policy = policy -class ManagementPolicyAction(msrest.serialization.Model): +class ManagementPolicyAction(_serialization.Model): """Actions are applied to the filtered blobs when the execution condition is met. :ivar base_blob: The management policy action for base blob. @@ -4343,9 +4155,9 @@ class ManagementPolicyAction(msrest.serialization.Model): """ _attribute_map = { - 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, - 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, - 'version': {'key': 'version', 'type': 'ManagementPolicyVersion'}, + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, + "version": {"key": "version", "type": "ManagementPolicyVersion"}, } def __init__( @@ -4364,13 +4176,13 @@ def __init__( :keyword version: The management policy action for version. :paramtype version: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyVersion """ - super(ManagementPolicyAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_blob = base_blob self.snapshot = snapshot self.version = version -class ManagementPolicyBaseBlob(msrest.serialization.Model): +class ManagementPolicyBaseBlob(_serialization.Model): """Management policy action for base blob. :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot @@ -4387,10 +4199,10 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, - 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, - 'enable_auto_tier_to_hot_from_cool': {'key': 'enableAutoTierToHotFromCool', 'type': 'bool'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, + "enable_auto_tier_to_hot_from_cool": {"key": "enableAutoTierToHotFromCool", "type": "bool"}, } def __init__( @@ -4416,31 +4228,31 @@ def __init__( tierToCool.daysAfterLastAccessTimeGreaterThan. :paramtype enable_auto_tier_to_hot_from_cool: bool """ - super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool -class ManagementPolicyDefinition(msrest.serialization.Model): +class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. All required parameters must be populated in order to send to Azure. - :ivar actions: Required. An object that defines the action set. + :ivar actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyAction :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyFilter """ _validation = { - 'actions': {'required': True}, + "actions": {"required": True}, } _attribute_map = { - 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, - 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, } def __init__( @@ -4451,25 +4263,25 @@ def __init__( **kwargs ): """ - :keyword actions: Required. An object that defines the action set. + :keyword actions: An object that defines the action set. Required. :paramtype actions: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyAction :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyFilter """ - super(ManagementPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.filters = filters -class ManagementPolicyFilter(msrest.serialization.Model): +class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :ivar blob_types: An array of predefined enum values. Currently blockBlob supports all tiering + and delete actions. Only delete actions are supported for appendBlob. Required. :vartype blob_types: list[str] :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. @@ -4477,13 +4289,13 @@ class ManagementPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'blob_index_match': {'key': 'blobIndexMatch', 'type': '[TagFilter]'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "blob_index_match": {"key": "blobIndexMatch", "type": "[TagFilter]"}, } def __init__( @@ -4497,46 +4309,46 @@ def __init__( """ :keyword prefix_match: An array of strings for prefixes to be match. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :keyword blob_types: An array of predefined enum values. Currently blockBlob supports all + tiering and delete actions. Only delete actions are supported for appendBlob. Required. :paramtype blob_types: list[str] :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. :paramtype blob_index_match: list[~azure.mgmt.storage.v2021_08_01.models.TagFilter] """ - super(ManagementPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.blob_index_match = blob_index_match -class ManagementPolicyRule(msrest.serialization.Model): +class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. :ivar enabled: Rule is enabled if set to true. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" :vartype type: str or ~azure.mgmt.storage.v2021_08_01.models.RuleType - :ivar definition: Required. An object that defines the Lifecycle rule. + :ivar definition: An object that defines the Lifecycle rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyDefinition """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - 'definition': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, } def __init__( @@ -4551,55 +4363,52 @@ def __init__( """ :keyword enabled: Rule is enabled if set to true. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" :paramtype type: str or ~azure.mgmt.storage.v2021_08_01.models.RuleType - :keyword definition: Required. An object that defines the Lifecycle rule. + :keyword definition: An object that defines the Lifecycle rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyDefinition """ - super(ManagementPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.type = type self.definition = definition -class ManagementPolicySchema(msrest.serialization.Model): +class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. All required parameters must be populated in order to send to Azure. - :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :vartype rules: list[~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyRule] """ _validation = { - 'rules': {'required': True}, + "rules": {"required": True}, } _attribute_map = { - 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, } - def __init__( - self, - *, - rules: List["_models.ManagementPolicyRule"], - **kwargs - ): + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): """ - :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :paramtype rules: list[~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyRule] """ - super(ManagementPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.rules = rules -class ManagementPolicySnapShot(msrest.serialization.Model): +class ManagementPolicySnapShot(_serialization.Model): """Management policy action for snapshot. :ivar tier_to_cool: The function to tier blob snapshot to cool storage. Support blob snapshot @@ -4613,9 +4422,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -4636,13 +4445,13 @@ def __init__( :keyword delete: The function to delete the blob snapshot. :paramtype delete: ~azure.mgmt.storage.v2021_08_01.models.DateAfterCreation """ - super(ManagementPolicySnapShot, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class ManagementPolicyVersion(msrest.serialization.Model): +class ManagementPolicyVersion(_serialization.Model): """Management policy action for blob version. :ivar tier_to_cool: The function to tier blob version to cool storage. Support blob version @@ -4656,9 +4465,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -4679,13 +4488,13 @@ def __init__( :keyword delete: The function to delete the blob version. :paramtype delete: ~azure.mgmt.storage.v2021_08_01.models.DateAfterCreation """ - super(ManagementPolicyVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -4709,15 +4518,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -4754,7 +4563,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -4766,7 +4575,7 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class Multichannel(msrest.serialization.Model): +class Multichannel(_serialization.Model): """Multichannel setting. Applies to Premium FileStorage only. :ivar enabled: Indicates whether multichannel is enabled. @@ -4774,32 +4583,27 @@ class Multichannel(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Indicates whether multichannel is enabled. :paramtype enabled: bool """ - super(Multichannel, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_08_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_08_01.models.ResourceAccessRule] @@ -4807,28 +4611,28 @@ class NetworkRuleSet(msrest.serialization.Model): :vartype virtual_network_rules: list[~azure.mgmt.storage.v2021_08_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_08_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2021_08_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'resource_access_rules': {'key': 'resourceAccessRules', 'type': '[ResourceAccessRule]'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "resource_access_rules": {"key": "resourceAccessRules", "type": "[ResourceAccessRule]"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, @@ -4838,7 +4642,7 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_08_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4848,11 +4652,11 @@ def __init__( list[~azure.mgmt.storage.v2021_08_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_08_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2021_08_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.resource_access_rules = resource_access_rules self.virtual_network_rules = virtual_network_rules @@ -4860,7 +4664,7 @@ def __init__( self.default_action = default_action -class ObjectReplicationPolicies(msrest.serialization.Model): +class ObjectReplicationPolicies(_serialization.Model): """List storage account object replication policies. :ivar value: The replication policy between two storage accounts. @@ -4868,20 +4672,15 @@ class ObjectReplicationPolicies(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ObjectReplicationPolicy]'}, + "value": {"key": "value", "type": "[ObjectReplicationPolicy]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ObjectReplicationPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs): """ :keyword value: The replication policy between two storage accounts. :paramtype value: list[~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy] """ - super(ObjectReplicationPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4913,22 +4712,22 @@ class ObjectReplicationPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_id': {'readonly': True}, - 'enabled_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_id": {"readonly": True}, + "enabled_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, - 'enabled_time': {'key': 'properties.enabledTime', 'type': 'iso-8601'}, - 'source_account': {'key': 'properties.sourceAccount', 'type': 'str'}, - 'destination_account': {'key': 'properties.destinationAccount', 'type': 'str'}, - 'rules': {'key': 'properties.rules', 'type': '[ObjectReplicationPolicyRule]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "enabled_time": {"key": "properties.enabledTime", "type": "iso-8601"}, + "source_account": {"key": "properties.sourceAccount", "type": "str"}, + "destination_account": {"key": "properties.destinationAccount", "type": "str"}, + "rules": {"key": "properties.rules", "type": "[ObjectReplicationPolicyRule]"}, } def __init__( @@ -4949,7 +4748,7 @@ def __init__( :keyword rules: The storage account object replication rules. :paramtype rules: list[~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicyRule] """ - super(ObjectReplicationPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_id = None self.enabled_time = None self.source_account = source_account @@ -4957,7 +4756,7 @@ def __init__( self.rules = rules -class ObjectReplicationPolicyFilter(msrest.serialization.Model): +class ObjectReplicationPolicyFilter(_serialization.Model): """Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the filter. If multiple filters are defined, a logical AND is performed on all filters. :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin @@ -4969,17 +4768,11 @@ class ObjectReplicationPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'min_creation_time': {'key': 'minCreationTime', 'type': 'str'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "min_creation_time": {"key": "minCreationTime", "type": "str"}, } - def __init__( - self, - *, - prefix_match: Optional[List[str]] = None, - min_creation_time: Optional[str] = None, - **kwargs - ): + def __init__(self, *, prefix_match: Optional[List[str]] = None, min_creation_time: Optional[str] = None, **kwargs): """ :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. @@ -4988,12 +4781,12 @@ def __init__( It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. :paramtype min_creation_time: str """ - super(ObjectReplicationPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.min_creation_time = min_creation_time -class ObjectReplicationPolicyRule(msrest.serialization.Model): +class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. All required parameters must be populated in order to send to Azure. @@ -5001,24 +4794,24 @@ class ObjectReplicationPolicyRule(msrest.serialization.Model): :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :vartype rule_id: str - :ivar source_container: Required. Required. Source container name. + :ivar source_container: Required. Source container name. Required. :vartype source_container: str - :ivar destination_container: Required. Required. Destination container name. + :ivar destination_container: Required. Destination container name. Required. :vartype destination_container: str :ivar filters: Optional. An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicyFilter """ _validation = { - 'source_container': {'required': True}, - 'destination_container': {'required': True}, + "source_container": {"required": True}, + "destination_container": {"required": True}, } _attribute_map = { - 'rule_id': {'key': 'ruleId', 'type': 'str'}, - 'source_container': {'key': 'sourceContainer', 'type': 'str'}, - 'destination_container': {'key': 'destinationContainer', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': 'ObjectReplicationPolicyFilter'}, + "rule_id": {"key": "ruleId", "type": "str"}, + "source_container": {"key": "sourceContainer", "type": "str"}, + "destination_container": {"key": "destinationContainer", "type": "str"}, + "filters": {"key": "filters", "type": "ObjectReplicationPolicyFilter"}, } def __init__( @@ -5034,21 +4827,21 @@ def __init__( :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :paramtype rule_id: str - :keyword source_container: Required. Required. Source container name. + :keyword source_container: Required. Source container name. Required. :paramtype source_container: str - :keyword destination_container: Required. Required. Destination container name. + :keyword destination_container: Required. Destination container name. Required. :paramtype destination_container: str :keyword filters: Optional. An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicyFilter """ - super(ObjectReplicationPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.rule_id = rule_id self.source_container = source_container self.destination_container = destination_container self.filters = filters -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -5062,10 +4855,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -5087,14 +4880,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2021_08_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -5108,10 +4901,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -5133,14 +4926,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -5148,75 +4941,63 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2021_08_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PermissionScope(msrest.serialization.Model): +class PermissionScope(_serialization.Model): """PermissionScope. All required parameters must be populated in order to send to Azure. - :ivar permissions: Required. The permissions for the local user. Possible values include: Read - (r), Write (w), Delete (d), List (l), and Create (c). + :ivar permissions: The permissions for the local user. Possible values include: Read (r), Write + (w), Delete (d), List (l), and Create (c). Required. :vartype permissions: str - :ivar service: Required. The service used by the local user, e.g. blob, file. + :ivar service: The service used by the local user, e.g. blob, file. Required. :vartype service: str - :ivar resource_name: Required. The name of resource, normally the container name or the file - share name, used by the local user. + :ivar resource_name: The name of resource, normally the container name or the file share name, + used by the local user. Required. :vartype resource_name: str """ _validation = { - 'permissions': {'required': True}, - 'service': {'required': True}, - 'resource_name': {'required': True}, + "permissions": {"required": True}, + "service": {"required": True}, + "resource_name": {"required": True}, } _attribute_map = { - 'permissions': {'key': 'permissions', 'type': 'str'}, - 'service': {'key': 'service', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "permissions": {"key": "permissions", "type": "str"}, + "service": {"key": "service", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } - def __init__( - self, - *, - permissions: str, - service: str, - resource_name: str, - **kwargs - ): + def __init__(self, *, permissions: str, service: str, resource_name: str, **kwargs): """ - :keyword permissions: Required. The permissions for the local user. Possible values include: - Read (r), Write (w), Delete (d), List (l), and Create (c). + :keyword permissions: The permissions for the local user. Possible values include: Read (r), + Write (w), Delete (d), List (l), and Create (c). Required. :paramtype permissions: str - :keyword service: Required. The service used by the local user, e.g. blob, file. + :keyword service: The service used by the local user, e.g. blob, file. Required. :paramtype service: str - :keyword resource_name: Required. The name of resource, normally the container name or the file - share name, used by the local user. + :keyword resource_name: The name of resource, normally the container name or the file share + name, used by the local user. Required. :paramtype resource_name: str """ - super(PermissionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.permissions = permissions self.service = service self.resource_name = resource_name -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -5226,20 +5007,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -5263,25 +5040,28 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_08_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -5299,13 +5079,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.storage.v2021_08_01.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """List of private endpoint connection associated with the specified storage account. :ivar value: Array of private endpoint connections. @@ -5313,20 +5093,15 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -5352,39 +5127,34 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "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, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): """ :keyword required_zone_names: The private link resource Private link DNS zone name. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. @@ -5392,28 +5162,23 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.storage.v2021_08_01.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", and "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -5424,9 +5189,9 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'action_required': {'key': 'actionRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "action_required": {"key": "actionRequired", "type": "str"}, } def __init__( @@ -5439,7 +5204,7 @@ def __init__( ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", and "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -5448,13 +5213,13 @@ def __init__( updates on the consumer. :paramtype action_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.action_required = action_required -class ProtectedAppendWritesHistory(msrest.serialization.Model): +class ProtectedAppendWritesHistory(_serialization.Model): """Protected append writes history setting for the blob container with Legal holds. Variables are only populated by the server, and will be ignored when sending a request. @@ -5468,32 +5233,27 @@ class ProtectedAppendWritesHistory(msrest.serialization.Model): """ _validation = { - 'timestamp': {'readonly': True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - allow_protected_append_writes_all: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, allow_protected_append_writes_all: Optional[bool] = None, **kwargs): """ :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes_all: bool """ - super(ProtectedAppendWritesHistory, self).__init__(**kwargs) + super().__init__(**kwargs) self.allow_protected_append_writes_all = allow_protected_append_writes_all self.timestamp = None -class ProtocolSettings(msrest.serialization.Model): +class ProtocolSettings(_serialization.Model): """Protocol settings for file service. :ivar smb: Setting for SMB protocol. @@ -5501,20 +5261,15 @@ class ProtocolSettings(msrest.serialization.Model): """ _attribute_map = { - 'smb': {'key': 'smb', 'type': 'SmbSetting'}, + "smb": {"key": "smb", "type": "SmbSetting"}, } - def __init__( - self, - *, - smb: Optional["_models.SmbSetting"] = None, - **kwargs - ): + def __init__(self, *, smb: Optional["_models.SmbSetting"] = None, **kwargs): """ :keyword smb: Setting for SMB protocol. :paramtype smb: ~azure.mgmt.storage.v2021_08_01.models.SmbSetting """ - super(ProtocolSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.smb = smb @@ -5538,35 +5293,30 @@ class QueueServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Queue service. :paramtype cors: ~azure.mgmt.storage.v2021_08_01.models.CorsRules """ - super(QueueServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class ResourceAccessRule(msrest.serialization.Model): +class ResourceAccessRule(_serialization.Model): """Resource Access Rule. :ivar tenant_id: Tenant Id. @@ -5576,36 +5326,30 @@ class ResourceAccessRule(msrest.serialization.Model): """ _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__( - self, - *, - tenant_id: Optional[str] = None, - resource_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tenant_id: Optional[str] = None, resource_id: Optional[str] = None, **kwargs): """ :keyword tenant_id: Tenant Id. :paramtype tenant_id: str :keyword resource_id: Resource Id. :paramtype resource_id: str """ - super(ResourceAccessRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.tenant_id = tenant_id self.resource_id = resource_id -class RestorePolicyProperties(msrest.serialization.Model): +class RestorePolicyProperties(_serialization.Model): """The blob service properties for blob restore policy. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Blob restore is enabled if set to true. + :ivar enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool :ivar days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. @@ -5617,41 +5361,35 @@ class RestorePolicyProperties(msrest.serialization.Model): """ _validation = { - 'enabled': {'required': True}, - 'days': {'maximum': 365, 'minimum': 1}, - 'last_enabled_time': {'readonly': True}, - 'min_restore_time': {'readonly': True}, + "enabled": {"required": True}, + "days": {"maximum": 365, "minimum": 1}, + "last_enabled_time": {"readonly": True}, + "min_restore_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'min_restore_time': {'key': 'minRestoreTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "min_restore_time": {"key": "minRestoreTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: bool, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: bool, days: Optional[int] = None, **kwargs): """ - :keyword enabled: Required. Blob restore is enabled if set to true. + :keyword enabled: Blob restore is enabled if set to true. Required. :paramtype enabled: bool :keyword days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. :paramtype days: int """ - super(RestorePolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days self.last_enabled_time = None self.min_restore_time = None -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -5664,45 +5402,40 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_08_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_08_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class RoutingPreference(msrest.serialization.Model): +class RoutingPreference(_serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_08_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5713,9 +5446,9 @@ class RoutingPreference(msrest.serialization.Model): """ _attribute_map = { - 'routing_choice': {'key': 'routingChoice', 'type': 'str'}, - 'publish_microsoft_endpoints': {'key': 'publishMicrosoftEndpoints', 'type': 'bool'}, - 'publish_internet_endpoints': {'key': 'publishInternetEndpoints', 'type': 'bool'}, + "routing_choice": {"key": "routingChoice", "type": "str"}, + "publish_microsoft_endpoints": {"key": "publishMicrosoftEndpoints", "type": "bool"}, + "publish_internet_endpoints": {"key": "publishInternetEndpoints", "type": "bool"}, } def __init__( @@ -5728,7 +5461,7 @@ def __init__( ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_08_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5737,72 +5470,66 @@ def __init__( storage endpoints are to be published. :paramtype publish_internet_endpoints: bool """ - super(RoutingPreference, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_choice = routing_choice self.publish_microsoft_endpoints = publish_microsoft_endpoints self.publish_internet_endpoints = publish_internet_endpoints -class SasPolicy(msrest.serialization.Model): +class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :ivar sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str - :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :ivar expiration_action: The SAS expiration action. Can only be Log. "Log" :vartype expiration_action: str or ~azure.mgmt.storage.v2021_08_01.models.ExpirationAction """ _validation = { - 'sas_expiration_period': {'required': True}, - 'expiration_action': {'required': True}, + "sas_expiration_period": {"required": True}, + "expiration_action": {"required": True}, } _attribute_map = { - 'sas_expiration_period': {'key': 'sasExpirationPeriod', 'type': 'str'}, - 'expiration_action': {'key': 'expirationAction', 'type': 'str'}, + "sas_expiration_period": {"key": "sasExpirationPeriod", "type": "str"}, + "expiration_action": {"key": "expirationAction", "type": "str"}, } def __init__( - self, - *, - sas_expiration_period: str, - expiration_action: Union[str, "_models.ExpirationAction"] = "Log", - **kwargs + self, *, sas_expiration_period: str, expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs ): """ - :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :keyword sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :paramtype sas_expiration_period: str - :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :keyword expiration_action: The SAS expiration action. Can only be Log. "Log" :paramtype expiration_action: str or ~azure.mgmt.storage.v2021_08_01.models.ExpirationAction """ - super(SasPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_expiration_period = sas_expiration_period self.expiration_action = expiration_action -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2021_08_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_08_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_08_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -5834,29 +5561,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, - } - - _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, + } + + _attribute_map = { + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -5883,20 +5610,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_08_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_08_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_08_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -5927,7 +5655,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -5948,7 +5676,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -5957,25 +5685,20 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2021_08_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class SignedIdentifier(msrest.serialization.Model): +class SignedIdentifier(_serialization.Model): """SignedIdentifier. :ivar id: An unique identifier of the stored access policy. @@ -5985,14 +5708,14 @@ class SignedIdentifier(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'access_policy': {'key': 'accessPolicy', 'type': 'AccessPolicy'}, + "id": {"key": "id", "type": "str"}, + "access_policy": {"key": "accessPolicy", "type": "AccessPolicy"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin access_policy: Optional["_models.AccessPolicy"] = None, **kwargs ): @@ -6002,57 +5725,52 @@ def __init__( :keyword access_policy: Access policy. :paramtype access_policy: ~azure.mgmt.storage.v2021_08_01.models.AccessPolicy """ - super(SignedIdentifier, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.access_policy = access_policy -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_08_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_08_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_08_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -6065,45 +5783,41 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Storage SKU and its properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_08_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_08_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -6117,22 +5831,22 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -6143,16 +5857,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_08_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2021_08_01.models.Restriction] """ - super(SkuInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -6162,7 +5876,7 @@ def __init__( self.restrictions = restrictions -class SmbSetting(msrest.serialization.Model): +class SmbSetting(_serialization.Model): """Setting for SMB protocol. :ivar multichannel: Multichannel setting. Applies to Premium FileStorage only. @@ -6182,11 +5896,11 @@ class SmbSetting(msrest.serialization.Model): """ _attribute_map = { - 'multichannel': {'key': 'multichannel', 'type': 'Multichannel'}, - 'versions': {'key': 'versions', 'type': 'str'}, - 'authentication_methods': {'key': 'authenticationMethods', 'type': 'str'}, - 'kerberos_ticket_encryption': {'key': 'kerberosTicketEncryption', 'type': 'str'}, - 'channel_encryption': {'key': 'channelEncryption', 'type': 'str'}, + "multichannel": {"key": "multichannel", "type": "Multichannel"}, + "versions": {"key": "versions", "type": "str"}, + "authentication_methods": {"key": "authenticationMethods", "type": "str"}, + "kerberos_ticket_encryption": {"key": "kerberosTicketEncryption", "type": "str"}, + "channel_encryption": {"key": "channelEncryption", "type": "str"}, } def __init__( @@ -6215,7 +5929,7 @@ def __init__( AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. :paramtype channel_encryption: str """ - super(SmbSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.multichannel = multichannel self.versions = versions self.authentication_methods = authentication_methods @@ -6223,7 +5937,7 @@ def __init__( self.channel_encryption = channel_encryption -class SshPublicKey(msrest.serialization.Model): +class SshPublicKey(_serialization.Model): """SshPublicKey. :ivar description: Optional. It is used to store the function/usage of the key. @@ -6234,17 +5948,11 @@ class SshPublicKey(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - description: Optional[str] = None, - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, key: Optional[str] = None, **kwargs): """ :keyword description: Optional. It is used to store the function/usage of the key. :paramtype description: str @@ -6252,7 +5960,7 @@ def __init__( :code:``', e.g. ssh-rsa AAAABBBB. :paramtype key: str """ - super(SshPublicKey, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.key = key @@ -6272,46 +5980,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -6326,21 +6028,21 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_08_01.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_08_01.models.Identity :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_08_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_08_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -6349,7 +6051,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_08_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -6361,7 +6063,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_08_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -6381,7 +6083,7 @@ class StorageAccount(TrackedResource): account. :vartype encryption: ~azure.mgmt.storage.v2021_08_01.models.Encryption :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6403,7 +6105,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -6420,7 +6122,7 @@ class StorageAccount(TrackedResource): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6436,7 +6138,7 @@ class StorageAccount(TrackedResource): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess @@ -6446,88 +6148,97 @@ class StorageAccount(TrackedResource): :vartype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_08_01.models.ImmutableStorageAccount :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'sas_policy': {'readonly': True}, - 'key_policy': {'readonly': True}, - 'key_creation_time': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'blob_restore_status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'key_creation_time': {'key': 'properties.keyCreationTime', 'type': 'KeyCreationTime'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, - 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'blob_restore_status': {'key': 'properties.blobRestoreStatus', 'type': 'BlobRestoreStatus'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, - 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "sas_policy": {"readonly": True}, + "key_policy": {"readonly": True}, + "key_creation_time": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "blob_restore_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "key_creation_time": {"key": "properties.keyCreationTime", "type": "KeyCreationTime"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "blob_restore_status": {"key": "properties.blobRestoreStatus", "type": "BlobRestoreStatus"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -6553,9 +6264,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_08_01.models.Identity @@ -6575,7 +6286,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6586,7 +6297,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6603,7 +6314,7 @@ def __init__( :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess :keyword immutable_storage_with_versioning: The property is immutable and can only be set to @@ -6612,10 +6323,10 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_08_01.models.ImmutableStorageAccount :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -6658,77 +6369,72 @@ def __init__( self.allowed_copy_scope = allowed_copy_scope -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_08_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str :ivar extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :vartype extended_location: ~azure.mgmt.storage.v2021_08_01.models.ExtendedLocation - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_08_01.models.Identity :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess @@ -6746,7 +6452,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_08_01.models.NetworkRuleSet :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6762,7 +6468,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6773,7 +6479,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6796,43 +6502,49 @@ class StorageAccountCreateParameters(msrest.serialization.Model): """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, - 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, - } - - def __init__( + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + } + + def __init__( # pylint: disable=too-many-locals self, *, sku: "_models.Sku", @@ -6866,33 +6578,33 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2021_08_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str :keyword extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :paramtype extended_location: ~azure.mgmt.storage.v2021_08_01.models.ExtendedLocation - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_08_01.models.Identity :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess :keyword sas_policy: SasPolicy assigned to the storage account. @@ -6909,7 +6621,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_08_01.models.NetworkRuleSet :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6925,7 +6637,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6936,7 +6648,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6957,7 +6669,7 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_08_01.models.ImmutableStorageAccount """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -6988,7 +6700,7 @@ def __init__( self.immutable_storage_with_versioning = immutable_storage_with_versioning -class StorageAccountInternetEndpoints(msrest.serialization.Model): +class StorageAccountInternetEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -7004,33 +6716,29 @@ class StorageAccountInternetEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountInternetEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.file = None self.web = None self.dfs = None -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -7040,40 +6748,36 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_08_01.models.KeyPermission :ivar creation_time: Creation time of the key, in round trip date format. :vartype creation_time: ~datetime.datetime """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, - 'creation_time': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, + "creation_time": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None self.creation_time = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -7084,24 +6788,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -7114,27 +6814,23 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): +class StorageAccountMicrosoftEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -7154,30 +6850,26 @@ class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountMicrosoftEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -7186,55 +6878,50 @@ def __init__( self.dfs = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2, kerb1, kerb2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2, kerb1, kerb2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2021_08_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_08_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7248,7 +6935,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar key_policy: KeyPolicy assigned to the storage account. :vartype key_policy: ~azure.mgmt.storage.v2021_08_01.models.KeyPolicy :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier used - for billing. Known values are: "Hot", "Cool". + for billing. Known values are: "Hot" and "Cool". :vartype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7263,7 +6950,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_08_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -7274,7 +6961,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7288,7 +6975,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess @@ -7298,38 +6985,44 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_08_01.models.ImmutableStorageAccount :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, - 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, - 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, - } - - def __init__( + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, sku: Optional["_models.Sku"] = None, @@ -7363,16 +7056,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2021_08_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_08_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_08_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7386,7 +7079,7 @@ def __init__( :keyword key_policy: KeyPolicy assigned to the storage account. :paramtype key_policy: ~azure.mgmt.storage.v2021_08_01.models.KeyPolicy :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier - used for billing. Known values are: "Hot", "Cool". + used for billing. Known values are: "Hot" and "Cool". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_08_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7402,7 +7095,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_08_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_08_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -7413,7 +7106,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_08_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7428,7 +7121,7 @@ def __init__( :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_08_01.models.PublicNetworkAccess :keyword immutable_storage_with_versioning: The property is immutable and can only be set to @@ -7437,10 +7130,10 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_08_01.models.ImmutableStorageAccount :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_08_01.models.AllowedCopyScope """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -7489,36 +7182,31 @@ class StorageQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'approximate_message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "approximate_message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'approximate_message_count': {'key': 'properties.approximateMessageCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "approximate_message_count": {"key": "properties.approximateMessageCount", "type": "int"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(StorageQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata self.approximate_message_count = None -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -7528,49 +7216,45 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuInformation]'}, + "value": {"key": "value", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_08_01.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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_08_01.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'}, + "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__( @@ -7588,19 +7272,19 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_08_01.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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_08_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -7627,26 +7311,22 @@ class Table(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'table_name': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "table_name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Table, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.table_name = None @@ -7670,86 +7350,74 @@ class TableServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Table service. :paramtype cors: ~azure.mgmt.storage.v2021_08_01.models.CorsRules """ - super(TableServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class TagFilter(msrest.serialization.Model): +class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. All required parameters must be populated in order to send to Azure. - :ivar name: Required. This is the filter tag name, it can have 1 - 128 characters. + :ivar name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str - :ivar op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :ivar op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :vartype op: str - :ivar value: Required. This is the filter tag value field used for tag based filtering, it can - have 0 - 256 characters. + :ivar value: This is the filter tag value field used for tag based filtering, it can have 0 - + 256 characters. Required. :vartype value: str """ _validation = { - 'name': {'required': True, 'max_length': 128, 'min_length': 1}, - 'op': {'required': True}, - 'value': {'required': True, 'max_length': 256, 'min_length': 0}, + "name": {"required": True, "max_length": 128, "min_length": 1}, + "op": {"required": True}, + "value": {"required": True, "max_length": 256}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'op': {'key': 'op', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "op": {"key": "op", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - op: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, op: str, value: str, **kwargs): """ - :keyword name: Required. This is the filter tag name, it can have 1 - 128 characters. + :keyword name: This is the filter tag name, it can have 1 - 128 characters. Required. :paramtype name: str - :keyword op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :keyword op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :paramtype op: str - :keyword value: Required. This is the filter tag value field used for tag based filtering, it - can have 0 - 256 characters. + :keyword value: This is the filter tag value field used for tag based filtering, it can have 0 + - 256 characters. Required. :paramtype value: str """ - super(TagFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.op = op self.value = value -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -7767,28 +7435,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -7796,13 +7460,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -7832,23 +7496,23 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -7873,7 +7537,7 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -7884,13 +7548,13 @@ def __init__( self.allow_protected_append_writes_all = allow_protected_append_writes_all -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_08_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -7901,33 +7565,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -7935,24 +7595,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2021_08_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -7964,27 +7619,23 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """UserAssignedIdentity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -7996,72 +7647,68 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", - "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_08_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", - "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_08_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py index 94d2e110787f..b9aba0f36c70 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/models/_storage_management_client_enums.py @@ -11,12 +11,12 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Required for storage accounts where kind = BlobStorage. The access tier used for billing. - """ + """Required for storage accounts where kind = BlobStorage. The access tier used for billing.""" HOT = "Hot" COOL = "Cool" + class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the policy, Unlocked state allows increase and decrease of immutability retention time and also @@ -30,6 +30,7 @@ class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMet LOCKED = "Locked" DISABLED = "Disabled" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -38,13 +39,14 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class ActiveDirectoryPropertiesAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the Active Directory account type for Azure Storage. - """ + """Specifies the Active Directory account type for Azure Storage.""" USER = "User" COMPUTER = "Computer" + class AllowedCopyScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet. @@ -53,10 +55,13 @@ class AllowedCopyScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): PRIVATE_LINK = "PrivateLink" AAD = "AAD" + class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobInventoryPolicyName.""" DEFAULT = "default" + class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - @@ -67,6 +72,7 @@ class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): COMPLETE = "Complete" FAILED = "Failed" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -78,7 +84,9 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CorsRuleAllowedMethodsItem.""" DELETE = "DELETE" GET = "GET" @@ -88,39 +96,40 @@ class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): OPTIONS = "OPTIONS" PUT = "PUT" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default share permission for users using Kerberos authentication if RBAC role is not assigned. - """ + """Default share permission for users using Kerberos authentication if RBAC role is not assigned.""" NONE = "None" STORAGE_FILE_DATA_SMB_SHARE_READER = "StorageFileDataSmbShareReader" STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = "StorageFileDataSmbShareContributor" STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" + class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the directory service used. - """ + """Indicates the directory service used.""" NONE = "None" AADDS = "AADDS" AD = "AD" + class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. @@ -129,6 +138,7 @@ class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): SMB = "SMB" NFS = "NFS" + class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. @@ -137,32 +147,33 @@ class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. - """ + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SAS expiration action. Can only be Log. - """ + """The SAS expiration action. Can only be Log.""" LOG = "Log" + class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation. - """ + """The type of extendedLocation.""" EDGE_ZONE = "EdgeZone" + class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is a required field, it specifies the format for the inventory files. - """ + """This is a required field, it specifies the format for the inventory files.""" CSV = "Csv" PARQUET = "Parquet" + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -175,29 +186,30 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type. - """ + """The identity type.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -207,27 +219,29 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Inventory - """ + """The valid value is Inventory.""" INVENTORY = "Inventory" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service @@ -237,9 +251,9 @@ class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SERVICE = "Service" ACCOUNT = "Account" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -247,22 +261,23 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - """ + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -272,19 +287,19 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -292,21 +307,26 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListContainersInclude.""" DELETED = "deleted" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property denotes the container level immutability to object level immutability migration state. @@ -315,6 +335,7 @@ class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): IN_PROGRESS = "InProgress" COMPLETED = "Completed" + class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. @@ -324,12 +345,13 @@ class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" + class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only - """ + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only.""" ACCESS_TIME_TRACKING = "AccessTimeTracking" + class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field specifies the scope of the inventory created either at the blob or container level. @@ -338,6 +360,7 @@ class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): BLOB = "Blob" CONTAINER = "Container" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -352,39 +375,40 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state. - """ + """The current provisioning state.""" SUCCEEDED = "Succeeded" CREATING = "Creating" DELETING = "Deleting" FAILED = "Failed" + class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status. - """ + """The private endpoint connection status.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. @@ -393,6 +417,7 @@ class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): ENABLED = "Enabled" DISABLED = "Disabled" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -401,6 +426,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -411,34 +437,35 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The property is for NFS share only. The default is NoRootSquash. - """ + """The property is for NFS share only. The default is NoRootSquash.""" NO_ROOT_SQUASH = "NoRootSquash" ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" + class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Routing Choice defines the kind of network routing opted by the user. - """ + """Routing Choice defines the kind of network routing opted by the user.""" MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" + class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Lifecycle - """ + """The valid value is Lifecycle.""" LIFECYCLE = "Lifecycle" + class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is a required field. This field is used to schedule an inventory formation. - """ + """This is a required field. This field is used to schedule an inventory formation.""" DAILY = "Daily" WEEKLY = "Weekly" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -449,6 +476,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. @@ -459,6 +487,7 @@ class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): COOL = "Cool" PREMIUM = "Premium" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -469,6 +498,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -479,6 +509,7 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -493,16 +524,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SKU tier. This is based on the SKU name. - """ + """The SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "Provisioning" DEPROVISIONING = "Deprovisioning" @@ -510,14 +541,16 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "Failed" NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" + class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountExpand.""" GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/__init__.py index 22f9808d440a..b58975e023a9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/__init__.py @@ -30,27 +30,28 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'LocalUsersOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "LocalUsersOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_operations.py index 71d3e64fdd7a..70887fa1afa4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_containers_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,13 +29,20 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -36,303 +50,253 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( @@ -341,50 +305,45 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( @@ -399,37 +358,36 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( @@ -444,36 +402,35 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -488,34 +445,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -525,132 +481,113 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_object_level_worm_request_initial( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any +def build_object_level_worm_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobContainersOperations: """ @@ -671,7 +608,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -679,18 +615,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> Iterable[_models.ListContainerItems]: + ) -> Iterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -699,35 +635,39 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_08_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -735,18 +675,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -763,10 +702,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -776,19 +713,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -796,37 +733,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -836,7 +860,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -844,10 +869,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -855,63 +879,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -921,7 +1031,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -929,72 +1040,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1002,72 +1109,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1075,10 +1178,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1088,16 +1190,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1105,37 +1208,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1145,7 +1335,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1153,80 +1344,166 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') - - request = build_clear_legal_hold_request( - resource_group_name=resource_group_name, - account_name=account_name, - container_name=container_name, - subscription_id=self._config.subscription_id, + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_08_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + request = build_clear_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1234,27 +1511,25 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, @@ -1262,22 +1537,24 @@ def create_or_update_immutability_policy( container_name: str, if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -1286,44 +1563,149 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy or IO + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: 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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1331,10 +1713,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1342,17 +1723,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1367,16 +1747,16 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -1387,32 +1767,34 @@ def get_immutability_policy( "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1420,10 +1802,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1431,26 +1812,20 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this @@ -1458,52 +1833,54 @@ def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1511,10 +1888,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1522,71 +1898,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1594,10 +1966,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1605,19 +1976,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1625,6 +1995,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1632,56 +2004,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1689,10 +2160,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1700,65 +2170,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1768,7 +2324,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1776,52 +2333,48 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_object_level_worm_request_initial( + request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata['url'], + template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1829,10 +2382,9 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1842,16 +2394,11 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore - + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace - def begin_object_level_worm( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> LROPoller[None]: """This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites require a container level immutability policy either in locked @@ -1859,16 +2406,16 @@ def begin_object_level_worm( # pylint: disable=inconsistent-return-statements on the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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. @@ -1880,53 +2427,48 @@ def begin_object_level_worm( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_operations.py index b0ad8051848a..bdab50e285ef 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_inventory_policies_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,167 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - *, - json: Optional[_models.BlobInventoryPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobInventoryPoliciesOperations: """ @@ -207,52 +208,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -260,10 +262,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -271,68 +272,151 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy 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 - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -340,10 +424,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -351,61 +434,62 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -413,10 +497,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -427,51 +510,50 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -479,15 +561,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -504,10 +588,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -518,8 +600,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_operations.py index 4032a1608127..8f1dec5af3b0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_blob_services_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,134 +27,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -168,47 +164,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -216,15 +214,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -241,10 +241,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -254,56 +252,139 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties or IO + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: 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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -313,7 +394,8 @@ def set_service_properties( blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -321,72 +403,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -394,22 +473,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_operations.py index c6df72c74666..d8c4d8618450 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_deleted_accounts_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,81 +27,74 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_get_request( - deleted_account_name: str, - location: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(deleted_account_name: str, location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), - "location": _SERIALIZER.url("location", location, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "deletedAccountName": _SERIALIZER.url( + "deleted_account_name", deleted_account_name, "str", max_length=24, min_length=3 + ), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DeletedAccountsOperations: """ @@ -115,38 +115,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DeletedAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -154,13 +152,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -177,10 +179,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -191,48 +191,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace - def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,10 +235,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,12 +245,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_operations.py index 453b044c1b97..fbdebfd1094a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_encryption_scopes_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,181 +27,164 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_put_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EncryptionScopesOperations: """ @@ -215,14 +205,15 @@ def __init__(self, *args, **kwargs): 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 + @overload def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -230,47 +221,137 @@ def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -278,10 +359,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -290,73 +370,160 @@ def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace + @overload def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -364,10 +531,9 @@ def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,62 +541,59 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -438,10 +601,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,58 +611,54 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.EncryptionScopeListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -508,15 +666,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -533,10 +693,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -546,8 +704,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_operations.py index 6e195d2f2d1b..c88d2fc29d10 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.FileServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class FileServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,70 +205,152 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties or IO + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: 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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -287,7 +360,8 @@ def set_service_properties( file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +369,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +439,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_operations.py index 6f618628abd3..32823e7c784e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_file_shares_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -40,38 +54,37 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( @@ -80,95 +93,80 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: Optional[_models.FileShare] = None, - content: Any = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -184,37 +182,36 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -230,84 +227,73 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_restore_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.DeletedShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( @@ -316,48 +302,44 @@ def build_lease_request( share_name: str, subscription_id: str, *, - json: Optional[_models.LeaseShareRequest] = None, - content: Any = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class FileSharesOperations: """ @@ -378,7 +360,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -388,15 +369,15 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.FileShareItems]: + ) -> Iterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -409,32 +390,36 @@ def list( None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -442,18 +427,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -470,10 +454,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -483,13 +465,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, @@ -497,6 +477,8 @@ def create( share_name: str, file_share: _models.FileShare, expand: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -504,51 +486,147 @@ def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -556,10 +634,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -567,63 +644,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_08_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -633,7 +796,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -641,25 +805,23 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def get( @@ -674,16 +836,16 @@ def get( """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. Default value is None. @@ -692,31 +854,33 @@ def get( None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -724,25 +888,23 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -757,16 +919,16 @@ def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str @@ -775,34 +937,37 @@ def delete( # pylint: disable=inconsistent-return-statements snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the - file share contains any snapshots (leased or unleased), the deletion fails. + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. :type include: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -810,10 +975,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -823,52 +987,135 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace + @overload def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_08_01.models.DeletedShare + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_08_01.models.DeletedShare 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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -878,7 +1125,8 @@ def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -886,10 +1134,9 @@ def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -899,10 +1146,9 @@ def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - @distributed_trace + @overload def lease( self, resource_group_name: str, @@ -910,60 +1156,156 @@ def lease( share_name: str, x_ms_snapshot: Optional[str] = None, parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse, or the result of cls(response) + :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseShareResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseShareRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, api_version=api_version, content_type=content_type, json=_json, - x_ms_snapshot=x_ms_snapshot, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -971,10 +1313,9 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -982,14 +1323,13 @@ def lease( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_operations.py index 744d05c08c79..726d09645e9d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_local_users_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,251 +27,223 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - *, - json: Optional[_models.LocalUser] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_password_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class LocalUsersOperations: """ @@ -285,47 +264,45 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.LocalUsers]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.LocalUser"]: """List the local users associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 LocalUsers or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.LocalUsers] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LocalUser or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.LocalUser] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUsers] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -333,15 +310,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -358,10 +337,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -372,56 +349,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any - ) -> _models.LocalUser: + def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -429,10 +400,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -440,67 +410,148 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, username: str, properties: _models.LocalUser, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str - :param properties: The local user associated with a storage account. + :param properties: The local user associated with a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_08_01.models.LocalUser + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: IO + :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: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: Union[_models.LocalUser, IO], + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Is either a model type or + a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.LocalUser 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 + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - _json = self._serialize.body(properties, 'LocalUser') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalUser") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -508,10 +559,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -519,60 +569,57 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> None: """Deletes the local user associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -580,10 +627,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -594,53 +640,50 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserKeys: """List SSH authorized keys and shared key of the local user. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserKeys, or the result of cls(response) + :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -648,10 +691,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -659,60 +701,57 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserKeys', pipeline_response) + deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore @distributed_trace def regenerate_password( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserRegeneratePasswordResult: """Regenerate the local user SSH password. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserRegeneratePasswordResult, or the result of cls(response) + :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.LocalUserRegeneratePasswordResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] - request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata['url'], + template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) @@ -720,10 +759,9 @@ def regenerate_password( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -731,12 +769,11 @@ def regenerate_password( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserRegeneratePasswordResult', pipeline_response) + deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore - + regenerate_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_operations.py index 0096f03f797b..265ab2ac8356 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,130 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,52 +169,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -215,78 +223,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy 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 - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -294,71 +384,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_08_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -366,10 +456,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +468,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_operations.py index 17b3b08a15e8..ccb5588bd271 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_object_replication_policies_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,161 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - *, - json: Optional[_models.ObjectReplicationPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ObjectReplicationPoliciesOperations: """ @@ -207,49 +202,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +252,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +279,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -296,58 +291,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -355,10 +346,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -366,70 +356,156 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy 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 - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -437,10 +513,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -448,62 +523,59 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -511,10 +583,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -525,5 +596,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_operations.py index af6fa1a3c2f6..4626155ecd6c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_endpoint_connections_operations.py index cade3bce413b..a47392e29d58 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,173 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -207,49 +214,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +264,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +291,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,56 +302,52 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -352,10 +355,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,67 +365,148 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace + @overload def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection 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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -431,10 +514,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,60 +524,57 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -503,10 +582,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -517,5 +595,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_link_resources_operations.py index 4e83d0388012..6501c617e4d0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,52 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_storage_account_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,46 +91,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -128,22 +136,20 @@ def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_operations.py index 1ff65174e7e7..f6d70530e67a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,183 +27,188 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( @@ -211,36 +223,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueOperations: """ @@ -261,60 +273,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -322,79 +419,163 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -402,72 +583,66 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.StorageQueue: + def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -475,72 +650,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -548,10 +719,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -561,8 +731,7 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -572,15 +741,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.ListQueueResource]: + ) -> Iterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -589,31 +758,35 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -621,17 +794,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -648,10 +821,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -661,8 +832,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_operations.py index 45a03f592ca0..9d8515969648 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_queue_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.QueueServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,70 +205,153 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties or IO + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: 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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -287,7 +361,8 @@ def set_service_properties( queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +370,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +440,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_operations.py index 2a602e45c938..cb919fd5800c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_operations.py index 30246447746b..048423d23554 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +29,110 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,153 +140,129 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -304,357 +270,305 @@ def build_list_keys_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "kerb", + expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_hierarchical_namespace_migration_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - request_type: str, - **kwargs: Any +def build_hierarchical_namespace_migration_request( + resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['requestType'] = _SERIALIZER.query("request_type", request_type, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["requestType"] = _SERIALIZER.query("request_type", request_type, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_abort_hierarchical_namespace_migration_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_abort_hierarchical_namespace_migration_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_blob_ranges_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobRestoreParameters] = None, - content: Any = None, - **kwargs: Any + +def build_restore_blob_ranges_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revoke_user_delegation_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: # pylint: disable=too-many-public-methods """ @@ -675,45 +589,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2021_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -721,55 +688,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -777,10 +752,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -789,22 +763,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -813,14 +788,17 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCreateParameters + :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 @@ -832,20 +810,98 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -853,79 +909,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -933,10 +984,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -946,15 +996,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -962,40 +1011,43 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_08_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -1003,32 +1055,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1041,32 +1093,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountUpdateParameters + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1075,7 +1212,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1083,58 +1221,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1142,13 +1277,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1165,10 +1304,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1178,49 +1315,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1228,14 +1361,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1252,10 +1388,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1265,57 +1399,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1323,65 +1453,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_08_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1390,7 +1593,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1398,63 +1602,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.AccountSasParameters 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 - :return: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1463,7 +1740,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1471,63 +1749,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.ServiceSasParameters 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 - :return: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1536,7 +1885,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1544,50 +1894,47 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1595,10 +1942,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1608,26 +1954,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1639,82 +1979,75 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_hierarchical_namespace_migration_request_initial( + request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, request_type=request_type, - template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + api_version=api_version, + template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1722,43 +2055,38 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - + _hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace - def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> LROPoller[None]: """Live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param request_type: Required. Hierarchical namespace migration type can either be a hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the - hydration request will migrate the account. + hydration request will migrate the account. Required. :type request_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. @@ -1770,81 +2098,75 @@ def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-retu 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + begin_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_abort_hierarchical_namespace_migration_request_initial( + request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1852,37 +2174,33 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore - + _abort_hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + def begin_abort_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Abort live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1894,85 +2212,90 @@ def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsisten 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1980,10 +2303,9 @@ def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1991,38 +2313,117 @@ def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace + @overload def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.BlobRestoreParameters 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 @@ -2034,20 +2435,17 @@ def begin_restore_blob_ranges( :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_08_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -2055,79 +2453,76 @@ def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -2135,10 +2530,9 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2148,5 +2542,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_operations.py index 9316a8e185c4..a8981f443887 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,204 +27,194 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableOperations: """ @@ -238,52 +235,47 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def create( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def create(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.create.metadata['url'], + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -291,71 +283,65 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def update( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def update(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.update.metadata['url'], + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -363,71 +349,65 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -435,71 +415,67 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -507,10 +483,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -520,49 +495,47 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -570,15 +543,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -595,10 +570,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -608,8 +581,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_operations.py index f5211d91ee90..f2d309f57bb2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_table_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.TableServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,70 +205,153 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties or IO + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: 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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -287,7 +361,8 @@ def set_service_properties( table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +370,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_08_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +440,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_operations.py index 0a2a251f1d29..30f794a5355d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_08_01/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,41 +87,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_08_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-08-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-08-01")) # type: Literal["2021-08-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -122,14 +128,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -146,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -159,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_configuration.py index 69823f1504a1..8524e8a36259 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-09-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + api_version = kwargs.pop("api_version", "2021-09-01") # type: Literal["2021-09-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json index 063502cd1df3..5f79453016cd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -118,4 +118,4 @@ "table_services": "TableServicesOperations", "table": "TableOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py index 24ba6339460f..4b1761f32417 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_storage_management_client.py @@ -9,20 +9,41 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, LocalUsersOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + LocalUsersOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -71,9 +92,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_09_01.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_09_01.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -91,28 +112,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -128,43 +145,20 @@ def __init__( self.object_replication_policies = ObjectReplicationPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.local_users = LocalUsersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -173,7 +167,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_configuration.py index 20ead82eb2f8..f3d880cd32f6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2021-09-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2021-09-01") # type: str + api_version = kwargs.pop("api_version", "2021-09-01") # type: Literal["2021-09-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_patch.py index 74e48ecd07cf..f99e77fef986 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_patch.py @@ -28,4 +28,4 @@ # 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(): - pass \ No newline at end of file + pass diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py index adfc0b7bacb1..cad9f9179e64 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/_storage_management_client.py @@ -9,20 +9,41 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, LocalUsersOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + LocalUsersOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -74,9 +95,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2021_09_01.aio.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2021_09_01.aio.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -94,28 +115,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -131,43 +148,20 @@ def __init__( self.object_replication_policies = ObjectReplicationPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.local_users = LocalUsersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -176,7 +170,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/__init__.py index 22f9808d440a..b58975e023a9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/__init__.py @@ -30,27 +30,28 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'LocalUsersOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "LocalUsersOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_operations.py index b70331e0b40d..d4a2d103972f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_containers_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,31 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_object_level_worm_request_initial, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_object_level_worm_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -45,7 +75,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,18 +82,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListContainerItems]: + ) -> AsyncIterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -73,36 +102,40 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_09_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -110,18 +143,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -138,10 +170,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,19 +181,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -171,37 +201,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -211,7 +328,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -219,10 +337,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -230,63 +347,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -296,7 +499,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -304,72 +508,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -377,72 +577,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -450,10 +646,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -463,16 +658,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -480,37 +676,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -520,7 +803,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -528,70 +812,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -601,7 +970,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -609,27 +979,25 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, @@ -637,22 +1005,24 @@ async def create_or_update_immutability_policy( container_name: str, if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -661,44 +1031,149 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy or IO :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: 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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -706,10 +1181,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -717,17 +1191,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -742,16 +1215,16 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -762,32 +1235,34 @@ async def get_immutability_policy( "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -795,10 +1270,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -806,26 +1280,20 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this @@ -833,52 +1301,54 @@ async def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -886,10 +1356,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -897,71 +1366,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -969,10 +1434,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -980,19 +1444,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -1000,6 +1463,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1007,56 +1472,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1064,10 +1628,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1075,65 +1638,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1143,7 +1792,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1151,52 +1801,48 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_object_level_worm_request_initial( + request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata['url'], + template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1204,10 +1850,9 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1217,16 +1862,11 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore - + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace_async - async def begin_object_level_worm( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + async def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites require a container level immutability policy either in locked @@ -1234,16 +1874,16 @@ async def begin_object_level_worm( # pylint: disable=inconsistent-return-statem on the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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. @@ -1255,53 +1895,48 @@ async def begin_object_level_worm( # pylint: disable=inconsistent-return-statem 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_operations.py index c7bec22d883e..8f06cc06651b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_inventory_policies_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_inventory_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._blob_inventory_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobInventoryPoliciesOperations: """ .. warning:: @@ -43,52 +63,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -96,78 +117,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy 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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -175,71 +278,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -247,10 +350,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -260,51 +362,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -312,15 +413,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -337,10 +440,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -351,8 +452,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_operations.py index f8ff422a9431..846b0fae33ff 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_blob_services_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -43,48 +62,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,56 +150,139 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties or IO + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: 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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -189,7 +292,8 @@ async def set_service_properties( blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -197,72 +301,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -270,22 +371,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_operations.py index ff5dfd1bdb8e..8fb187d91671 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_deleted_accounts_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DeletedAccountsOperations: """ .. warning:: @@ -43,38 +58,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) + :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -82,13 +96,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -105,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -119,48 +135,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async - async def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -168,10 +179,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,12 +189,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_operations.py index 52ff5528677c..96eb21b34a95 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_encryption_scopes_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._encryption_scopes_operations import build_get_request, build_list_request, build_patch_request, build_put_request -T = TypeVar('T') +from ...operations._encryption_scopes_operations import ( + build_get_request, + build_list_request, + build_patch_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EncryptionScopesOperations: """ .. warning:: @@ -43,14 +63,15 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -58,47 +79,137 @@ async def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -106,10 +217,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -118,73 +228,160 @@ async def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace_async + @overload async def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +389,9 @@ async def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,62 +399,59 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -266,10 +459,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -277,58 +469,57 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EncryptionScopeListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) + :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -336,15 +527,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -361,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -374,8 +565,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_operations.py index 762f31d452af..166e438fc292 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,70 +102,152 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties or IO + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: 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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -161,7 +257,8 @@ async def set_service_properties( file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +266,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +336,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_operations.py index 5b5c474ee5c7..04b15991c1cb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_file_shares_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,24 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_shares_operations import build_create_request, build_delete_request, build_get_request, build_lease_request, build_list_request, build_restore_request, build_update_request -T = TypeVar('T') +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_lease_request, + build_list_request, + build_restore_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileSharesOperations: """ .. warning:: @@ -43,7 +66,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,15 +75,15 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.FileShareItems]: + ) -> AsyncIterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -74,33 +96,37 @@ def list( None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) + :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -108,18 +134,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -136,10 +161,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,13 +172,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, @@ -163,6 +184,8 @@ async def create( share_name: str, file_share: _models.FileShare, expand: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -170,51 +193,147 @@ async def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -222,10 +341,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -233,63 +351,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -299,7 +503,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -307,25 +512,23 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def get( @@ -340,16 +543,16 @@ async def get( """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. Default value is None. @@ -358,31 +561,33 @@ async def get( None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -390,25 +595,23 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -423,16 +626,16 @@ async def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str @@ -441,34 +644,37 @@ async def delete( # pylint: disable=inconsistent-return-statements snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the - file share contains any snapshots (leased or unleased), the deletion fails. + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. :type include: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -476,10 +682,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -489,52 +694,135 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace_async + @overload async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_09_01.models.DeletedShare + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_09_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -544,7 +832,8 @@ async def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -552,10 +841,9 @@ async def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,10 +853,9 @@ async def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, @@ -576,60 +863,156 @@ async def lease( share_name: str, x_ms_snapshot: Optional[str] = None, parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse, or the result of cls(response) + :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseShareResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseShareRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, api_version=api_version, content_type=content_type, json=_json, - x_ms_snapshot=x_ms_snapshot, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -637,10 +1020,9 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -648,14 +1030,13 @@ async def lease( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_operations.py index a31b89af5d59..cf7c2b583c88 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_local_users_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._local_users_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_keys_request, build_list_request, build_regenerate_password_request -T = TypeVar('T') +from ...operations._local_users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_keys_request, + build_list_request, + build_regenerate_password_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class LocalUsersOperations: """ .. warning:: @@ -43,48 +65,46 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.LocalUsers]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.LocalUser"]: """List the local users associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 LocalUsers or the result of cls(response) + :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.LocalUsers] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.LocalUser] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUsers] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +151,50 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any - ) -> _models.LocalUser: + async def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +202,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +212,148 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, username: str, properties: _models.LocalUser, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str - :param properties: The local user associated with a storage account. + :param properties: The local user associated with a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_09_01.models.LocalUser + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: IO + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: Union[_models.LocalUser, IO], + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Is either a model type or + a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.LocalUser 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 - :return: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - _json = self._serialize.body(properties, 'LocalUser') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalUser") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +361,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +371,57 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> None: """Deletes the local user associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +429,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,53 +442,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserKeys: """List SSH authorized keys and shared key of the local user. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserKeys, or the result of cls(response) + :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -407,10 +493,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,60 +503,57 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserKeys', pipeline_response) + deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore @distributed_trace_async async def regenerate_password( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserRegeneratePasswordResult: """Regenerate the local user SSH password. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserRegeneratePasswordResult, or the result of cls(response) + :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserRegeneratePasswordResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] - request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata['url'], + template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) @@ -479,10 +561,9 @@ async def regenerate_password( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -490,12 +571,11 @@ async def regenerate_password( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserRegeneratePasswordResult', pipeline_response) + deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore - + regenerate_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_operations.py index 08eeb6fe367c..b43db3885637 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,52 +59,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -94,78 +113,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy + :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: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -173,71 +274,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -245,10 +346,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -258,5 +358,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_operations.py index 42c4e4d83662..f3b4bfff330a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_object_replication_policies_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._object_replication_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._object_replication_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ObjectReplicationPoliciesOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,58 +152,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -191,10 +207,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,70 +217,156 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy 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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -273,10 +374,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -284,62 +384,59 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -347,10 +444,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -361,5 +457,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_operations.py index fba333183c00..22a97fa9b2c9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py index 246294577182..750d215b2de7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request, build_get_request, build_list_request, build_put_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +151,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +204,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +214,148 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection 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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +363,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +373,57 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +431,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,5 +444,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_link_resources_operations.py index 41afa2e996d4..8fd38a75bbd7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,46 +55,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -88,22 +100,20 @@ async def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_operations.py index 632a2e264d15..6db3fdc53b6e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._queue_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueOperations: """ .. warning:: @@ -43,60 +64,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue 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 - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -104,79 +210,163 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -184,72 +374,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -257,72 +443,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -330,10 +512,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -343,8 +524,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -354,15 +534,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListQueueResource]: + ) -> AsyncIterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -371,32 +551,36 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) + :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -404,17 +588,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -431,10 +615,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -444,8 +626,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_operations.py index 6067116acf15..ec92b0e9e34f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_queue_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._queue_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,70 +102,153 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties or IO + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: 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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -161,7 +258,8 @@ async def set_service_properties( queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +267,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +337,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_operations.py index edec00dbecd8..dce25c672f3e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) + :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +95,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +133,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_operations.py index bec093e53520..885b883be2bf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,33 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_abort_hierarchical_namespace_migration_request_initial, build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_hierarchical_namespace_migration_request_initial, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_restore_blob_ranges_request_initial, build_revoke_user_delegation_keys_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_abort_hierarchical_namespace_migration_request, + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_hierarchical_namespace_migration_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_restore_blob_ranges_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: # pylint: disable=too-many-public-methods """ .. warning:: @@ -45,45 +77,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2021_09_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +176,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +240,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +251,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +276,17 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCreateParameters + :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 @@ -203,20 +299,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCreateParameters 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. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +400,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +475,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,15 +487,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -333,40 +502,43 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_09_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,32 +546,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -412,32 +584,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -446,7 +703,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -454,58 +712,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -513,13 +769,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -536,10 +796,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,49 +807,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -599,14 +856,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -623,10 +883,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -636,57 +894,53 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -694,65 +948,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_09_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -761,7 +1088,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -769,63 +1097,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -834,7 +1235,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -842,63 +1244,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ServiceSasParameters + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -907,7 +1380,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -915,50 +1389,47 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -966,10 +1437,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -979,26 +1449,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1010,82 +1474,75 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_hierarchical_namespace_migration_request_initial( + request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, request_type=request_type, - template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + api_version=api_version, + template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1093,43 +1550,38 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - + _hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace_async - async def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + async def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param request_type: Required. Hierarchical namespace migration type can either be a hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the - hydration request will migrate the account. + hydration request will migrate the account. Required. :type request_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. @@ -1141,81 +1593,75 @@ async def begin_hierarchical_namespace_migration( # pylint: disable=inconsisten 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + begin_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_abort_hierarchical_namespace_migration_request_initial( + request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1223,37 +1669,33 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore - + _abort_hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + async def begin_abort_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Abort live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1265,85 +1707,90 @@ async def begin_abort_hierarchical_namespace_migration( # pylint: disable=incon 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1351,10 +1798,9 @@ async def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1362,38 +1808,81 @@ async def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace_async + @overload async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1406,20 +1895,55 @@ async def begin_restore_blob_ranges( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobRestoreParameters 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. + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1427,79 +1951,76 @@ async def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1507,10 +2028,9 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1520,5 +2040,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_operations.py index 6ecab78e6781..241d8e712702 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._table_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableOperations: """ .. warning:: @@ -43,62 +64,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, table_name: str, parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table 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 - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - if parameters is not None: - _json = self._serialize.body(parameters, 'Table') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -106,81 +210,163 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, table_name: str, parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table 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 - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - if parameters is not None: - _json = self._serialize.body(parameters, 'Table') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -188,71 +374,65 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -260,71 +440,67 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -332,10 +508,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -345,50 +520,47 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -396,15 +568,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -421,10 +595,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -434,8 +606,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_operations.py index 96add7ed72c6..3ac4abab4a33 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_table_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._table_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,70 +102,153 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties or IO + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: 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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -161,7 +258,8 @@ async def set_service_properties( table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +267,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +337,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_operations.py index fc903859e18b..bfccf52e2fd3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,42 +57,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2021_09_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -85,14 +98,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -109,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -122,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/__init__.py index 8d3930cd6c2b..3dbf8d607f68 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/__init__.py @@ -155,289 +155,287 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountImmutabilityPolicyState, - AccountStatus, - ActiveDirectoryPropertiesAccountType, - AllowedCopyScope, - BlobInventoryPolicyName, - BlobRestoreProgressStatus, - Bypass, - CorsRuleAllowedMethodsItem, - CreatedByType, - DefaultAction, - DefaultSharePermission, - DirectoryServiceOptions, - DnsEndpointType, - EnabledProtocols, - EncryptionScopeSource, - EncryptionScopeState, - ExpirationAction, - ExtendedLocationTypes, - Format, - GeoReplicationStatus, - HttpProtocol, - IdentityType, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - InventoryRuleType, - KeyPermission, - KeySource, - KeyType, - Kind, - LargeFileSharesState, - LeaseContainerRequestAction, - LeaseDuration, - LeaseShareAction, - LeaseState, - LeaseStatus, - ListContainersInclude, - ManagementPolicyName, - MigrationState, - MinimumTlsVersion, - Name, - ObjectType, - Permissions, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisioningState, - PublicAccess, - PublicNetworkAccess, - Reason, - ReasonCode, - RootSquashType, - RoutingChoice, - RuleType, - Schedule, - Services, - ShareAccessTier, - SignedResource, - SignedResourceTypes, - SkuConversionStatus, - SkuName, - SkuTier, - State, - StorageAccountExpand, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountImmutabilityPolicyState +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import ActiveDirectoryPropertiesAccountType +from ._storage_management_client_enums import AllowedCopyScope +from ._storage_management_client_enums import BlobInventoryPolicyName +from ._storage_management_client_enums import BlobRestoreProgressStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CorsRuleAllowedMethodsItem +from ._storage_management_client_enums import CreatedByType +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DefaultSharePermission +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import DnsEndpointType +from ._storage_management_client_enums import EnabledProtocols +from ._storage_management_client_enums import EncryptionScopeSource +from ._storage_management_client_enums import EncryptionScopeState +from ._storage_management_client_enums import ExpirationAction +from ._storage_management_client_enums import ExtendedLocationTypes +from ._storage_management_client_enums import Format +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import IdentityType +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import InventoryRuleType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import KeyType +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestAction +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseShareAction +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ListContainersInclude +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MigrationState +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Name +from ._storage_management_client_enums import ObjectType +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._storage_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import PublicNetworkAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RootSquashType +from ._storage_management_client_enums import RoutingChoice +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Schedule +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import ShareAccessTier +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuConversionStatus +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import StorageAccountExpand +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessPolicy', - 'AccountImmutabilityPolicyProperties', - 'AccountSasParameters', - 'ActiveDirectoryProperties', - 'AzureEntityResource', - 'AzureFilesIdentityBasedAuthentication', - 'BlobContainer', - 'BlobInventoryPolicy', - 'BlobInventoryPolicyDefinition', - 'BlobInventoryPolicyFilter', - 'BlobInventoryPolicyRule', - 'BlobInventoryPolicySchema', - 'BlobRestoreParameters', - 'BlobRestoreRange', - 'BlobRestoreStatus', - 'BlobServiceItems', - 'BlobServiceProperties', - 'ChangeFeed', - 'CheckNameAvailabilityResult', - 'CloudErrorBody', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DateAfterCreation', - 'DateAfterModification', - 'DeleteRetentionPolicy', - 'DeletedAccount', - 'DeletedAccountListResult', - 'DeletedShare', - 'Dimension', - 'Encryption', - 'EncryptionIdentity', - 'EncryptionScope', - 'EncryptionScopeKeyVaultProperties', - 'EncryptionScopeListResult', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'ErrorResponse', - 'ErrorResponseBody', - 'ExtendedLocation', - 'FileServiceItems', - 'FileServiceProperties', - 'FileShare', - 'FileShareItem', - 'FileShareItems', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'ImmutableStorageAccount', - 'ImmutableStorageWithVersioning', - 'KeyCreationTime', - 'KeyPolicy', - 'KeyVaultProperties', - 'LastAccessTimeTrackingPolicy', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LeaseShareRequest', - 'LeaseShareResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListBlobInventoryPolicy', - 'ListContainerItem', - 'ListContainerItems', - 'ListQueue', - 'ListQueueResource', - 'ListQueueServices', - 'ListServiceSasResponse', - 'ListTableResource', - 'ListTableServices', - 'LocalUser', - 'LocalUserKeys', - 'LocalUserRegeneratePasswordResult', - 'LocalUsers', - 'ManagementPolicy', - 'ManagementPolicyAction', - 'ManagementPolicyBaseBlob', - 'ManagementPolicyDefinition', - 'ManagementPolicyFilter', - 'ManagementPolicyRule', - 'ManagementPolicySchema', - 'ManagementPolicySnapShot', - 'ManagementPolicyVersion', - 'MetricSpecification', - 'Multichannel', - 'NetworkRuleSet', - 'ObjectReplicationPolicies', - 'ObjectReplicationPolicy', - 'ObjectReplicationPolicyFilter', - 'ObjectReplicationPolicyRule', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PermissionScope', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProtectedAppendWritesHistory', - 'ProtocolSettings', - 'ProxyResource', - 'QueueServiceProperties', - 'Resource', - 'ResourceAccessRule', - 'RestorePolicyProperties', - 'Restriction', - 'RoutingPreference', - 'SKUCapability', - 'SasPolicy', - 'ServiceSasParameters', - 'ServiceSpecification', - 'SignedIdentifier', - 'Sku', - 'SkuInformation', - 'SmbSetting', - 'SshPublicKey', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountInternetEndpoints', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountMicrosoftEndpoints', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountSkuConversionStatus', - 'StorageAccountUpdateParameters', - 'StorageQueue', - 'StorageSkuListResult', - 'SystemData', - 'Table', - 'TableAccessPolicy', - 'TableServiceProperties', - 'TableSignedIdentifier', - 'TagFilter', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'UserAssignedIdentity', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountImmutabilityPolicyState', - 'AccountStatus', - 'ActiveDirectoryPropertiesAccountType', - 'AllowedCopyScope', - 'BlobInventoryPolicyName', - 'BlobRestoreProgressStatus', - 'Bypass', - 'CorsRuleAllowedMethodsItem', - 'CreatedByType', - 'DefaultAction', - 'DefaultSharePermission', - 'DirectoryServiceOptions', - 'DnsEndpointType', - 'EnabledProtocols', - 'EncryptionScopeSource', - 'EncryptionScopeState', - 'ExpirationAction', - 'ExtendedLocationTypes', - 'Format', - 'GeoReplicationStatus', - 'HttpProtocol', - 'IdentityType', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'InventoryRuleType', - 'KeyPermission', - 'KeySource', - 'KeyType', - 'Kind', - 'LargeFileSharesState', - 'LeaseContainerRequestAction', - 'LeaseDuration', - 'LeaseShareAction', - 'LeaseState', - 'LeaseStatus', - 'ListContainersInclude', - 'ManagementPolicyName', - 'MigrationState', - 'MinimumTlsVersion', - 'Name', - 'ObjectType', - 'Permissions', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'ProvisioningState', - 'PublicAccess', - 'PublicNetworkAccess', - 'Reason', - 'ReasonCode', - 'RootSquashType', - 'RoutingChoice', - 'RuleType', - 'Schedule', - 'Services', - 'ShareAccessTier', - 'SignedResource', - 'SignedResourceTypes', - 'SkuConversionStatus', - 'SkuName', - 'SkuTier', - 'State', - 'StorageAccountExpand', - 'UsageUnit', + "AccessPolicy", + "AccountImmutabilityPolicyProperties", + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobInventoryPolicy", + "BlobInventoryPolicyDefinition", + "BlobInventoryPolicyFilter", + "BlobInventoryPolicyRule", + "BlobInventoryPolicySchema", + "BlobRestoreParameters", + "BlobRestoreRange", + "BlobRestoreStatus", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorBody", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "DeletedAccount", + "DeletedAccountListResult", + "DeletedShare", + "Dimension", + "Encryption", + "EncryptionIdentity", + "EncryptionScope", + "EncryptionScopeKeyVaultProperties", + "EncryptionScopeListResult", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ErrorResponse", + "ErrorResponseBody", + "ExtendedLocation", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "ImmutableStorageAccount", + "ImmutableStorageWithVersioning", + "KeyCreationTime", + "KeyPolicy", + "KeyVaultProperties", + "LastAccessTimeTrackingPolicy", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LeaseShareRequest", + "LeaseShareResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListBlobInventoryPolicy", + "ListContainerItem", + "ListContainerItems", + "ListQueue", + "ListQueueResource", + "ListQueueServices", + "ListServiceSasResponse", + "ListTableResource", + "ListTableServices", + "LocalUser", + "LocalUserKeys", + "LocalUserRegeneratePasswordResult", + "LocalUsers", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "ManagementPolicyVersion", + "MetricSpecification", + "Multichannel", + "NetworkRuleSet", + "ObjectReplicationPolicies", + "ObjectReplicationPolicy", + "ObjectReplicationPolicyFilter", + "ObjectReplicationPolicyRule", + "Operation", + "OperationDisplay", + "OperationListResult", + "PermissionScope", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProtectedAppendWritesHistory", + "ProtocolSettings", + "ProxyResource", + "QueueServiceProperties", + "Resource", + "ResourceAccessRule", + "RestorePolicyProperties", + "Restriction", + "RoutingPreference", + "SKUCapability", + "SasPolicy", + "ServiceSasParameters", + "ServiceSpecification", + "SignedIdentifier", + "Sku", + "SkuInformation", + "SmbSetting", + "SshPublicKey", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountInternetEndpoints", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountMicrosoftEndpoints", + "StorageAccountRegenerateKeyParameters", + "StorageAccountSkuConversionStatus", + "StorageAccountUpdateParameters", + "StorageQueue", + "StorageSkuListResult", + "SystemData", + "Table", + "TableAccessPolicy", + "TableServiceProperties", + "TableSignedIdentifier", + "TagFilter", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "UserAssignedIdentity", + "VirtualNetworkRule", + "AccessTier", + "AccountImmutabilityPolicyState", + "AccountStatus", + "ActiveDirectoryPropertiesAccountType", + "AllowedCopyScope", + "BlobInventoryPolicyName", + "BlobRestoreProgressStatus", + "Bypass", + "CorsRuleAllowedMethodsItem", + "CreatedByType", + "DefaultAction", + "DefaultSharePermission", + "DirectoryServiceOptions", + "DnsEndpointType", + "EnabledProtocols", + "EncryptionScopeSource", + "EncryptionScopeState", + "ExpirationAction", + "ExtendedLocationTypes", + "Format", + "GeoReplicationStatus", + "HttpProtocol", + "IdentityType", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "InventoryRuleType", + "KeyPermission", + "KeySource", + "KeyType", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestAction", + "LeaseDuration", + "LeaseShareAction", + "LeaseState", + "LeaseStatus", + "ListContainersInclude", + "ManagementPolicyName", + "MigrationState", + "MinimumTlsVersion", + "Name", + "ObjectType", + "Permissions", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicAccess", + "PublicNetworkAccess", + "Reason", + "ReasonCode", + "RootSquashType", + "RoutingChoice", + "RuleType", + "Schedule", + "Services", + "ShareAccessTier", + "SignedResource", + "SignedResourceTypes", + "SkuConversionStatus", + "SkuName", + "SkuTier", + "State", + "StorageAccountExpand", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py index 0a4ce2403020..db6dba41014f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccessPolicy(msrest.serialization.Model): +class AccessPolicy(_serialization.Model): """AccessPolicy. :ivar start_time: Start time of the access policy. @@ -29,9 +35,9 @@ class AccessPolicy(msrest.serialization.Model): """ _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'permission': {'key': 'permission', 'type': 'str'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "permission": {"key": "permission", "type": "str"}, } def __init__( @@ -50,13 +56,13 @@ def __init__( :keyword permission: List of abbreviated permissions. :paramtype permission: str """ - super(AccessPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_time = start_time self.expiry_time = expiry_time self.permission = permission -class AccountImmutabilityPolicyProperties(msrest.serialization.Model): +class AccountImmutabilityPolicyProperties(_serialization.Model): """This defines account-level immutability policy properties. :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the @@ -68,7 +74,7 @@ class AccountImmutabilityPolicyProperties(msrest.serialization.Model): increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", - "Locked", "Disabled". + "Locked", and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_09_01.models.AccountImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for disabled and unlocked time-based retention policies. When enabled, new blocks can be written to an append @@ -78,13 +84,13 @@ class AccountImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'immutability_period_since_creation_in_days': {'maximum': 146000, 'minimum': 1}, + "immutability_period_since_creation_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'allowProtectedAppendWrites', 'type': 'bool'}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "state": {"key": "state", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -105,7 +111,7 @@ def __init__( increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", - "Locked", "Disabled". + "Locked", and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_09_01.models.AccountImmutabilityPolicyState :keyword allow_protected_append_writes: This property can only be changed for disabled and unlocked time-based retention policies. When enabled, new blocks can be written to an append @@ -113,60 +119,60 @@ def __init__( any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes: bool """ - super(AccountImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = state self.allow_protected_append_writes = allow_protected_append_writes -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2021_09_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2021_09_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_09_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_09_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -183,33 +189,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2021_09_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2021_09_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_09_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_09_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -220,50 +227,50 @@ def __init__( self.key_to_sign = key_to_sign -class ActiveDirectoryProperties(msrest.serialization.Model): +class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). All required parameters must be populated in order to send to Azure. - :ivar domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :vartype domain_name: str - :ivar net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. Required. :vartype net_bios_domain_name: str - :ivar forest_name: Required. Specifies the Active Directory forest to get. + :ivar forest_name: Specifies the Active Directory forest to get. Required. :vartype forest_name: str - :ivar domain_guid: Required. Specifies the domain GUID. + :ivar domain_guid: Specifies the domain GUID. Required. :vartype domain_guid: str - :ivar domain_sid: Required. Specifies the security identifier (SID). + :ivar domain_sid: Specifies the security identifier (SID). Required. :vartype domain_sid: str - :ivar azure_storage_sid: Required. Specifies the security identifier (SID) for Azure Storage. + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. Required. :vartype azure_storage_sid: str :ivar sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. :vartype sam_account_name: str :ivar account_type: Specifies the Active Directory account type for Azure Storage. Known values - are: "User", "Computer". + are: "User" and "Computer". :vartype account_type: str or ~azure.mgmt.storage.v2021_09_01.models.ActiveDirectoryPropertiesAccountType """ _validation = { - 'domain_name': {'required': True}, - 'net_bios_domain_name': {'required': True}, - 'forest_name': {'required': True}, - 'domain_guid': {'required': True}, - 'domain_sid': {'required': True}, - 'azure_storage_sid': {'required': True}, + "domain_name": {"required": True}, + "net_bios_domain_name": {"required": True}, + "forest_name": {"required": True}, + "domain_guid": {"required": True}, + "domain_sid": {"required": True}, + "azure_storage_sid": {"required": True}, } _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'net_bios_domain_name': {'key': 'netBiosDomainName', 'type': 'str'}, - 'forest_name': {'key': 'forestName', 'type': 'str'}, - 'domain_guid': {'key': 'domainGuid', 'type': 'str'}, - 'domain_sid': {'key': 'domainSid', 'type': 'str'}, - 'azure_storage_sid': {'key': 'azureStorageSid', 'type': 'str'}, - 'sam_account_name': {'key': 'samAccountName', 'type': 'str'}, - 'account_type': {'key': 'accountType', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, + "sam_account_name": {"key": "samAccountName", "type": "str"}, + "account_type": {"key": "accountType", "type": "str"}, } def __init__( @@ -280,28 +287,28 @@ def __init__( **kwargs ): """ - :keyword domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :paramtype domain_name: str - :keyword net_bios_domain_name: Required. Specifies the NetBIOS domain name. + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. Required. :paramtype net_bios_domain_name: str - :keyword forest_name: Required. Specifies the Active Directory forest to get. + :keyword forest_name: Specifies the Active Directory forest to get. Required. :paramtype forest_name: str - :keyword domain_guid: Required. Specifies the domain GUID. + :keyword domain_guid: Specifies the domain GUID. Required. :paramtype domain_guid: str - :keyword domain_sid: Required. Specifies the security identifier (SID). + :keyword domain_sid: Specifies the security identifier (SID). Required. :paramtype domain_sid: str - :keyword azure_storage_sid: Required. Specifies the security identifier (SID) for Azure - Storage. + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + Required. :paramtype azure_storage_sid: str :keyword sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. :paramtype sam_account_name: str :keyword account_type: Specifies the Active Directory account type for Azure Storage. Known - values are: "User", "Computer". + values are: "User" and "Computer". :paramtype account_type: str or ~azure.mgmt.storage.v2021_09_01.models.ActiveDirectoryPropertiesAccountType """ - super(ActiveDirectoryProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.net_bios_domain_name = net_bios_domain_name self.forest_name = forest_name @@ -312,7 +319,7 @@ def __init__( self.account_type = account_type -class Resource(msrest.serialization.Model): +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. @@ -328,24 +335,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -369,36 +372,32 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): +class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Known values - are: "None", "AADDS", "AD". + :ivar directory_service_options: Indicates the directory service used. Required. Known values + are: "None", "AADDS", and "AD". :vartype directory_service_options: str or ~azure.mgmt.storage.v2021_09_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if choose AD. @@ -406,20 +405,20 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): ~azure.mgmt.storage.v2021_09_01.models.ActiveDirectoryProperties :ivar default_share_permission: Default share permission for users using Kerberos authentication if RBAC role is not assigned. Known values are: "None", - "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and "StorageFileDataSmbShareElevatedContributor". :vartype default_share_permission: str or ~azure.mgmt.storage.v2021_09_01.models.DefaultSharePermission """ _validation = { - 'directory_service_options': {'required': True}, + "directory_service_options": {"required": True}, } _attribute_map = { - 'directory_service_options': {'key': 'directoryServiceOptions', 'type': 'str'}, - 'active_directory_properties': {'key': 'activeDirectoryProperties', 'type': 'ActiveDirectoryProperties'}, - 'default_share_permission': {'key': 'defaultSharePermission', 'type': 'str'}, + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, + "default_share_permission": {"key": "defaultSharePermission", "type": "str"}, } def __init__( @@ -431,8 +430,8 @@ def __init__( **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Known - values are: "None", "AADDS", "AD". + :keyword directory_service_options: Indicates the directory service used. Required. Known + values are: "None", "AADDS", and "AD". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2021_09_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if choose AD. @@ -440,18 +439,18 @@ def __init__( ~azure.mgmt.storage.v2021_09_01.models.ActiveDirectoryProperties :keyword default_share_permission: Default share permission for users using Kerberos authentication if RBAC role is not assigned. Known values are: "None", - "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and "StorageFileDataSmbShareElevatedContributor". :paramtype default_share_permission: str or ~azure.mgmt.storage.v2021_09_01.models.DefaultSharePermission """ - super(AzureFilesIdentityBasedAuthentication, self).__init__(**kwargs) + super().__init__(**kwargs) self.directory_service_options = directory_service_options self.active_directory_properties = active_directory_properties self.default_share_permission = default_share_permission -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -481,17 +480,18 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -521,48 +521,51 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, - 'enable_nfs_v3_root_squash': {'key': 'properties.enableNfsV3RootSquash', 'type': 'bool'}, - 'enable_nfs_v3_all_squash': {'key': 'properties.enableNfsV3AllSquash', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, } def __init__( @@ -585,7 +588,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -599,7 +602,7 @@ def __init__( :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. :paramtype enable_nfs_v3_all_squash: bool """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -643,59 +646,55 @@ class BlobInventoryPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified_time": {"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'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'BlobInventoryPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "BlobInventoryPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.BlobInventoryPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs): """ :keyword policy: The storage account blob inventory policy object. It is composed of policy rules. :paramtype policy: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicySchema """ - super(BlobInventoryPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.last_modified_time = None self.policy = policy -class BlobInventoryPolicyDefinition(msrest.serialization.Model): +class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. All required parameters must be populated in order to send to Azure. :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyFilter - :ivar format: Required. This is a required field, it specifies the format for the inventory - files. Known values are: "Csv", "Parquet". + :ivar format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". :vartype format: str or ~azure.mgmt.storage.v2021_09_01.models.Format - :ivar schedule: Required. This is a required field. This field is used to schedule an inventory - formation. Known values are: "Daily", "Weekly". + :ivar schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". :vartype schedule: str or ~azure.mgmt.storage.v2021_09_01.models.Schedule - :ivar object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Known values are: "Blob", "Container". + :ivar object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". :vartype object_type: str or ~azure.mgmt.storage.v2021_09_01.models.ObjectType - :ivar schema_fields: Required. This is a required field. This field specifies the fields and - properties of the object to be included in the inventory. The Schema field value 'Name' is - always required. The valid values for this field for the 'Blob' definition.objectType include - 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, + :ivar schema_fields: This is a required field. This field specifies the fields and properties + of the object to be included in the inventory. The Schema field value 'Name' is always + required. The valid values for this field for the 'Blob' definition.objectType include 'Name, + Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, AccessTierChangeTime, AccessTierInferred, Tags, Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime, Tags, Etag, ContentType, ContentEncoding, ContentLanguage, ContentCRC64, CacheControl, ContentDisposition, @@ -710,23 +709,23 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, DeletionId' are valid only for Hns enabled accounts.Schema field - values 'Tags, TagCount' are only valid for Non-Hns accounts. + values 'Tags, TagCount' are only valid for Non-Hns accounts. Required. :vartype schema_fields: list[str] """ _validation = { - 'format': {'required': True}, - 'schedule': {'required': True}, - 'object_type': {'required': True}, - 'schema_fields': {'required': True}, + "format": {"required": True}, + "schedule": {"required": True}, + "object_type": {"required": True}, + "schema_fields": {"required": True}, } _attribute_map = { - 'filters': {'key': 'filters', 'type': 'BlobInventoryPolicyFilter'}, - 'format': {'key': 'format', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'schema_fields': {'key': 'schemaFields', 'type': '[str]'}, + "filters": {"key": "filters", "type": "BlobInventoryPolicyFilter"}, + "format": {"key": "format", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "schema_fields": {"key": "schemaFields", "type": "[str]"}, } def __init__( @@ -742,16 +741,17 @@ def __init__( """ :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyFilter - :keyword format: Required. This is a required field, it specifies the format for the inventory - files. Known values are: "Csv", "Parquet". + :keyword format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". :paramtype format: str or ~azure.mgmt.storage.v2021_09_01.models.Format - :keyword schedule: Required. This is a required field. This field is used to schedule an - inventory formation. Known values are: "Daily", "Weekly". + :keyword schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". :paramtype schedule: str or ~azure.mgmt.storage.v2021_09_01.models.Schedule - :keyword object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Known values are: "Blob", "Container". + :keyword object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". :paramtype object_type: str or ~azure.mgmt.storage.v2021_09_01.models.ObjectType - :keyword schema_fields: Required. This is a required field. This field specifies the fields and + :keyword schema_fields: This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is always required. The valid values for this field for the 'Blob' definition.objectType include 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, @@ -769,10 +769,10 @@ def __init__( DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, DeletionId' are valid only for Hns enabled accounts.Schema field - values 'Tags, TagCount' are only valid for Non-Hns accounts. + values 'Tags, TagCount' are only valid for Non-Hns accounts. Required. :paramtype schema_fields: list[str] """ - super(BlobInventoryPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.filters = filters self.format = format self.schedule = schedule @@ -780,7 +780,7 @@ def __init__( self.schema_fields = schema_fields -class BlobInventoryPolicyFilter(msrest.serialization.Model): +class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. For 'Blob' definition.objectType all filter properties are applicable, 'blobTypes' is required and others are optional. For 'Container' definition.objectType only prefixMatch is applicable and is optional. :ivar prefix_match: An array of strings with maximum 10 blob prefixes to be included in the @@ -811,12 +811,12 @@ class BlobInventoryPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'exclude_prefix': {'key': 'excludePrefix', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'include_blob_versions': {'key': 'includeBlobVersions', 'type': 'bool'}, - 'include_snapshots': {'key': 'includeSnapshots', 'type': 'bool'}, - 'include_deleted': {'key': 'includeDeleted', 'type': 'bool'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "exclude_prefix": {"key": "excludePrefix", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "include_blob_versions": {"key": "includeBlobVersions", "type": "bool"}, + "include_snapshots": {"key": "includeSnapshots", "type": "bool"}, + "include_deleted": {"key": "includeDeleted", "type": "bool"}, } def __init__( @@ -857,7 +857,7 @@ def __init__( excluded. :paramtype include_deleted: bool """ - super(BlobInventoryPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.exclude_prefix = exclude_prefix self.blob_types = blob_types @@ -866,35 +866,35 @@ def __init__( self.include_deleted = include_deleted -class BlobInventoryPolicyRule(msrest.serialization.Model): +class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Rule is enabled when set to true. + :ivar enabled: Rule is enabled when set to true. Required. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :ivar destination: Container name where blob inventory files are stored. Must be pre-created. + Required. :vartype destination: str - :ivar definition: Required. An object that defines the blob inventory policy rule. + :ivar definition: An object that defines the blob inventory policy rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyDefinition """ _validation = { - 'enabled': {'required': True}, - 'name': {'required': True}, - 'destination': {'required': True}, - 'definition': {'required': True}, + "enabled": {"required": True}, + "name": {"required": True}, + "destination": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'destination': {'key': 'destination', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'BlobInventoryPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "destination": {"key": "destination", "type": "str"}, + "definition": {"key": "definition", "type": "BlobInventoryPolicyDefinition"}, } def __init__( @@ -907,55 +907,55 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Rule is enabled when set to true. + :keyword enabled: Rule is enabled when set to true. Required. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :keyword destination: Container name where blob inventory files are stored. Must be + pre-created. Required. :paramtype destination: str - :keyword definition: Required. An object that defines the blob inventory policy rule. + :keyword definition: An object that defines the blob inventory policy rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyDefinition """ - super(BlobInventoryPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.destination = destination self.definition = definition -class BlobInventoryPolicySchema(msrest.serialization.Model): +class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Policy is enabled if set to true. + :ivar enabled: Policy is enabled if set to true. Required. :vartype enabled: bool :ivar destination: Deprecated Property from API version 2021-04-01 onwards, the required destination container name must be specified at the rule level 'policy.rule.destination'. :vartype destination: str - :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". + :ivar type: The valid value is Inventory. Required. "Inventory" :vartype type: str or ~azure.mgmt.storage.v2021_09_01.models.InventoryRuleType - :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :ivar rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :vartype rules: list[~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyRule] """ _validation = { - 'enabled': {'required': True}, - 'destination': {'readonly': True}, - 'type': {'required': True}, - 'rules': {'required': True}, + "enabled": {"required": True}, + "destination": {"readonly": True}, + "type": {"required": True}, + "rules": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'destination': {'key': 'destination', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rules': {'key': 'rules', 'type': '[BlobInventoryPolicyRule]'}, + "enabled": {"key": "enabled", "type": "bool"}, + "destination": {"key": "destination", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rules": {"key": "rules", "type": "[BlobInventoryPolicyRule]"}, } def __init__( @@ -967,100 +967,88 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Policy is enabled if set to true. + :keyword enabled: Policy is enabled if set to true. Required. :paramtype enabled: bool - :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". + :keyword type: The valid value is Inventory. Required. "Inventory" :paramtype type: str or ~azure.mgmt.storage.v2021_09_01.models.InventoryRuleType - :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :keyword rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :paramtype rules: list[~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyRule] """ - super(BlobInventoryPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.destination = None self.type = type self.rules = rules -class BlobRestoreParameters(msrest.serialization.Model): +class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. All required parameters must be populated in order to send to Azure. - :ivar time_to_restore: Required. Restore blob to the specified time. + :ivar time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime - :ivar blob_ranges: Required. Blob ranges to restore. + :ivar blob_ranges: Blob ranges to restore. Required. :vartype blob_ranges: list[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreRange] """ _validation = { - 'time_to_restore': {'required': True}, - 'blob_ranges': {'required': True}, + "time_to_restore": {"required": True}, + "blob_ranges": {"required": True}, } _attribute_map = { - 'time_to_restore': {'key': 'timeToRestore', 'type': 'iso-8601'}, - 'blob_ranges': {'key': 'blobRanges', 'type': '[BlobRestoreRange]'}, + "time_to_restore": {"key": "timeToRestore", "type": "iso-8601"}, + "blob_ranges": {"key": "blobRanges", "type": "[BlobRestoreRange]"}, } - def __init__( - self, - *, - time_to_restore: datetime.datetime, - blob_ranges: List["_models.BlobRestoreRange"], - **kwargs - ): + def __init__(self, *, time_to_restore: datetime.datetime, blob_ranges: List["_models.BlobRestoreRange"], **kwargs): """ - :keyword time_to_restore: Required. Restore blob to the specified time. + :keyword time_to_restore: Restore blob to the specified time. Required. :paramtype time_to_restore: ~datetime.datetime - :keyword blob_ranges: Required. Blob ranges to restore. + :keyword blob_ranges: Blob ranges to restore. Required. :paramtype blob_ranges: list[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreRange] """ - super(BlobRestoreParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_to_restore = time_to_restore self.blob_ranges = blob_ranges -class BlobRestoreRange(msrest.serialization.Model): +class BlobRestoreRange(_serialization.Model): """Blob range. All required parameters must be populated in order to send to Azure. - :ivar start_range: Required. Blob start range. This is inclusive. Empty means account start. + :ivar start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str - :ivar end_range: Required. Blob end range. This is exclusive. Empty means account end. + :ivar end_range: Blob end range. This is exclusive. Empty means account end. Required. :vartype end_range: str """ _validation = { - 'start_range': {'required': True}, - 'end_range': {'required': True}, + "start_range": {"required": True}, + "end_range": {"required": True}, } _attribute_map = { - 'start_range': {'key': 'startRange', 'type': 'str'}, - 'end_range': {'key': 'endRange', 'type': 'str'}, + "start_range": {"key": "startRange", "type": "str"}, + "end_range": {"key": "endRange", "type": "str"}, } - def __init__( - self, - *, - start_range: str, - end_range: str, - **kwargs - ): + def __init__(self, *, start_range: str, end_range: str, **kwargs): """ - :keyword start_range: Required. Blob start range. This is inclusive. Empty means account start. + :keyword start_range: Blob start range. This is inclusive. Empty means account start. Required. :paramtype start_range: str - :keyword end_range: Required. Blob end range. This is exclusive. Empty means account end. + :keyword end_range: Blob end range. This is exclusive. Empty means account end. Required. :paramtype end_range: str """ - super(BlobRestoreRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_range = start_range self.end_range = end_range -class BlobRestoreStatus(msrest.serialization.Model): +class BlobRestoreStatus(_serialization.Model): """Blob restore status. Variables are only populated by the server, and will be ignored when sending a request. @@ -1068,7 +1056,7 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", - "Complete", "Failed". + "Complete", and "Failed". :vartype status: str or ~azure.mgmt.storage.v2021_09_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -1079,33 +1067,29 @@ class BlobRestoreStatus(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'restore_id': {'readonly': True}, - 'parameters': {'readonly': True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "restore_id": {"readonly": True}, + "parameters": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'restore_id': {'key': 'restoreId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'BlobRestoreParameters'}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "restore_id": {"key": "restoreId", "type": "str"}, + "parameters": {"key": "parameters", "type": "BlobRestoreParameters"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobRestoreStatus, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.failure_reason = None self.restore_id = None self.parameters = None -class BlobServiceItems(msrest.serialization.Model): +class BlobServiceItems(_serialization.Model): """BlobServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -1115,24 +1099,20 @@ class BlobServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobServiceProperties]'}, + "value": {"key": "value", "type": "[BlobServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class BlobServiceProperties(Resource): +class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attributes """The properties of a storage account’s Blob service. Variables are only populated by the server, and will be ignored when sending a request. @@ -1175,26 +1155,32 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'is_versioning_enabled': {'key': 'properties.isVersioningEnabled', 'type': 'bool'}, - 'automatic_snapshot_policy_enabled': {'key': 'properties.automaticSnapshotPolicyEnabled', 'type': 'bool'}, - 'change_feed': {'key': 'properties.changeFeed', 'type': 'ChangeFeed'}, - 'restore_policy': {'key': 'properties.restorePolicy', 'type': 'RestorePolicyProperties'}, - 'container_delete_retention_policy': {'key': 'properties.containerDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'last_access_time_tracking_policy': {'key': 'properties.lastAccessTimeTrackingPolicy', 'type': 'LastAccessTimeTrackingPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "is_versioning_enabled": {"key": "properties.isVersioningEnabled", "type": "bool"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, + "restore_policy": {"key": "properties.restorePolicy", "type": "RestorePolicyProperties"}, + "container_delete_retention_policy": { + "key": "properties.containerDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "last_access_time_tracking_policy": { + "key": "properties.lastAccessTimeTrackingPolicy", + "type": "LastAccessTimeTrackingPolicy", + }, } def __init__( @@ -1241,7 +1227,7 @@ def __init__( :paramtype last_access_time_tracking_policy: ~azure.mgmt.storage.v2021_09_01.models.LastAccessTimeTrackingPolicy """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.default_service_version = default_service_version @@ -1254,7 +1240,7 @@ def __init__( self.last_access_time_tracking_policy = last_access_time_tracking_policy -class ChangeFeed(msrest.serialization.Model): +class ChangeFeed(_serialization.Model): """The blob service properties for change feed events. :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. @@ -1266,21 +1252,15 @@ class ChangeFeed(msrest.serialization.Model): """ _validation = { - 'retention_in_days': {'maximum': 146000, 'minimum': 1}, + "retention_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_in_days': {'key': 'retentionInDays', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_in_days": {"key": "retentionInDays", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - retention_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, retention_in_days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. :paramtype enabled: bool @@ -1289,12 +1269,12 @@ def __init__( retention of the change feed. :paramtype retention_in_days: int """ - super(ChangeFeed, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.retention_in_days = retention_in_days -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1304,7 +1284,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2021_09_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1312,30 +1292,26 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1352,10 +1328,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -1380,50 +1356,50 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2021_09_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2021_09_01.models.CorsRuleAllowedMethodsItem] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -1437,24 +1413,24 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2021_09_01.models.CorsRuleAllowedMethodsItem] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -1462,7 +1438,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -1471,31 +1447,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2021_09_01.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -1503,41 +1474,35 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DateAfterCreation(msrest.serialization.Model): +class DateAfterCreation(_serialization.Model): """Object to define snapshot and version action conditions. All required parameters must be populated in order to send to Azure. - :ivar days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :vartype days_after_creation_greater_than: float :ivar days_after_last_tier_change_greater_than: Value indicating the age in days after last blob tier change time. This property is only applicable for tierToArchive actions and requires @@ -1547,13 +1512,13 @@ class DateAfterCreation(msrest.serialization.Model): """ _validation = { - 'days_after_creation_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, - 'days_after_last_tier_change_greater_than': {'minimum': 0, 'multiple': 1}, + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, + "days_after_last_tier_change_greater_than": {"minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, - 'days_after_last_tier_change_greater_than': {'key': 'daysAfterLastTierChangeGreaterThan', 'type': 'float'}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, + "days_after_last_tier_change_greater_than": {"key": "daysAfterLastTierChangeGreaterThan", "type": "float"}, } def __init__( @@ -1564,8 +1529,8 @@ def __init__( **kwargs ): """ - :keyword days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :paramtype days_after_creation_greater_than: float :keyword days_after_last_tier_change_greater_than: Value indicating the age in days after last blob tier change time. This property is only applicable for tierToArchive actions and requires @@ -1573,12 +1538,12 @@ def __init__( will be archived if both the conditions are satisfied. :paramtype days_after_last_tier_change_greater_than: float """ - super(DateAfterCreation, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_creation_greater_than = days_after_creation_greater_than self.days_after_last_tier_change_greater_than = days_after_last_tier_change_greater_than -class DateAfterModification(msrest.serialization.Model): +class DateAfterModification(_serialization.Model): """Object to define the base blob action conditions. Properties daysAfterModificationGreaterThan, daysAfterLastAccessTimeGreaterThan and daysAfterCreationGreaterThan are mutually exclusive. The daysAfterLastTierChangeGreaterThan property is only applicable for tierToArchive actions which requires daysAfterModificationGreaterThan to be set, also it cannot be used in conjunction with daysAfterLastAccessTimeGreaterThan or daysAfterCreationGreaterThan. :ivar days_after_modification_greater_than: Value indicating the age in days after last @@ -1598,17 +1563,17 @@ class DateAfterModification(msrest.serialization.Model): """ _validation = { - 'days_after_modification_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_last_access_time_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_last_tier_change_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_creation_greater_than': {'minimum': 0, 'multiple': 1}, + "days_after_modification_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_access_time_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_tier_change_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_creation_greater_than": {"minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'float'}, - 'days_after_last_access_time_greater_than': {'key': 'daysAfterLastAccessTimeGreaterThan', 'type': 'float'}, - 'days_after_last_tier_change_greater_than': {'key': 'daysAfterLastTierChangeGreaterThan', 'type': 'float'}, - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, + "days_after_last_access_time_greater_than": {"key": "daysAfterLastAccessTimeGreaterThan", "type": "float"}, + "days_after_last_tier_change_greater_than": {"key": "daysAfterLastTierChangeGreaterThan", "type": "float"}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, } def __init__( @@ -1637,7 +1602,7 @@ def __init__( creation. :paramtype days_after_creation_greater_than: float """ - super(DateAfterModification, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_modification_greater_than = days_after_modification_greater_than self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than self.days_after_last_tier_change_greater_than = days_after_last_tier_change_greater_than @@ -1660,24 +1625,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class DeletedAccount(ProxyResource): @@ -1707,34 +1668,30 @@ class DeletedAccount(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'storage_account_resource_id': {'readonly': True}, - 'location': {'readonly': True}, - 'restore_reference': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'deletion_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'location': {'key': 'properties.location', 'type': 'str'}, - 'restore_reference': {'key': 'properties.restoreReference', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, - 'deletion_time': {'key': 'properties.deletionTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccount, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "storage_account_resource_id": {"readonly": True}, + "location": {"readonly": True}, + "restore_reference": {"readonly": True}, + "creation_time": {"readonly": True}, + "deletion_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "location": {"key": "properties.location", "type": "str"}, + "restore_reference": {"key": "properties.restoreReference", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "str"}, + "deletion_time": {"key": "properties.deletionTime", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_account_resource_id = None self.location = None self.restore_reference = None @@ -1742,7 +1699,7 @@ def __init__( self.deletion_time = None -class DeletedAccountListResult(msrest.serialization.Model): +class DeletedAccountListResult(_serialization.Model): """The response from the List Deleted Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1755,70 +1712,60 @@ class DeletedAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeletedAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeletedAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DeletedShare(msrest.serialization.Model): +class DeletedShare(_serialization.Model): """The deleted share to be restored. All required parameters must be populated in order to send to Azure. - :ivar deleted_share_name: Required. Required. Identify the name of the deleted share that will - be restored. + :ivar deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :vartype deleted_share_name: str - :ivar deleted_share_version: Required. Required. Identify the version of the deleted share that - will be restored. + :ivar deleted_share_version: Required. Identify the version of the deleted share that will be + restored. Required. :vartype deleted_share_version: str """ _validation = { - 'deleted_share_name': {'required': True}, - 'deleted_share_version': {'required': True}, + "deleted_share_name": {"required": True}, + "deleted_share_version": {"required": True}, } _attribute_map = { - 'deleted_share_name': {'key': 'deletedShareName', 'type': 'str'}, - 'deleted_share_version': {'key': 'deletedShareVersion', 'type': 'str'}, + "deleted_share_name": {"key": "deletedShareName", "type": "str"}, + "deleted_share_version": {"key": "deletedShareVersion", "type": "str"}, } - def __init__( - self, - *, - deleted_share_name: str, - deleted_share_version: str, - **kwargs - ): + def __init__(self, *, deleted_share_name: str, deleted_share_version: str, **kwargs): """ - :keyword deleted_share_name: Required. Required. Identify the name of the deleted share that - will be restored. + :keyword deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :paramtype deleted_share_name: str - :keyword deleted_share_version: Required. Required. Identify the version of the deleted share - that will be restored. + :keyword deleted_share_version: Required. Identify the version of the deleted share that will + be restored. Required. :paramtype deleted_share_version: str """ - super(DeletedShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.deleted_share_name = deleted_share_name self.deleted_share_version = deleted_share_version -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. @@ -1833,13 +1780,13 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - 'allow_permanent_delete': {'key': 'allowPermanentDelete', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "allow_permanent_delete": {"key": "allowPermanentDelete", "type": "bool"}, } def __init__( @@ -1861,13 +1808,13 @@ def __init__( property only applies to blob service and does not apply to containers or file share. :paramtype allow_permanent_delete: bool """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days self.allow_permanent_delete = allow_permanent_delete -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -1877,38 +1824,32 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. All required parameters must be populated in order to send to Azure. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2021_09_01.models.EncryptionServices - :ivar key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2021_09_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1920,15 +1861,15 @@ class Encryption(msrest.serialization.Model): """ _validation = { - 'key_source': {'required': True}, + "key_source": {"required": True}, } _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, - 'encryption_identity': {'key': 'identity', 'type': 'EncryptionIdentity'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, + "encryption_identity": {"key": "identity", "type": "EncryptionIdentity"}, } def __init__( @@ -1944,9 +1885,9 @@ def __init__( """ :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2021_09_01.models.EncryptionServices - :keyword key_source: Required. The encryption keySource (provider). Possible values - (case-insensitive): Microsoft.Storage, Microsoft.Keyvault. Known values are: - "Microsoft.Storage", "Microsoft.Keyvault". Default value: "Microsoft.Storage". + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2021_09_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1956,7 +1897,7 @@ def __init__( :keyword encryption_identity: The identity to be used with service-side encryption at rest. :paramtype encryption_identity: ~azure.mgmt.storage.v2021_09_01.models.EncryptionIdentity """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption @@ -1964,7 +1905,7 @@ def __init__( self.encryption_identity = encryption_identity -class EncryptionIdentity(msrest.serialization.Model): +class EncryptionIdentity(_serialization.Model): """Encryption identity for the storage account. :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be @@ -1977,8 +1918,8 @@ class EncryptionIdentity(msrest.serialization.Model): """ _attribute_map = { - 'encryption_user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, - 'encryption_federated_identity_client_id': {'key': 'federatedIdentityClientId', 'type': 'str'}, + "encryption_user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, + "encryption_federated_identity_client_id": {"key": "federatedIdentityClientId", "type": "str"}, } def __init__( @@ -1997,7 +1938,7 @@ def __init__( server-side encryption on the storage account. :paramtype encryption_federated_identity_client_id: str """ - super(EncryptionIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.encryption_user_assigned_identity = encryption_user_assigned_identity self.encryption_federated_identity_client_id = encryption_federated_identity_client_id @@ -2016,11 +1957,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Known values are: "Enabled", "Disabled". + Disabled. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -2037,23 +1978,23 @@ class EncryptionScope(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'EncryptionScopeKeyVaultProperties'}, - 'require_infrastructure_encryption': {'key': 'properties.requireInfrastructureEncryption', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "EncryptionScopeKeyVaultProperties"}, + "require_infrastructure_encryption": {"key": "properties.requireInfrastructureEncryption", "type": "bool"}, } def __init__( @@ -2067,11 +2008,11 @@ def __init__( ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Known values are: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -2081,7 +2022,7 @@ def __init__( applies a secondary layer of encryption with platform managed keys for data at rest. :paramtype require_infrastructure_encryption: bool """ - super(EncryptionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.state = state self.creation_time = None @@ -2090,7 +2031,7 @@ def __init__( self.require_infrastructure_encryption = require_infrastructure_encryption -class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): +class EncryptionScopeKeyVaultProperties(_serialization.Model): """The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. Variables are only populated by the server, and will be ignored when sending a request. @@ -2107,35 +2048,30 @@ class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_uri': {'key': 'keyUri', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_uri": {"key": "keyUri", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_uri: Optional[str] = None, **kwargs): """ :keyword key_uri: The object identifier for a key vault key object. When applied, the encryption scope will use the key referenced by the identifier to enable customer-managed key support on this encryption scope. :paramtype key_uri: str """ - super(EncryptionScopeKeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_uri = key_uri self.current_versioned_key_identifier = None self.last_key_rotation_timestamp = None -class EncryptionScopeListResult(msrest.serialization.Model): +class EncryptionScopeListResult(_serialization.Model): """List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. Variables are only populated by the server, and will be ignored when sending a request. @@ -2148,27 +2084,23 @@ class EncryptionScopeListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EncryptionScope]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EncryptionScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(EncryptionScopeListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -2181,26 +2113,22 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Known values are: "Service", "Account". + default service key is used. Known values are: "Service" and "Account". :vartype key_type: str or ~azure.mgmt.storage.v2021_09_01.models.KeyType """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'key_type': {'key': 'keyType', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "key_type": {"key": "keyType", "type": "str"}, } def __init__( - self, - *, - enabled: Optional[bool] = None, - key_type: Optional[Union[str, "_models.KeyType"]] = None, - **kwargs + self, *, enabled: Optional[bool] = None, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is @@ -2208,16 +2136,16 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Known values are: "Service", "Account". + that a default service key is used. Known values are: "Service" and "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2021_09_01.models.KeyType """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None self.key_type = key_type -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. :ivar blob: The encryption function of the blob storage service. @@ -2231,10 +2159,10 @@ class EncryptionServices(msrest.serialization.Model): """ _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -2256,14 +2184,14 @@ def __init__( :keyword queue: The encryption function of the queue storage service. :paramtype queue: ~azure.mgmt.storage.v2021_09_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = table self.queue = queue -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -2289,23 +2217,23 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, - 'microsoft_endpoints': {'key': 'microsoftEndpoints', 'type': 'StorageAccountMicrosoftEndpoints'}, - 'internet_endpoints': {'key': 'internetEndpoints', 'type': 'StorageAccountInternetEndpoints'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + "microsoft_endpoints": {"key": "microsoftEndpoints", "type": "StorageAccountMicrosoftEndpoints"}, + "internet_endpoints": {"key": "internetEndpoints", "type": "StorageAccountInternetEndpoints"}, } def __init__( @@ -2323,7 +2251,7 @@ def __init__( :paramtype internet_endpoints: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountInternetEndpoints """ - super(Endpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -2334,7 +2262,7 @@ def __init__( self.internet_endpoints = internet_endpoints -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the storage resource provider. :ivar error: Azure Storage Resource Provider error response body. @@ -2342,24 +2270,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure Storage Resource Provider error response body. :paramtype error: ~azure.mgmt.storage.v2021_09_01.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """Error response body contract. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -2371,17 +2294,11 @@ class ErrorResponseBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. @@ -2390,23 +2307,23 @@ def __init__( interface. :paramtype message: str """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ExtendedLocation(msrest.serialization.Model): +class ExtendedLocation(_serialization.Model): """The complex type of the extended location. :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Known values are: "EdgeZone". + :ivar type: The type of the extended location. "EdgeZone" :vartype type: str or ~azure.mgmt.storage.v2021_09_01.models.ExtendedLocationTypes """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -2419,15 +2336,15 @@ def __init__( """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Known values are: "EdgeZone". + :keyword type: The type of the extended location. "EdgeZone" :paramtype type: str or ~azure.mgmt.storage.v2021_09_01.models.ExtendedLocationTypes """ - super(ExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class FileServiceItems(msrest.serialization.Model): +class FileServiceItems(_serialization.Model): """FileServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -2437,20 +2354,16 @@ class FileServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileServiceProperties]'}, + "value": {"key": "value", "type": "[FileServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -2481,20 +2394,23 @@ class FileServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'share_delete_retention_policy': {'key': 'properties.shareDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'protocol_settings': {'key': 'properties.protocolSettings', 'type': 'ProtocolSettings'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "share_delete_retention_policy": { + "key": "properties.shareDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "protocol_settings": {"key": "properties.protocolSettings", "type": "ProtocolSettings"}, } def __init__( @@ -2516,14 +2432,14 @@ def __init__( :keyword protocol_settings: Protocol settings for file service. :paramtype protocol_settings: ~azure.mgmt.storage.v2021_09_01.models.ProtocolSettings """ - super(FileServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.share_delete_retention_policy = share_delete_retention_policy self.protocol_settings = protocol_settings -class FileShare(AzureEntityResource): +class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the file share, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -2546,10 +2462,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_09_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_09_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2561,7 +2477,7 @@ class FileShare(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2569,14 +2485,14 @@ class FileShare(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseStatus :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Known values are: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_09_01.models.SignedIdentifier] @@ -2586,48 +2502,48 @@ class FileShare(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2648,19 +2564,19 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_09_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_09_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_09_01.models.SignedIdentifier] """ - super(FileShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2681,7 +2597,7 @@ def __init__( self.snapshot_time = None -class FileShareItem(AzureEntityResource): +class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The file share properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -2704,10 +2620,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2021_09_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2021_09_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2719,7 +2635,7 @@ class FileShareItem(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2727,14 +2643,14 @@ class FileShareItem(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseStatus :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Known values are: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2021_09_01.models.SignedIdentifier] @@ -2744,48 +2660,48 @@ class FileShareItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2806,19 +2722,19 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2021_09_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2021_09_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_09_01.models.SignedIdentifier] """ - super(FileShareItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2839,7 +2755,7 @@ def __init__( self.snapshot_time = None -class FileShareItems(msrest.serialization.Model): +class FileShareItems(_serialization.Model): """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. Variables are only populated by the server, and will be ignored when sending a request. @@ -2852,27 +2768,23 @@ class FileShareItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileShareItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileShareItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2881,7 +2793,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2021_09_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2894,30 +2806,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2928,8 +2836,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2021_09_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2939,16 +2847,16 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( @@ -2959,8 +2867,8 @@ def __init__( **kwargs ): """ - :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2021_09_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2968,7 +2876,7 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.storage.v2021_09_01.models.UserAssignedIdentity] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type @@ -2994,7 +2902,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -3012,22 +2920,25 @@ class ImmutabilityPolicy(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'properties.allowProtectedAppendWritesAll', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -3056,14 +2967,14 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None self.allow_protected_append_writes = allow_protected_append_writes self.allow_protected_append_writes_all = allow_protected_append_writes_all -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3076,7 +2987,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -3094,18 +3005,21 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'properties.allowProtectedAppendWritesAll', 'type': 'bool'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -3134,7 +3048,7 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days @@ -3143,7 +3057,7 @@ def __init__( self.allow_protected_append_writes_all = allow_protected_append_writes_all -class ImmutableStorageAccount(msrest.serialization.Model): +class ImmutableStorageAccount(_serialization.Model): """This property enables and defines account-level immutability. Enabling the feature auto-enables Blob Versioning. :ivar enabled: A boolean flag which enables account-level immutability. All the containers @@ -3159,8 +3073,8 @@ class ImmutableStorageAccount(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'immutability_policy': {'key': 'immutabilityPolicy', 'type': 'AccountImmutabilityPolicyProperties'}, + "enabled": {"key": "enabled", "type": "bool"}, + "immutability_policy": {"key": "immutabilityPolicy", "type": "AccountImmutabilityPolicyProperties"}, } def __init__( @@ -3182,12 +3096,12 @@ def __init__( :paramtype immutability_policy: ~azure.mgmt.storage.v2021_09_01.models.AccountImmutabilityPolicyProperties """ - super(ImmutableStorageAccount, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.immutability_policy = immutability_policy -class ImmutableStorageWithVersioning(msrest.serialization.Model): +class ImmutableStorageWithVersioning(_serialization.Model): """Object level immutability properties of the container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3198,81 +3112,68 @@ class ImmutableStorageWithVersioning(msrest.serialization.Model): :ivar time_stamp: Returns the date and time the object level immutability was enabled. :vartype time_stamp: ~datetime.datetime :ivar migration_state: This property denotes the container level immutability to object level - immutability migration state. Known values are: "InProgress", "Completed". + immutability migration state. Known values are: "InProgress" and "Completed". :vartype migration_state: str or ~azure.mgmt.storage.v2021_09_01.models.MigrationState """ _validation = { - 'time_stamp': {'readonly': True}, - 'migration_state': {'readonly': True}, + "time_stamp": {"readonly": True}, + "migration_state": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'migration_state': {'key': 'migrationState', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "migration_state": {"key": "migrationState", "type": "str"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: This is an immutable property, when set to true it enables object level immutability at the container level. :paramtype enabled: bool """ - super(ImmutableStorageWithVersioning, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.time_stamp = None self.migration_state = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyCreationTime(msrest.serialization.Model): +class KeyCreationTime(_serialization.Model): """Storage account keys creation time. :ivar key1: @@ -3282,60 +3183,49 @@ class KeyCreationTime(msrest.serialization.Model): """ _attribute_map = { - 'key1': {'key': 'key1', 'type': 'iso-8601'}, - 'key2': {'key': 'key2', 'type': 'iso-8601'}, + "key1": {"key": "key1", "type": "iso-8601"}, + "key2": {"key": "key2", "type": "iso-8601"}, } - def __init__( - self, - *, - key1: Optional[datetime.datetime] = None, - key2: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, key1: Optional[datetime.datetime] = None, key2: Optional[datetime.datetime] = None, **kwargs): """ :keyword key1: :paramtype key1: ~datetime.datetime :keyword key2: :paramtype key2: ~datetime.datetime """ - super(KeyCreationTime, self).__init__(**kwargs) + super().__init__(**kwargs) self.key1 = key1 self.key2 = key2 -class KeyPolicy(msrest.serialization.Model): +class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar key_expiration_period_in_days: Required. The key expiration period in days. + :ivar key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int """ _validation = { - 'key_expiration_period_in_days': {'required': True}, + "key_expiration_period_in_days": {"required": True}, } _attribute_map = { - 'key_expiration_period_in_days': {'key': 'keyExpirationPeriodInDays', 'type': 'int'}, + "key_expiration_period_in_days": {"key": "keyExpirationPeriodInDays", "type": "int"}, } - def __init__( - self, - *, - key_expiration_period_in_days: int, - **kwargs - ): + def __init__(self, *, key_expiration_period_in_days: int, **kwargs): """ - :keyword key_expiration_period_in_days: Required. The key expiration period in days. + :keyword key_expiration_period_in_days: The key expiration period in days. Required. :paramtype key_expiration_period_in_days: int """ - super(KeyPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_expiration_period_in_days = key_expiration_period_in_days -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. Variables are only populated by the server, and will be ignored when sending a request. @@ -3357,18 +3247,21 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, - 'current_versioned_key_expiration_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, + "current_versioned_key_expiration_timestamp": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, - 'current_versioned_key_expiration_timestamp': {'key': 'currentVersionedKeyExpirationTimestamp', 'type': 'iso-8601'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, + "current_versioned_key_expiration_timestamp": { + "key": "currentVersionedKeyExpirationTimestamp", + "type": "iso-8601", + }, } def __init__( @@ -3387,7 +3280,7 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri @@ -3396,15 +3289,15 @@ def __init__( self.current_versioned_key_expiration_timestamp = None -class LastAccessTimeTrackingPolicy(msrest.serialization.Model): +class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. All required parameters must be populated in order to send to Azure. - :ivar enable: Required. When set to true last access time based tracking is enabled. + :ivar enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Known values are: "AccessTimeTracking". + read only. "AccessTimeTracking" :vartype name: str or ~azure.mgmt.storage.v2021_09_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3416,14 +3309,14 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): """ _validation = { - 'enable': {'required': True}, + "enable": {"required": True}, } _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tracking_granularity_in_days': {'key': 'trackingGranularityInDays', 'type': 'int'}, - 'blob_type': {'key': 'blobType', 'type': '[str]'}, + "enable": {"key": "enable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "tracking_granularity_in_days": {"key": "trackingGranularityInDays", "type": "int"}, + "blob_type": {"key": "blobType", "type": "[str]"}, } def __init__( @@ -3436,10 +3329,10 @@ def __init__( **kwargs ): """ - :keyword enable: Required. When set to true last access time based tracking is enabled. + :keyword enable: When set to true last access time based tracking is enabled. Required. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Known values are: "AccessTimeTracking". + currently read only. "AccessTimeTracking" :paramtype name: str or ~azure.mgmt.storage.v2021_09_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3449,20 +3342,20 @@ def __init__( supported value. This field is currently read only. :paramtype blob_type: list[str] """ - super(LastAccessTimeTrackingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enable = enable self.name = name self.tracking_granularity_in_days = tracking_granularity_in_days self.blob_type = blob_type -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequestAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3478,15 +3371,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -3500,8 +3393,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequestAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3515,7 +3408,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -3523,7 +3416,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -3534,17 +3427,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -3552,18 +3439,18 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LeaseShareRequest(msrest.serialization.Model): +class LeaseShareRequest(_serialization.Model): """Lease Share request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3579,15 +3466,15 @@ class LeaseShareRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -3601,8 +3488,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3616,7 +3503,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseShareRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -3624,7 +3511,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseShareResponse(msrest.serialization.Model): +class LeaseShareResponse(_serialization.Model): """Lease Share response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -3635,17 +3522,11 @@ class LeaseShareResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the share, or to renew, change, or release the lease. @@ -3653,12 +3534,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseShareResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3670,8 +3551,8 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] :ivar allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks @@ -3680,39 +3561,33 @@ class LegalHold(msrest.serialization.Model): """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, } - def __init__( - self, - *, - tags: List[str], - allow_protected_append_writes_all: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, tags: List[str], allow_protected_append_writes_all: Optional[bool] = None, **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes_all: bool """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags self.allow_protected_append_writes_all = allow_protected_append_writes_all -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3722,7 +3597,7 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2021_09_01.models.TagProperty] :ivar protected_append_writes_history: Protected append blob writes history. :vartype protected_append_writes_history: @@ -3730,13 +3605,16 @@ class LegalHoldProperties(msrest.serialization.Model): """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, - 'protected_append_writes_history': {'key': 'protectedAppendWritesHistory', 'type': 'ProtectedAppendWritesHistory'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, + "protected_append_writes_history": { + "key": "protectedAppendWritesHistory", + "type": "ProtectedAppendWritesHistory", + }, } def __init__( @@ -3747,19 +3625,19 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2021_09_01.models.TagProperty] :keyword protected_append_writes_history: Protected append blob writes history. :paramtype protected_append_writes_history: ~azure.mgmt.storage.v2021_09_01.models.ProtectedAppendWritesHistory """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags self.protected_append_writes_history = protected_append_writes_history -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3769,24 +3647,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListBlobInventoryPolicy(msrest.serialization.Model): +class ListBlobInventoryPolicy(_serialization.Model): """List of blob inventory policies returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3796,24 +3670,20 @@ class ListBlobInventoryPolicy(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobInventoryPolicy]'}, + "value": {"key": "value", "type": "[BlobInventoryPolicy]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListBlobInventoryPolicy, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -3843,17 +3713,18 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2021_09_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3883,48 +3754,51 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, - 'enable_nfs_v3_root_squash': {'key': 'properties.enableNfsV3RootSquash', 'type': 'bool'}, - 'enable_nfs_v3_all_squash': {'key': 'properties.enableNfsV3AllSquash', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, } def __init__( @@ -3947,7 +3821,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -3961,7 +3835,7 @@ def __init__( :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. :paramtype enable_nfs_v3_all_squash: bool """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -3983,7 +3857,7 @@ def __init__( self.enable_nfs_v3_all_squash = enable_nfs_v3_all_squash -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. Variables are only populated by the server, and will be ignored when sending a request. @@ -3996,22 +3870,18 @@ class ListContainerItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListContainerItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -4034,33 +3904,28 @@ class ListQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(ListQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata -class ListQueueResource(msrest.serialization.Model): +class ListQueueResource(_serialization.Model): """Response schema. Contains list of queues returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -4072,27 +3937,23 @@ class ListQueueResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListQueueServices(msrest.serialization.Model): +class ListQueueServices(_serialization.Model): """ListQueueServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -4102,24 +3963,20 @@ class ListQueueServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueServiceProperties]'}, + "value": {"key": "value", "type": "[QueueServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -4129,24 +3986,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class ListTableResource(msrest.serialization.Model): +class ListTableResource(_serialization.Model): """Response schema. Contains list of tables returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -4158,27 +4011,23 @@ class ListTableResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Table]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Table]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListTableServices(msrest.serialization.Model): +class ListTableServices(_serialization.Model): """ListTableServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -4188,24 +4037,20 @@ class ListTableServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TableServiceProperties]'}, + "value": {"key": "value", "type": "[TableServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class LocalUser(Resource): +class LocalUser(Resource): # pylint: disable=too-many-instance-attributes """The local user associated with the storage accounts. Variables are only populated by the server, and will be ignored when sending a request. @@ -4240,25 +4085,25 @@ class LocalUser(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'sid': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "sid": {"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'}, - 'permission_scopes': {'key': 'properties.permissionScopes', 'type': '[PermissionScope]'}, - 'home_directory': {'key': 'properties.homeDirectory', 'type': 'str'}, - 'ssh_authorized_keys': {'key': 'properties.sshAuthorizedKeys', 'type': '[SshPublicKey]'}, - 'sid': {'key': 'properties.sid', 'type': 'str'}, - 'has_shared_key': {'key': 'properties.hasSharedKey', 'type': 'bool'}, - 'has_ssh_key': {'key': 'properties.hasSshKey', 'type': 'bool'}, - 'has_ssh_password': {'key': 'properties.hasSshPassword', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "permission_scopes": {"key": "properties.permissionScopes", "type": "[PermissionScope]"}, + "home_directory": {"key": "properties.homeDirectory", "type": "str"}, + "ssh_authorized_keys": {"key": "properties.sshAuthorizedKeys", "type": "[SshPublicKey]"}, + "sid": {"key": "properties.sid", "type": "str"}, + "has_shared_key": {"key": "properties.hasSharedKey", "type": "bool"}, + "has_ssh_key": {"key": "properties.hasSshKey", "type": "bool"}, + "has_ssh_password": {"key": "properties.hasSshPassword", "type": "bool"}, } def __init__( @@ -4289,7 +4134,7 @@ def __init__( existing SSH password. :paramtype has_ssh_password: bool """ - super(LocalUser, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.permission_scopes = permission_scopes self.home_directory = home_directory @@ -4300,7 +4145,7 @@ def __init__( self.has_ssh_password = has_ssh_password -class LocalUserKeys(msrest.serialization.Model): +class LocalUserKeys(_serialization.Model): """The Storage Account Local User keys. Variables are only populated by the server, and will be ignored when sending a request. @@ -4312,30 +4157,25 @@ class LocalUserKeys(msrest.serialization.Model): """ _validation = { - 'shared_key': {'readonly': True}, + "shared_key": {"readonly": True}, } _attribute_map = { - 'ssh_authorized_keys': {'key': 'sshAuthorizedKeys', 'type': '[SshPublicKey]'}, - 'shared_key': {'key': 'sharedKey', 'type': 'str'}, + "ssh_authorized_keys": {"key": "sshAuthorizedKeys", "type": "[SshPublicKey]"}, + "shared_key": {"key": "sharedKey", "type": "str"}, } - def __init__( - self, - *, - ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, - **kwargs - ): + def __init__(self, *, ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs): """ :keyword ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. :paramtype ssh_authorized_keys: list[~azure.mgmt.storage.v2021_09_01.models.SshPublicKey] """ - super(LocalUserKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.ssh_authorized_keys = ssh_authorized_keys self.shared_key = None -class LocalUserRegeneratePasswordResult(msrest.serialization.Model): +class LocalUserRegeneratePasswordResult(_serialization.Model): """The secrets of Storage Account Local User. Variables are only populated by the server, and will be ignored when sending a request. @@ -4346,24 +4186,20 @@ class LocalUserRegeneratePasswordResult(msrest.serialization.Model): """ _validation = { - 'ssh_password': {'readonly': True}, + "ssh_password": {"readonly": True}, } _attribute_map = { - 'ssh_password': {'key': 'sshPassword', 'type': 'str'}, + "ssh_password": {"key": "sshPassword", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LocalUserRegeneratePasswordResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ssh_password = None -class LocalUsers(msrest.serialization.Model): +class LocalUsers(_serialization.Model): """List storage account local users. :ivar value: The local users associated with the storage account. @@ -4371,20 +4207,15 @@ class LocalUsers(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[LocalUser]'}, + "value": {"key": "value", "type": "[LocalUser]"}, } - def __init__( - self, - *, - value: Optional[List["_models.LocalUser"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.LocalUser"]] = None, **kwargs): """ :keyword value: The local users associated with the storage account. :paramtype value: list[~azure.mgmt.storage.v2021_09_01.models.LocalUser] """ - super(LocalUsers, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4409,37 +4240,32 @@ class ManagementPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.ManagementPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :paramtype policy: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicySchema """ - super(ManagementPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.policy = policy -class ManagementPolicyAction(msrest.serialization.Model): +class ManagementPolicyAction(_serialization.Model): """Actions are applied to the filtered blobs when the execution condition is met. :ivar base_blob: The management policy action for base blob. @@ -4451,9 +4277,9 @@ class ManagementPolicyAction(msrest.serialization.Model): """ _attribute_map = { - 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, - 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, - 'version': {'key': 'version', 'type': 'ManagementPolicyVersion'}, + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, + "version": {"key": "version", "type": "ManagementPolicyVersion"}, } def __init__( @@ -4472,13 +4298,13 @@ def __init__( :keyword version: The management policy action for version. :paramtype version: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyVersion """ - super(ManagementPolicyAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_blob = base_blob self.snapshot = snapshot self.version = version -class ManagementPolicyBaseBlob(msrest.serialization.Model): +class ManagementPolicyBaseBlob(_serialization.Model): """Management policy action for base blob. :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot @@ -4495,10 +4321,10 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, - 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, - 'enable_auto_tier_to_hot_from_cool': {'key': 'enableAutoTierToHotFromCool', 'type': 'bool'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, + "enable_auto_tier_to_hot_from_cool": {"key": "enableAutoTierToHotFromCool", "type": "bool"}, } def __init__( @@ -4524,31 +4350,31 @@ def __init__( tierToCool.daysAfterLastAccessTimeGreaterThan. :paramtype enable_auto_tier_to_hot_from_cool: bool """ - super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool -class ManagementPolicyDefinition(msrest.serialization.Model): +class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. All required parameters must be populated in order to send to Azure. - :ivar actions: Required. An object that defines the action set. + :ivar actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyAction :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyFilter """ _validation = { - 'actions': {'required': True}, + "actions": {"required": True}, } _attribute_map = { - 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, - 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, } def __init__( @@ -4559,25 +4385,25 @@ def __init__( **kwargs ): """ - :keyword actions: Required. An object that defines the action set. + :keyword actions: An object that defines the action set. Required. :paramtype actions: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyAction :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyFilter """ - super(ManagementPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.filters = filters -class ManagementPolicyFilter(msrest.serialization.Model): +class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :ivar blob_types: An array of predefined enum values. Currently blockBlob supports all tiering + and delete actions. Only delete actions are supported for appendBlob. Required. :vartype blob_types: list[str] :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. @@ -4585,13 +4411,13 @@ class ManagementPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'blob_index_match': {'key': 'blobIndexMatch', 'type': '[TagFilter]'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "blob_index_match": {"key": "blobIndexMatch", "type": "[TagFilter]"}, } def __init__( @@ -4605,46 +4431,46 @@ def __init__( """ :keyword prefix_match: An array of strings for prefixes to be match. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :keyword blob_types: An array of predefined enum values. Currently blockBlob supports all + tiering and delete actions. Only delete actions are supported for appendBlob. Required. :paramtype blob_types: list[str] :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. :paramtype blob_index_match: list[~azure.mgmt.storage.v2021_09_01.models.TagFilter] """ - super(ManagementPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.blob_index_match = blob_index_match -class ManagementPolicyRule(msrest.serialization.Model): +class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. :ivar enabled: Rule is enabled if set to true. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" :vartype type: str or ~azure.mgmt.storage.v2021_09_01.models.RuleType - :ivar definition: Required. An object that defines the Lifecycle rule. + :ivar definition: An object that defines the Lifecycle rule. Required. :vartype definition: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyDefinition """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - 'definition': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, } def __init__( @@ -4659,55 +4485,52 @@ def __init__( """ :keyword enabled: Rule is enabled if set to true. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" :paramtype type: str or ~azure.mgmt.storage.v2021_09_01.models.RuleType - :keyword definition: Required. An object that defines the Lifecycle rule. + :keyword definition: An object that defines the Lifecycle rule. Required. :paramtype definition: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyDefinition """ - super(ManagementPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.type = type self.definition = definition -class ManagementPolicySchema(msrest.serialization.Model): +class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. All required parameters must be populated in order to send to Azure. - :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :vartype rules: list[~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyRule] """ _validation = { - 'rules': {'required': True}, + "rules": {"required": True}, } _attribute_map = { - 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, } - def __init__( - self, - *, - rules: List["_models.ManagementPolicyRule"], - **kwargs - ): + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): """ - :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :paramtype rules: list[~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyRule] """ - super(ManagementPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.rules = rules -class ManagementPolicySnapShot(msrest.serialization.Model): +class ManagementPolicySnapShot(_serialization.Model): """Management policy action for snapshot. :ivar tier_to_cool: The function to tier blob snapshot to cool storage. Support blob snapshot @@ -4721,9 +4544,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -4744,13 +4567,13 @@ def __init__( :keyword delete: The function to delete the blob snapshot. :paramtype delete: ~azure.mgmt.storage.v2021_09_01.models.DateAfterCreation """ - super(ManagementPolicySnapShot, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class ManagementPolicyVersion(msrest.serialization.Model): +class ManagementPolicyVersion(_serialization.Model): """Management policy action for blob version. :ivar tier_to_cool: The function to tier blob version to cool storage. Support blob version @@ -4764,9 +4587,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -4787,13 +4610,13 @@ def __init__( :keyword delete: The function to delete the blob version. :paramtype delete: ~azure.mgmt.storage.v2021_09_01.models.DateAfterCreation """ - super(ManagementPolicyVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -4817,15 +4640,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -4862,7 +4685,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -4874,7 +4697,7 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class Multichannel(msrest.serialization.Model): +class Multichannel(_serialization.Model): """Multichannel setting. Applies to Premium FileStorage only. :ivar enabled: Indicates whether multichannel is enabled. @@ -4882,32 +4705,27 @@ class Multichannel(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Indicates whether multichannel is enabled. :paramtype enabled: bool """ - super(Multichannel, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2021_09_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2021_09_01.models.ResourceAccessRule] @@ -4915,28 +4733,28 @@ class NetworkRuleSet(msrest.serialization.Model): :vartype virtual_network_rules: list[~azure.mgmt.storage.v2021_09_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2021_09_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2021_09_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'resource_access_rules': {'key': 'resourceAccessRules', 'type': '[ResourceAccessRule]'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "resource_access_rules": {"key": "resourceAccessRules", "type": "[ResourceAccessRule]"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, @@ -4946,7 +4764,7 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2021_09_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4956,11 +4774,11 @@ def __init__( list[~azure.mgmt.storage.v2021_09_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2021_09_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2021_09_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.resource_access_rules = resource_access_rules self.virtual_network_rules = virtual_network_rules @@ -4968,7 +4786,7 @@ def __init__( self.default_action = default_action -class ObjectReplicationPolicies(msrest.serialization.Model): +class ObjectReplicationPolicies(_serialization.Model): """List storage account object replication policies. :ivar value: The replication policy between two storage accounts. @@ -4976,20 +4794,15 @@ class ObjectReplicationPolicies(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ObjectReplicationPolicy]'}, + "value": {"key": "value", "type": "[ObjectReplicationPolicy]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ObjectReplicationPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs): """ :keyword value: The replication policy between two storage accounts. :paramtype value: list[~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy] """ - super(ObjectReplicationPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -5021,22 +4834,22 @@ class ObjectReplicationPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_id': {'readonly': True}, - 'enabled_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_id": {"readonly": True}, + "enabled_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, - 'enabled_time': {'key': 'properties.enabledTime', 'type': 'iso-8601'}, - 'source_account': {'key': 'properties.sourceAccount', 'type': 'str'}, - 'destination_account': {'key': 'properties.destinationAccount', 'type': 'str'}, - 'rules': {'key': 'properties.rules', 'type': '[ObjectReplicationPolicyRule]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "enabled_time": {"key": "properties.enabledTime", "type": "iso-8601"}, + "source_account": {"key": "properties.sourceAccount", "type": "str"}, + "destination_account": {"key": "properties.destinationAccount", "type": "str"}, + "rules": {"key": "properties.rules", "type": "[ObjectReplicationPolicyRule]"}, } def __init__( @@ -5057,7 +4870,7 @@ def __init__( :keyword rules: The storage account object replication rules. :paramtype rules: list[~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicyRule] """ - super(ObjectReplicationPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_id = None self.enabled_time = None self.source_account = source_account @@ -5065,7 +4878,7 @@ def __init__( self.rules = rules -class ObjectReplicationPolicyFilter(msrest.serialization.Model): +class ObjectReplicationPolicyFilter(_serialization.Model): """Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the filter. If multiple filters are defined, a logical AND is performed on all filters. :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin @@ -5077,17 +4890,11 @@ class ObjectReplicationPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'min_creation_time': {'key': 'minCreationTime', 'type': 'str'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "min_creation_time": {"key": "minCreationTime", "type": "str"}, } - def __init__( - self, - *, - prefix_match: Optional[List[str]] = None, - min_creation_time: Optional[str] = None, - **kwargs - ): + def __init__(self, *, prefix_match: Optional[List[str]] = None, min_creation_time: Optional[str] = None, **kwargs): """ :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. @@ -5096,12 +4903,12 @@ def __init__( It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. :paramtype min_creation_time: str """ - super(ObjectReplicationPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.min_creation_time = min_creation_time -class ObjectReplicationPolicyRule(msrest.serialization.Model): +class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. All required parameters must be populated in order to send to Azure. @@ -5109,24 +4916,24 @@ class ObjectReplicationPolicyRule(msrest.serialization.Model): :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :vartype rule_id: str - :ivar source_container: Required. Required. Source container name. + :ivar source_container: Required. Source container name. Required. :vartype source_container: str - :ivar destination_container: Required. Required. Destination container name. + :ivar destination_container: Required. Destination container name. Required. :vartype destination_container: str :ivar filters: Optional. An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicyFilter """ _validation = { - 'source_container': {'required': True}, - 'destination_container': {'required': True}, + "source_container": {"required": True}, + "destination_container": {"required": True}, } _attribute_map = { - 'rule_id': {'key': 'ruleId', 'type': 'str'}, - 'source_container': {'key': 'sourceContainer', 'type': 'str'}, - 'destination_container': {'key': 'destinationContainer', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': 'ObjectReplicationPolicyFilter'}, + "rule_id": {"key": "ruleId", "type": "str"}, + "source_container": {"key": "sourceContainer", "type": "str"}, + "destination_container": {"key": "destinationContainer", "type": "str"}, + "filters": {"key": "filters", "type": "ObjectReplicationPolicyFilter"}, } def __init__( @@ -5142,21 +4949,21 @@ def __init__( :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :paramtype rule_id: str - :keyword source_container: Required. Required. Source container name. + :keyword source_container: Required. Source container name. Required. :paramtype source_container: str - :keyword destination_container: Required. Required. Destination container name. + :keyword destination_container: Required. Destination container name. Required. :paramtype destination_container: str :keyword filters: Optional. An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicyFilter """ - super(ObjectReplicationPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.rule_id = rule_id self.source_container = source_container self.destination_container = destination_container self.filters = filters -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -5170,10 +4977,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -5195,14 +5002,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2021_09_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -5216,10 +5023,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -5241,14 +5048,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -5256,75 +5063,63 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2021_09_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PermissionScope(msrest.serialization.Model): +class PermissionScope(_serialization.Model): """PermissionScope. All required parameters must be populated in order to send to Azure. - :ivar permissions: Required. The permissions for the local user. Possible values include: Read - (r), Write (w), Delete (d), List (l), and Create (c). + :ivar permissions: The permissions for the local user. Possible values include: Read (r), Write + (w), Delete (d), List (l), and Create (c). Required. :vartype permissions: str - :ivar service: Required. The service used by the local user, e.g. blob, file. + :ivar service: The service used by the local user, e.g. blob, file. Required. :vartype service: str - :ivar resource_name: Required. The name of resource, normally the container name or the file - share name, used by the local user. + :ivar resource_name: The name of resource, normally the container name or the file share name, + used by the local user. Required. :vartype resource_name: str """ _validation = { - 'permissions': {'required': True}, - 'service': {'required': True}, - 'resource_name': {'required': True}, + "permissions": {"required": True}, + "service": {"required": True}, + "resource_name": {"required": True}, } _attribute_map = { - 'permissions': {'key': 'permissions', 'type': 'str'}, - 'service': {'key': 'service', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "permissions": {"key": "permissions", "type": "str"}, + "service": {"key": "service", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } - def __init__( - self, - *, - permissions: str, - service: str, - resource_name: str, - **kwargs - ): + def __init__(self, *, permissions: str, service: str, resource_name: str, **kwargs): """ - :keyword permissions: Required. The permissions for the local user. Possible values include: - Read (r), Write (w), Delete (d), List (l), and Create (c). + :keyword permissions: The permissions for the local user. Possible values include: Read (r), + Write (w), Delete (d), List (l), and Create (c). Required. :paramtype permissions: str - :keyword service: Required. The service used by the local user, e.g. blob, file. + :keyword service: The service used by the local user, e.g. blob, file. Required. :paramtype service: str - :keyword resource_name: Required. The name of resource, normally the container name or the file - share name, used by the local user. + :keyword resource_name: The name of resource, normally the container name or the file share + name, used by the local user. Required. :paramtype resource_name: str """ - super(PermissionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.permissions = permissions self.service = service self.resource_name = resource_name -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -5334,20 +5129,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -5371,25 +5162,28 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2021_09_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -5407,13 +5201,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.storage.v2021_09_01.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """List of private endpoint connection associated with the specified storage account. :ivar value: Array of private endpoint connections. @@ -5421,20 +5215,15 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -5460,39 +5249,34 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "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, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): """ :keyword required_zone_names: The private link resource Private link DNS zone name. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. @@ -5500,28 +5284,23 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.storage.v2021_09_01.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", and "Rejected". :vartype status: str or ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -5532,9 +5311,9 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'action_required': {'key': 'actionRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "action_required": {"key": "actionRequired", "type": "str"}, } def __init__( @@ -5547,7 +5326,7 @@ def __init__( ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", and "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -5556,13 +5335,13 @@ def __init__( updates on the consumer. :paramtype action_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.action_required = action_required -class ProtectedAppendWritesHistory(msrest.serialization.Model): +class ProtectedAppendWritesHistory(_serialization.Model): """Protected append writes history setting for the blob container with Legal holds. Variables are only populated by the server, and will be ignored when sending a request. @@ -5576,32 +5355,27 @@ class ProtectedAppendWritesHistory(msrest.serialization.Model): """ _validation = { - 'timestamp': {'readonly': True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - allow_protected_append_writes_all: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, allow_protected_append_writes_all: Optional[bool] = None, **kwargs): """ :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes_all: bool """ - super(ProtectedAppendWritesHistory, self).__init__(**kwargs) + super().__init__(**kwargs) self.allow_protected_append_writes_all = allow_protected_append_writes_all self.timestamp = None -class ProtocolSettings(msrest.serialization.Model): +class ProtocolSettings(_serialization.Model): """Protocol settings for file service. :ivar smb: Setting for SMB protocol. @@ -5609,20 +5383,15 @@ class ProtocolSettings(msrest.serialization.Model): """ _attribute_map = { - 'smb': {'key': 'smb', 'type': 'SmbSetting'}, + "smb": {"key": "smb", "type": "SmbSetting"}, } - def __init__( - self, - *, - smb: Optional["_models.SmbSetting"] = None, - **kwargs - ): + def __init__(self, *, smb: Optional["_models.SmbSetting"] = None, **kwargs): """ :keyword smb: Setting for SMB protocol. :paramtype smb: ~azure.mgmt.storage.v2021_09_01.models.SmbSetting """ - super(ProtocolSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.smb = smb @@ -5646,35 +5415,30 @@ class QueueServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Queue service. :paramtype cors: ~azure.mgmt.storage.v2021_09_01.models.CorsRules """ - super(QueueServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class ResourceAccessRule(msrest.serialization.Model): +class ResourceAccessRule(_serialization.Model): """Resource Access Rule. :ivar tenant_id: Tenant Id. @@ -5684,36 +5448,30 @@ class ResourceAccessRule(msrest.serialization.Model): """ _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__( - self, - *, - tenant_id: Optional[str] = None, - resource_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tenant_id: Optional[str] = None, resource_id: Optional[str] = None, **kwargs): """ :keyword tenant_id: Tenant Id. :paramtype tenant_id: str :keyword resource_id: Resource Id. :paramtype resource_id: str """ - super(ResourceAccessRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.tenant_id = tenant_id self.resource_id = resource_id -class RestorePolicyProperties(msrest.serialization.Model): +class RestorePolicyProperties(_serialization.Model): """The blob service properties for blob restore policy. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Blob restore is enabled if set to true. + :ivar enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool :ivar days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. @@ -5725,41 +5483,35 @@ class RestorePolicyProperties(msrest.serialization.Model): """ _validation = { - 'enabled': {'required': True}, - 'days': {'maximum': 365, 'minimum': 1}, - 'last_enabled_time': {'readonly': True}, - 'min_restore_time': {'readonly': True}, + "enabled": {"required": True}, + "days": {"maximum": 365, "minimum": 1}, + "last_enabled_time": {"readonly": True}, + "min_restore_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'min_restore_time': {'key': 'minRestoreTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "min_restore_time": {"key": "minRestoreTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: bool, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: bool, days: Optional[int] = None, **kwargs): """ - :keyword enabled: Required. Blob restore is enabled if set to true. + :keyword enabled: Blob restore is enabled if set to true. Required. :paramtype enabled: bool :keyword days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. :paramtype days: int """ - super(RestorePolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days self.last_enabled_time = None self.min_restore_time = None -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -5772,45 +5524,40 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2021_09_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2021_09_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class RoutingPreference(msrest.serialization.Model): +class RoutingPreference(_serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2021_09_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5821,9 +5568,9 @@ class RoutingPreference(msrest.serialization.Model): """ _attribute_map = { - 'routing_choice': {'key': 'routingChoice', 'type': 'str'}, - 'publish_microsoft_endpoints': {'key': 'publishMicrosoftEndpoints', 'type': 'bool'}, - 'publish_internet_endpoints': {'key': 'publishInternetEndpoints', 'type': 'bool'}, + "routing_choice": {"key": "routingChoice", "type": "str"}, + "publish_microsoft_endpoints": {"key": "publishMicrosoftEndpoints", "type": "bool"}, + "publish_internet_endpoints": {"key": "publishInternetEndpoints", "type": "bool"}, } def __init__( @@ -5836,7 +5583,7 @@ def __init__( ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2021_09_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5845,72 +5592,66 @@ def __init__( storage endpoints are to be published. :paramtype publish_internet_endpoints: bool """ - super(RoutingPreference, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_choice = routing_choice self.publish_microsoft_endpoints = publish_microsoft_endpoints self.publish_internet_endpoints = publish_internet_endpoints -class SasPolicy(msrest.serialization.Model): +class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :ivar sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str - :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :ivar expiration_action: The SAS expiration action. Can only be Log. "Log" :vartype expiration_action: str or ~azure.mgmt.storage.v2021_09_01.models.ExpirationAction """ _validation = { - 'sas_expiration_period': {'required': True}, - 'expiration_action': {'required': True}, + "sas_expiration_period": {"required": True}, + "expiration_action": {"required": True}, } _attribute_map = { - 'sas_expiration_period': {'key': 'sasExpirationPeriod', 'type': 'str'}, - 'expiration_action': {'key': 'expirationAction', 'type': 'str'}, + "sas_expiration_period": {"key": "sasExpirationPeriod", "type": "str"}, + "expiration_action": {"key": "expirationAction", "type": "str"}, } def __init__( - self, - *, - sas_expiration_period: str, - expiration_action: Union[str, "_models.ExpirationAction"] = "Log", - **kwargs + self, *, sas_expiration_period: str, expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs ): """ - :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :keyword sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :paramtype sas_expiration_period: str - :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :keyword expiration_action: The SAS expiration action. Can only be Log. "Log" :paramtype expiration_action: str or ~azure.mgmt.storage.v2021_09_01.models.ExpirationAction """ - super(SasPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_expiration_period = sas_expiration_period self.expiration_action = expiration_action -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2021_09_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2021_09_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2021_09_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -5942,29 +5683,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, - } - - _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, + } + + _attribute_map = { + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -5991,20 +5732,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2021_09_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2021_09_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2021_09_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -6035,7 +5777,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -6056,7 +5798,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -6065,25 +5807,20 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2021_09_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class SignedIdentifier(msrest.serialization.Model): +class SignedIdentifier(_serialization.Model): """SignedIdentifier. :ivar id: An unique identifier of the stored access policy. @@ -6093,14 +5830,14 @@ class SignedIdentifier(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'access_policy': {'key': 'accessPolicy', 'type': 'AccessPolicy'}, + "id": {"key": "id", "type": "str"}, + "access_policy": {"key": "accessPolicy", "type": "AccessPolicy"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin access_policy: Optional["_models.AccessPolicy"] = None, **kwargs ): @@ -6110,57 +5847,52 @@ def __init__( :keyword access_policy: Access policy. :paramtype access_policy: ~azure.mgmt.storage.v2021_09_01.models.AccessPolicy """ - super(SignedIdentifier, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.access_policy = access_policy -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_09_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -6173,45 +5905,41 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Storage SKU and its properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2021_09_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -6225,22 +5953,22 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -6251,16 +5979,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2021_09_01.models.Restriction] """ - super(SkuInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -6270,7 +5998,7 @@ def __init__( self.restrictions = restrictions -class SmbSetting(msrest.serialization.Model): +class SmbSetting(_serialization.Model): """Setting for SMB protocol. :ivar multichannel: Multichannel setting. Applies to Premium FileStorage only. @@ -6290,11 +6018,11 @@ class SmbSetting(msrest.serialization.Model): """ _attribute_map = { - 'multichannel': {'key': 'multichannel', 'type': 'Multichannel'}, - 'versions': {'key': 'versions', 'type': 'str'}, - 'authentication_methods': {'key': 'authenticationMethods', 'type': 'str'}, - 'kerberos_ticket_encryption': {'key': 'kerberosTicketEncryption', 'type': 'str'}, - 'channel_encryption': {'key': 'channelEncryption', 'type': 'str'}, + "multichannel": {"key": "multichannel", "type": "Multichannel"}, + "versions": {"key": "versions", "type": "str"}, + "authentication_methods": {"key": "authenticationMethods", "type": "str"}, + "kerberos_ticket_encryption": {"key": "kerberosTicketEncryption", "type": "str"}, + "channel_encryption": {"key": "channelEncryption", "type": "str"}, } def __init__( @@ -6323,7 +6051,7 @@ def __init__( AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. :paramtype channel_encryption: str """ - super(SmbSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.multichannel = multichannel self.versions = versions self.authentication_methods = authentication_methods @@ -6331,7 +6059,7 @@ def __init__( self.channel_encryption = channel_encryption -class SshPublicKey(msrest.serialization.Model): +class SshPublicKey(_serialization.Model): """SshPublicKey. :ivar description: Optional. It is used to store the function/usage of the key. @@ -6342,17 +6070,11 @@ class SshPublicKey(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - description: Optional[str] = None, - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, key: Optional[str] = None, **kwargs): """ :keyword description: Optional. It is used to store the function/usage of the key. :paramtype description: str @@ -6360,7 +6082,7 @@ def __init__( :code:``', e.g. ssh-rsa AAAABBBB. :paramtype key: str """ - super(SshPublicKey, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.key = key @@ -6380,46 +6102,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -6434,21 +6150,21 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2021_09_01.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_09_01.models.Identity :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2021_09_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2021_09_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -6457,7 +6173,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2021_09_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -6469,7 +6185,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2021_09_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -6491,7 +6207,7 @@ class StorageAccount(TrackedResource): :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Known values are: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6513,7 +6229,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -6530,7 +6246,7 @@ class StorageAccount(TrackedResource): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6546,7 +6262,7 @@ class StorageAccount(TrackedResource): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess @@ -6556,7 +6272,7 @@ class StorageAccount(TrackedResource): :vartype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_09_01.models.ImmutableStorageAccount :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :ivar storage_account_sku_conversion_status: This property is readOnly and is set by server during asynchronous storage account sku conversion operations. @@ -6565,90 +6281,102 @@ class StorageAccount(TrackedResource): :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values - are: "Standard", "AzureDnsZone". + are: "Standard" and "AzureDnsZone". :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'sas_policy': {'readonly': True}, - 'key_policy': {'readonly': True}, - 'key_creation_time': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'blob_restore_status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'key_creation_time': {'key': 'properties.keyCreationTime', 'type': 'KeyCreationTime'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, - 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'blob_restore_status': {'key': 'properties.blobRestoreStatus', 'type': 'BlobRestoreStatus'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, - 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, - 'storage_account_sku_conversion_status': {'key': 'properties.storageAccountSkuConversionStatus', 'type': 'StorageAccountSkuConversionStatus'}, - 'dns_endpoint_type': {'key': 'properties.dnsEndpointType', 'type': 'str'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "sas_policy": {"readonly": True}, + "key_policy": {"readonly": True}, + "key_creation_time": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "blob_restore_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "key_creation_time": {"key": "properties.keyCreationTime", "type": "KeyCreationTime"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "blob_restore_status": {"key": "properties.blobRestoreStatus", "type": "BlobRestoreStatus"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "storage_account_sku_conversion_status": { + "key": "properties.storageAccountSkuConversionStatus", + "type": "StorageAccountSkuConversionStatus", + }, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -6676,9 +6404,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_09_01.models.Identity @@ -6698,7 +6426,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6709,7 +6437,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6726,7 +6454,7 @@ def __init__( :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess :keyword immutable_storage_with_versioning: The property is immutable and can only be set to @@ -6735,7 +6463,7 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_09_01.models.ImmutableStorageAccount :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :keyword storage_account_sku_conversion_status: This property is readOnly and is set by server during asynchronous storage account sku conversion operations. @@ -6744,10 +6472,10 @@ def __init__( :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone - identifier. Known values are: "Standard", "AzureDnsZone". + identifier. Known values are: "Standard" and "AzureDnsZone". :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -6792,77 +6520,72 @@ def __init__( self.dns_endpoint_type = dns_endpoint_type -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2021_09_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str :ivar extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :vartype extended_location: ~azure.mgmt.storage.v2021_09_01.models.ExtendedLocation - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_09_01.models.Identity :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess @@ -6882,7 +6605,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Known values are: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6898,7 +6621,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6909,7 +6632,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6932,49 +6655,55 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values - are: "Standard", "AzureDnsZone". + are: "Standard" and "AzureDnsZone". :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, - 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, - 'dns_endpoint_type': {'key': 'properties.dnsEndpointType', 'type': 'str'}, - } - - def __init__( + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, sku: "_models.Sku", @@ -7009,33 +6738,33 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2021_09_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str :keyword extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :paramtype extended_location: ~azure.mgmt.storage.v2021_09_01.models.ExtendedLocation - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_09_01.models.Identity :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess :keyword sas_policy: SasPolicy assigned to the storage account. @@ -7054,7 +6783,7 @@ def __init__( :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Known values are: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7070,7 +6799,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -7081,7 +6810,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7104,10 +6833,10 @@ def __init__( :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone - identifier. Known values are: "Standard", "AzureDnsZone". + identifier. Known values are: "Standard" and "AzureDnsZone". :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -7139,7 +6868,7 @@ def __init__( self.dns_endpoint_type = dns_endpoint_type -class StorageAccountInternetEndpoints(msrest.serialization.Model): +class StorageAccountInternetEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -7155,33 +6884,29 @@ class StorageAccountInternetEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountInternetEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.file = None self.web = None self.dfs = None -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -7191,40 +6916,36 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2021_09_01.models.KeyPermission :ivar creation_time: Creation time of the key, in round trip date format. :vartype creation_time: ~datetime.datetime """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, - 'creation_time': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, + "creation_time": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None self.creation_time = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -7235,24 +6956,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -7265,27 +6982,23 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): +class StorageAccountMicrosoftEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -7305,30 +7018,26 @@ class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountMicrosoftEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -7337,51 +7046,46 @@ def __init__( self.dfs = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2, kerb1, kerb2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2, kerb1, kerb2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountSkuConversionStatus(msrest.serialization.Model): +class StorageAccountSkuConversionStatus(_serialization.Model): """This defines the sku conversion status object for asynchronous sku conversions. Variables are only populated by the server, and will be ignored when sending a request. :ivar sku_conversion_status: This property indicates the current sku conversion status. Known - values are: "InProgress", "Succeeded", "Failed". + values are: "InProgress", "Succeeded", and "Failed". :vartype sku_conversion_status: str or ~azure.mgmt.storage.v2021_09_01.models.SkuConversionStatus :ivar target_sku_name: This property represents the target sku name to which the account sku is being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", - "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", + "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", and "Standard_RAGZRS". :vartype target_sku_name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName :ivar start_time: This property represents the sku conversion start time. @@ -7391,54 +7095,49 @@ class StorageAccountSkuConversionStatus(msrest.serialization.Model): """ _validation = { - 'sku_conversion_status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, + "sku_conversion_status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, } _attribute_map = { - 'sku_conversion_status': {'key': 'skuConversionStatus', 'type': 'str'}, - 'target_sku_name': {'key': 'targetSkuName', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'str'}, + "sku_conversion_status": {"key": "skuConversionStatus", "type": "str"}, + "target_sku_name": {"key": "targetSkuName", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "end_time": {"key": "endTime", "type": "str"}, } - def __init__( - self, - *, - target_sku_name: Optional[Union[str, "_models.SkuName"]] = None, - **kwargs - ): + def __init__(self, *, target_sku_name: Optional[Union[str, "_models.SkuName"]] = None, **kwargs): """ :keyword target_sku_name: This property represents the target sku name to which the account sku is being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", - "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", + "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", and "Standard_RAGZRS". :paramtype target_sku_name: str or ~azure.mgmt.storage.v2021_09_01.models.SkuName """ - super(StorageAccountSkuConversionStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku_conversion_status = None self.target_sku_name = target_sku_name self.start_time = None self.end_time = None -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2021_09_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2021_09_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7454,7 +7153,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Known values are: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7469,7 +7168,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2021_09_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -7480,7 +7179,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7494,7 +7193,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess @@ -7504,44 +7203,50 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_09_01.models.ImmutableStorageAccount :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values - are: "Standard", "AzureDnsZone". + are: "Standard" and "AzureDnsZone". :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, - 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, - 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, - 'dns_endpoint_type': {'key': 'properties.dnsEndpointType', 'type': 'str'}, - } - - def __init__( + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, sku: Optional["_models.Sku"] = None, @@ -7576,16 +7281,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2021_09_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2021_09_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2021_09_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7601,7 +7306,7 @@ def __init__( :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Known values are: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2021_09_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7617,7 +7322,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2021_09_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2021_09_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -7628,7 +7333,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2021_09_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7643,7 +7348,7 @@ def __init__( :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2021_09_01.models.PublicNetworkAccess :keyword immutable_storage_with_versioning: The property is immutable and can only be set to @@ -7652,15 +7357,15 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2021_09_01.models.ImmutableStorageAccount :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2021_09_01.models.AllowedCopyScope :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone - identifier. Known values are: "Standard", "AzureDnsZone". + identifier. Known values are: "Standard" and "AzureDnsZone". :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2021_09_01.models.DnsEndpointType """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -7710,36 +7415,31 @@ class StorageQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'approximate_message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "approximate_message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'approximate_message_count': {'key': 'properties.approximateMessageCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "approximate_message_count": {"key": "properties.approximateMessageCount", "type": "int"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(StorageQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata self.approximate_message_count = None -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -7749,49 +7449,45 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuInformation]'}, + "value": {"key": "value", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2021_09_01.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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2021_09_01.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'}, + "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__( @@ -7809,19 +7505,19 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2021_09_01.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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2021_09_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -7850,37 +7546,32 @@ class Table(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'table_name': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "table_name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[TableSignedIdentifier]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[TableSignedIdentifier]"}, } - def __init__( - self, - *, - signed_identifiers: Optional[List["_models.TableSignedIdentifier"]] = None, - **kwargs - ): + def __init__(self, *, signed_identifiers: Optional[List["_models.TableSignedIdentifier"]] = None, **kwargs): """ :keyword signed_identifiers: List of stored access policies specified on the table. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2021_09_01.models.TableSignedIdentifier] """ - super(Table, self).__init__(**kwargs) + super().__init__(**kwargs) self.table_name = None self.signed_identifiers = signed_identifiers -class TableAccessPolicy(msrest.serialization.Model): +class TableAccessPolicy(_serialization.Model): """Table Access Policy Properties Object. All required parameters must be populated in order to send to Azure. @@ -7889,19 +7580,19 @@ class TableAccessPolicy(msrest.serialization.Model): :vartype start_time: ~datetime.datetime :ivar expiry_time: Expiry time of the access policy. :vartype expiry_time: ~datetime.datetime - :ivar permission: Required. Required. List of abbreviated permissions. Supported permission - values include 'r','a','u','d'. + :ivar permission: Required. List of abbreviated permissions. Supported permission values + include 'r','a','u','d'. Required. :vartype permission: str """ _validation = { - 'permission': {'required': True}, + "permission": {"required": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'permission': {'key': 'permission', 'type': 'str'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "permission": {"key": "permission", "type": "str"}, } def __init__( @@ -7917,11 +7608,11 @@ def __init__( :paramtype start_time: ~datetime.datetime :keyword expiry_time: Expiry time of the access policy. :paramtype expiry_time: ~datetime.datetime - :keyword permission: Required. Required. List of abbreviated permissions. Supported permission - values include 'r','a','u','d'. + :keyword permission: Required. List of abbreviated permissions. Supported permission values + include 'r','a','u','d'. Required. :paramtype permission: str """ - super(TableAccessPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_time = start_time self.expiry_time = expiry_time self.permission = permission @@ -7947,124 +7638,112 @@ class TableServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Table service. :paramtype cors: ~azure.mgmt.storage.v2021_09_01.models.CorsRules """ - super(TableServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class TableSignedIdentifier(msrest.serialization.Model): +class TableSignedIdentifier(_serialization.Model): """Object to set Table Access Policy. All required parameters must be populated in order to send to Azure. - :ivar id: Required. unique-64-character-value of the stored access policy. + :ivar id: unique-64-character-value of the stored access policy. Required. :vartype id: str :ivar access_policy: Access policy. :vartype access_policy: ~azure.mgmt.storage.v2021_09_01.models.TableAccessPolicy """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'access_policy': {'key': 'accessPolicy', 'type': 'TableAccessPolicy'}, + "id": {"key": "id", "type": "str"}, + "access_policy": {"key": "accessPolicy", "type": "TableAccessPolicy"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin access_policy: Optional["_models.TableAccessPolicy"] = None, **kwargs ): """ - :keyword id: Required. unique-64-character-value of the stored access policy. + :keyword id: unique-64-character-value of the stored access policy. Required. :paramtype id: str :keyword access_policy: Access policy. :paramtype access_policy: ~azure.mgmt.storage.v2021_09_01.models.TableAccessPolicy """ - super(TableSignedIdentifier, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.access_policy = access_policy -class TagFilter(msrest.serialization.Model): +class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. All required parameters must be populated in order to send to Azure. - :ivar name: Required. This is the filter tag name, it can have 1 - 128 characters. + :ivar name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str - :ivar op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :ivar op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :vartype op: str - :ivar value: Required. This is the filter tag value field used for tag based filtering, it can - have 0 - 256 characters. + :ivar value: This is the filter tag value field used for tag based filtering, it can have 0 - + 256 characters. Required. :vartype value: str """ _validation = { - 'name': {'required': True, 'max_length': 128, 'min_length': 1}, - 'op': {'required': True}, - 'value': {'required': True, 'max_length': 256, 'min_length': 0}, + "name": {"required": True, "max_length": 128, "min_length": 1}, + "op": {"required": True}, + "value": {"required": True, "max_length": 256}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'op': {'key': 'op', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "op": {"key": "op", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - op: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, op: str, value: str, **kwargs): """ - :keyword name: Required. This is the filter tag name, it can have 1 - 128 characters. + :keyword name: This is the filter tag name, it can have 1 - 128 characters. Required. :paramtype name: str - :keyword op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :keyword op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :paramtype op: str - :keyword value: Required. This is the filter tag value field used for tag based filtering, it - can have 0 - 256 characters. + :keyword value: This is the filter tag value field used for tag based filtering, it can have 0 + - 256 characters. Required. :paramtype value: str """ - super(TagFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.op = op self.value = value -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -8082,28 +7761,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -8111,13 +7786,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -8147,23 +7822,23 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -8188,7 +7863,7 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -8199,13 +7874,13 @@ def __init__( self.allow_protected_append_writes_all = allow_protected_append_writes_all -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2021_09_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -8216,33 +7891,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -8250,24 +7921,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2021_09_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -8279,27 +7945,23 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """UserAssignedIdentity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -8311,72 +7973,68 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", - "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2021_09_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", - "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2021_09_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py index 84932f4dc478..76b95640d0b1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/models/_storage_management_client_enums.py @@ -20,6 +20,7 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): COOL = "Cool" PREMIUM = "Premium" + class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the policy, Unlocked state allows increase and decrease of immutability retention time and also @@ -33,6 +34,7 @@ class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMet LOCKED = "Locked" DISABLED = "Disabled" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -41,13 +43,14 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class ActiveDirectoryPropertiesAccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the Active Directory account type for Azure Storage. - """ + """Specifies the Active Directory account type for Azure Storage.""" USER = "User" COMPUTER = "Computer" + class AllowedCopyScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet. @@ -56,10 +59,13 @@ class AllowedCopyScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): PRIVATE_LINK = "PrivateLink" AAD = "AAD" + class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobInventoryPolicyName.""" DEFAULT = "default" + class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - @@ -70,6 +76,7 @@ class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): COMPLETE = "Complete" FAILED = "Failed" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -81,7 +88,9 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """CorsRuleAllowedMethodsItem.""" DELETE = "DELETE" GET = "GET" @@ -92,39 +101,40 @@ class CorsRuleAllowedMethodsItem(str, Enum, metaclass=CaseInsensitiveEnumMeta): PUT = "PUT" PATCH = "PATCH" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default share permission for users using Kerberos authentication if RBAC role is not assigned. - """ + """Default share permission for users using Kerberos authentication if RBAC role is not assigned.""" NONE = "None" STORAGE_FILE_DATA_SMB_SHARE_READER = "StorageFileDataSmbShareReader" STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = "StorageFileDataSmbShareContributor" STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" + class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the directory service used. - """ + """Indicates the directory service used.""" NONE = "None" AADDS = "AADDS" AD = "AD" + class DnsEndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the @@ -134,6 +144,7 @@ class DnsEndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD = "Standard" AZURE_DNS_ZONE = "AzureDnsZone" + class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. @@ -142,6 +153,7 @@ class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): SMB = "SMB" NFS = "NFS" + class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. @@ -150,32 +162,33 @@ class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. - """ + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SAS expiration action. Can only be Log. - """ + """The SAS expiration action. Can only be Log.""" LOG = "Log" + class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation. - """ + """The type of extendedLocation.""" EDGE_ZONE = "EdgeZone" + class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is a required field, it specifies the format for the inventory files. - """ + """This is a required field, it specifies the format for the inventory files.""" CSV = "Csv" PARQUET = "Parquet" + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -188,29 +201,30 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type. - """ + """The identity type.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -220,27 +234,29 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Inventory - """ + """The valid value is Inventory.""" INVENTORY = "Inventory" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service @@ -250,9 +266,9 @@ class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SERVICE = "Service" ACCOUNT = "Account" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -260,22 +276,23 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - """ + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" + class LeaseContainerRequestAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -285,19 +302,19 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -305,21 +322,26 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListContainersInclude.""" DELETED = "deleted" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property denotes the container level immutability to object level immutability migration state. @@ -328,6 +350,7 @@ class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): IN_PROGRESS = "InProgress" COMPLETED = "Completed" + class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. @@ -337,12 +360,13 @@ class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" + class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only - """ + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only.""" ACCESS_TIME_TRACKING = "AccessTimeTracking" + class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field specifies the scope of the inventory created either at the blob or container level. @@ -351,6 +375,7 @@ class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): BLOB = "Blob" CONTAINER = "Container" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -365,39 +390,40 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state. - """ + """The current provisioning state.""" SUCCEEDED = "Succeeded" CREATING = "Creating" DELETING = "Deleting" FAILED = "Failed" + class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status. - """ + """The private endpoint connection status.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. @@ -406,6 +432,7 @@ class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): ENABLED = "Enabled" DISABLED = "Disabled" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -414,6 +441,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -424,34 +452,35 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The property is for NFS share only. The default is NoRootSquash. - """ + """The property is for NFS share only. The default is NoRootSquash.""" NO_ROOT_SQUASH = "NoRootSquash" ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" + class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Routing Choice defines the kind of network routing opted by the user. - """ + """Routing Choice defines the kind of network routing opted by the user.""" MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" + class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Lifecycle - """ + """The valid value is Lifecycle.""" LIFECYCLE = "Lifecycle" + class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is a required field. This field is used to schedule an inventory formation. - """ + """This is a required field. This field is used to schedule an inventory formation.""" DAILY = "Daily" WEEKLY = "Weekly" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -462,6 +491,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. @@ -472,6 +502,7 @@ class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): COOL = "Cool" PREMIUM = "Premium" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -482,6 +513,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -492,14 +524,15 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuConversionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property indicates the current sku conversion status. - """ + """This property indicates the current sku conversion status.""" IN_PROGRESS = "InProgress" SUCCEEDED = "Succeeded" FAILED = "Failed" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -514,16 +547,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SKU tier. This is based on the SKU name. - """ + """The SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "Provisioning" DEPROVISIONING = "Deprovisioning" @@ -531,14 +564,16 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "Failed" NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" + class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountExpand.""" GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/__init__.py index 22f9808d440a..b58975e023a9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/__init__.py @@ -30,27 +30,28 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'LocalUsersOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "LocalUsersOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_operations.py index d146683385d6..00bc63529d2c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_containers_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,13 +29,20 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -36,303 +50,253 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( @@ -341,50 +305,45 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( @@ -399,37 +358,36 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( @@ -444,36 +402,35 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -488,34 +445,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -525,132 +481,113 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_object_level_worm_request_initial( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any +def build_object_level_worm_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobContainersOperations: """ @@ -671,7 +608,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -679,18 +615,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> Iterable[_models.ListContainerItems]: + ) -> Iterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -699,35 +635,39 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2021_09_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -735,18 +675,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -763,10 +702,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -776,19 +713,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -796,37 +733,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -836,7 +860,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -844,10 +869,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -855,63 +879,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -921,7 +1031,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -929,72 +1040,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1002,72 +1109,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1075,10 +1178,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1088,16 +1190,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1105,37 +1208,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1145,7 +1335,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1153,80 +1344,166 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') - - request = build_clear_legal_hold_request( - resource_group_name=resource_group_name, - account_name=account_name, - container_name=container_name, - subscription_id=self._config.subscription_id, + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2021_09_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + request = build_clear_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1234,27 +1511,25 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, @@ -1262,22 +1537,24 @@ def create_or_update_immutability_policy( container_name: str, if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -1286,44 +1563,149 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy or IO + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: 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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1331,10 +1713,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1342,17 +1723,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1367,16 +1747,16 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -1387,32 +1767,34 @@ def get_immutability_policy( "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1420,10 +1802,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1431,26 +1812,20 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this @@ -1458,52 +1833,54 @@ def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1511,10 +1888,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1522,71 +1898,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1594,10 +1966,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1605,19 +1976,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1625,6 +1995,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1632,56 +2004,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1689,10 +2160,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1700,65 +2170,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1768,7 +2324,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1776,52 +2333,48 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_object_level_worm_request_initial( + request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata['url'], + template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1829,10 +2382,9 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1842,16 +2394,11 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore - + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace - def begin_object_level_worm( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> LROPoller[None]: """This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites require a container level immutability policy either in locked @@ -1859,16 +2406,16 @@ def begin_object_level_worm( # pylint: disable=inconsistent-return-statements on the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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. @@ -1880,53 +2427,48 @@ def begin_object_level_worm( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_operations.py index 9df37dbd9c00..c1314d6987dd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_inventory_policies_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,167 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - *, - json: Optional[_models.BlobInventoryPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobInventoryPoliciesOperations: """ @@ -207,52 +208,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -260,78 +262,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy 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 - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -339,71 +423,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -411,10 +495,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -424,51 +507,50 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -476,15 +558,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -501,10 +585,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -515,8 +597,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_operations.py index a4865acd736b..ca686d99d7bd 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_blob_services_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,134 +27,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -168,47 +164,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -216,15 +214,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -241,10 +241,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -254,56 +252,139 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties or IO + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: 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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -313,7 +394,8 @@ def set_service_properties( blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -321,72 +403,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -394,22 +473,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_operations.py index 384cb183eaf9..303a9cc50bf8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_deleted_accounts_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,81 +27,74 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_get_request( - deleted_account_name: str, - location: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(deleted_account_name: str, location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), - "location": _SERIALIZER.url("location", location, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "deletedAccountName": _SERIALIZER.url( + "deleted_account_name", deleted_account_name, "str", max_length=24, min_length=3 + ), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DeletedAccountsOperations: """ @@ -115,38 +115,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DeletedAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -154,13 +152,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -177,10 +179,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -191,48 +191,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace - def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,10 +235,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,12 +245,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_operations.py index e2c076749b2d..cf6671039184 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_encryption_scopes_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,181 +27,164 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_put_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EncryptionScopesOperations: """ @@ -215,14 +205,15 @@ def __init__(self, *args, **kwargs): 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 + @overload def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -230,47 +221,137 @@ def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -278,10 +359,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -290,73 +370,160 @@ def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace + @overload def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -364,10 +531,9 @@ def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,62 +541,59 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -438,10 +601,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,58 +611,54 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.EncryptionScopeListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -508,15 +666,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -533,10 +693,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -546,8 +704,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_operations.py index 2ef980142a62..92e8c38dc092 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.FileServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class FileServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,70 +205,152 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties or IO + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: 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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -287,7 +360,8 @@ def set_service_properties( file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +369,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +439,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_operations.py index 15448b525c26..c7c2e987ec7c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_file_shares_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -40,38 +54,37 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( @@ -80,95 +93,80 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: Optional[_models.FileShare] = None, - content: Any = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -184,37 +182,36 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -230,84 +227,73 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_restore_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.DeletedShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( @@ -316,48 +302,44 @@ def build_lease_request( share_name: str, subscription_id: str, *, - json: Optional[_models.LeaseShareRequest] = None, - content: Any = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class FileSharesOperations: """ @@ -378,7 +360,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -388,15 +369,15 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.FileShareItems]: + ) -> Iterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -409,32 +390,36 @@ def list( None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -442,18 +427,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -470,10 +454,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -483,13 +465,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, @@ -497,6 +477,8 @@ def create( share_name: str, file_share: _models.FileShare, expand: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -504,51 +486,147 @@ def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -556,10 +634,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -567,63 +644,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2021_09_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -633,7 +796,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -641,25 +805,23 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def get( @@ -674,16 +836,16 @@ def get( """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. Default value is None. @@ -692,31 +854,33 @@ def get( None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -724,25 +888,23 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -757,16 +919,16 @@ def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str @@ -775,34 +937,37 @@ def delete( # pylint: disable=inconsistent-return-statements snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the - file share contains any snapshots (leased or unleased), the deletion fails. + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. :type include: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -810,10 +975,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -823,52 +987,135 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace + @overload def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2021_09_01.models.DeletedShare + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2021_09_01.models.DeletedShare 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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -878,7 +1125,8 @@ def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -886,10 +1134,9 @@ def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -899,10 +1146,9 @@ def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - @distributed_trace + @overload def lease( self, resource_group_name: str, @@ -910,60 +1156,156 @@ def lease( share_name: str, x_ms_snapshot: Optional[str] = None, parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse, or the result of cls(response) + :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseShareResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseShareRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, api_version=api_version, content_type=content_type, json=_json, - x_ms_snapshot=x_ms_snapshot, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -971,10 +1313,9 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -982,14 +1323,13 @@ def lease( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_operations.py index c5d6fede8671..a557775338a8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_local_users_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,251 +27,223 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - *, - json: Optional[_models.LocalUser] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_password_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class LocalUsersOperations: """ @@ -285,47 +264,45 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.LocalUsers]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.LocalUser"]: """List the local users associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 LocalUsers or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.LocalUsers] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LocalUser or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.LocalUser] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUsers] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -333,15 +310,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -358,10 +337,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -372,56 +349,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any - ) -> _models.LocalUser: + def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -429,10 +400,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -440,67 +410,148 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, username: str, properties: _models.LocalUser, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str - :param properties: The local user associated with a storage account. + :param properties: The local user associated with a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_09_01.models.LocalUser + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: IO + :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: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: Union[_models.LocalUser, IO], + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Is either a model type or + a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.LocalUser 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 + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - _json = self._serialize.body(properties, 'LocalUser') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalUser") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -508,10 +559,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -519,60 +569,57 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> None: """Deletes the local user associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -580,10 +627,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -594,53 +640,50 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserKeys: """List SSH authorized keys and shared key of the local user. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserKeys, or the result of cls(response) + :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -648,10 +691,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -659,60 +701,57 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserKeys', pipeline_response) + deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore @distributed_trace def regenerate_password( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserRegeneratePasswordResult: """Regenerate the local user SSH password. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserRegeneratePasswordResult, or the result of cls(response) + :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.LocalUserRegeneratePasswordResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] - request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata['url'], + template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) @@ -720,10 +759,9 @@ def regenerate_password( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -731,12 +769,11 @@ def regenerate_password( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserRegeneratePasswordResult', pipeline_response) + deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore - + regenerate_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_operations.py index d0225e59df8a..539de987b761 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,130 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,52 +169,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -215,78 +223,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy 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 - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -294,71 +384,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2021_09_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -366,10 +456,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +468,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_operations.py index 230056334db6..6760772ed5fc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_object_replication_policies_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,161 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - *, - json: Optional[_models.ObjectReplicationPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ObjectReplicationPoliciesOperations: """ @@ -207,49 +202,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +252,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +279,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -296,58 +291,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -355,10 +346,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -366,70 +356,156 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy 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 - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -437,10 +513,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -448,62 +523,59 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -511,10 +583,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -525,5 +596,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_operations.py index 489380c929cd..a2fcb35f3e84 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_endpoint_connections_operations.py index 51296ec70728..62e09301d940 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,173 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -207,49 +214,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +264,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +291,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,56 +302,52 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -352,10 +355,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,67 +365,148 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace + @overload def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection 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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -431,10 +514,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,60 +524,57 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -503,10 +582,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -517,5 +595,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_link_resources_operations.py index 497cef43fd00..2797eafda337 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,52 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_storage_account_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,46 +91,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -128,22 +136,20 @@ def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_operations.py index cd07d16df39a..6782efac59a3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,183 +27,188 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( @@ -211,36 +223,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueOperations: """ @@ -261,60 +273,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -322,79 +419,163 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -402,72 +583,66 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.StorageQueue: + def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -475,72 +650,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -548,10 +719,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -561,8 +731,7 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -572,15 +741,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.ListQueueResource]: + ) -> Iterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -589,31 +758,35 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -621,17 +794,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -648,10 +821,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -661,8 +832,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_operations.py index e4b9a0c85491..d34300441bb4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_queue_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.QueueServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,70 +205,153 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties or IO + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: 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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -287,7 +361,8 @@ def set_service_properties( queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +370,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +440,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_operations.py index 6735b0daa110..b8c4855e813e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_operations.py index 218fd3bbcce4..1f7eb228fbf0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +29,110 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,153 +140,129 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -304,357 +270,305 @@ def build_list_keys_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "kerb", + expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_hierarchical_namespace_migration_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - request_type: str, - **kwargs: Any +def build_hierarchical_namespace_migration_request( + resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['requestType'] = _SERIALIZER.query("request_type", request_type, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["requestType"] = _SERIALIZER.query("request_type", request_type, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_abort_hierarchical_namespace_migration_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_abort_hierarchical_namespace_migration_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_blob_ranges_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobRestoreParameters] = None, - content: Any = None, - **kwargs: Any + +def build_restore_blob_ranges_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revoke_user_delegation_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: # pylint: disable=too-many-public-methods """ @@ -675,45 +589,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2021_09_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -721,55 +688,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -777,10 +752,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -789,22 +763,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -813,14 +788,17 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCreateParameters + :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 @@ -832,20 +810,98 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -853,79 +909,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -933,10 +984,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -946,15 +996,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -962,40 +1011,43 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2021_09_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -1003,32 +1055,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1041,32 +1093,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountUpdateParameters + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1075,7 +1212,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1083,58 +1221,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1142,13 +1277,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1165,10 +1304,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1178,49 +1315,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1228,14 +1361,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1252,10 +1388,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1265,57 +1399,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1323,65 +1453,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2021_09_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1390,7 +1593,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1398,63 +1602,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.AccountSasParameters 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 - :return: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1463,7 +1740,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1471,63 +1749,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.ServiceSasParameters 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 - :return: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1536,7 +1885,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1544,50 +1894,47 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1595,10 +1942,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1608,26 +1954,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1639,82 +1979,75 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_hierarchical_namespace_migration_request_initial( + request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, request_type=request_type, - template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + api_version=api_version, + template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1722,43 +2055,38 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - + _hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace - def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> LROPoller[None]: """Live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param request_type: Required. Hierarchical namespace migration type can either be a hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the - hydration request will migrate the account. + hydration request will migrate the account. Required. :type request_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. @@ -1770,81 +2098,75 @@ def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-retu 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + begin_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_abort_hierarchical_namespace_migration_request_initial( + request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1852,37 +2174,33 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore - + _abort_hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + def begin_abort_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Abort live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1894,85 +2212,90 @@ def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsisten 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1980,10 +2303,9 @@ def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1991,38 +2313,117 @@ def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace + @overload def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.BlobRestoreParameters 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 @@ -2034,20 +2435,17 @@ def begin_restore_blob_ranges( :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2021_09_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -2055,79 +2453,76 @@ def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -2135,10 +2530,9 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2148,5 +2542,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_operations.py index a975b6cbd892..3a1e7cc738f6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,220 +27,200 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - *, - json: Optional[_models.Table] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - *, - json: Optional[_models.Table] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableOperations: """ @@ -254,62 +241,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def create( self, resource_group_name: str, account_name: str, table_name: str, parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table 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 - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - if parameters is not None: - _json = self._serialize.body(parameters, 'Table') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -317,81 +387,163 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, table_name: str, parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.Table 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 - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - if parameters is not None: - _json = self._serialize.body(parameters, 'Table') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -399,71 +551,65 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -471,71 +617,67 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -543,10 +685,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -556,49 +697,47 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -606,15 +745,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -631,10 +772,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -644,8 +783,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_operations.py index 6d129544cdfa..54b36632c12f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_table_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.TableServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,70 +205,153 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties or IO + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: 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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -287,7 +361,8 @@ def set_service_properties( table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +370,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2021_09_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +440,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_operations.py index 0b404a62faea..06527d161a77 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2021_09_01/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,41 +87,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2021_09_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2021-09-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2021-09-01")) # type: Literal["2021-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -122,14 +128,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -146,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -159,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/__init__.py index 317c71b53775..2ded28c1cc6a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/__init__.py @@ -17,7 +17,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_configuration.py index dce8613e5ba5..c0c960c234bc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from ._version import VERSION +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 from azure.core.credentials import TokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-05-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: + def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-05-01") # type: str + api_version = kwargs.pop("api_version", "2022-05-01") # type: Literal["2022-05-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,23 +52,24 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) def _configure( - self, - **kwargs # type: Any + self, **kwargs # type: Any ): # type: (...) -> None - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json index dec2d3cd88d4..1bdf8b40217a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_metadata.json @@ -10,20 +10,20 @@ "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"]}, \"thirdparty\": {\"msrest\": [\"Deserializer\", \"Serializer\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "global_parameters": { "sync": { "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials.TokenCredential", "required": true }, "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "The ID of the target subscription.", + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -31,13 +31,13 @@ "async": { "credential": { "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", + "description": "Credential needed for the client to connect to Azure. Required.", "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", "required": true }, "subscription_id": { "signature": "subscription_id: str,", - "description": "The ID of the target subscription.", + "description": "The ID of the target subscription. Required.", "docstring_type": "str", "required": true } @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=\"https://management.azure.com\", # type: str", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -118,4 +118,4 @@ "table_services": "TableServicesOperations", "table": "TableOperations" } -} \ No newline at end of file +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py index c1d123697fce..15363d9fdaf1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_storage_management_client.py @@ -9,20 +9,41 @@ from copy import deepcopy from typing import Any, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from . import models +from .._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, LocalUsersOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + LocalUsersOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials import TokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -71,9 +92,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2022_05_01.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2022_05_01.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -91,28 +112,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -128,43 +145,20 @@ def __init__( self.object_replication_policies = ObjectReplicationPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.local_users = LocalUsersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> HttpResponse: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -173,7 +167,7 @@ def _send_request( >>> response = client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_vendor.py index 138f663c53a4..9aad73fc743e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_vendor.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_vendor.py @@ -7,6 +7,7 @@ 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) @@ -14,6 +15,7 @@ def _convert_request(request, files=None): request.set_formdata_body(files) return request + def _format_url_section(template, **kwargs): components = template.split("/") while components: @@ -21,7 +23,5 @@ def _format_url_section(template, **kwargs): return template.format(**kwargs) except KeyError as key: formatted_components = template.split("/") - components = [ - c for c in formatted_components if "{}".format(key.args[0]) not in c - ] + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py index aee9e7ff7ef2..bb46423cd61e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "20.1.0" +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/__init__.py index d763454b9494..1bb98744d937 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/__init__.py @@ -14,7 +14,10 @@ except ImportError: _patch_all = [] from ._patch import patch_sdk as _patch_sdk -__all__ = ['StorageManagementClient'] + +__all__ = [ + "StorageManagementClient", +] __all__.extend([p for p in _patch_all if p not in __all__]) _patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_configuration.py index 9ec42f7e94a0..4819d0e747b4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_configuration.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_configuration.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import sys from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration @@ -14,6 +15,11 @@ from .._version import VERSION +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 from azure.core.credentials_async import AsyncTokenCredential @@ -25,23 +31,18 @@ class StorageManagementClientConfiguration(Configuration): # pylint: disable=to Note that all parameters used to create this instance are saved as instance attributes. - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :keyword api_version: Api Version. Default value is "2022-05-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: + def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None: super(StorageManagementClientConfiguration, self).__init__(**kwargs) - api_version = kwargs.pop('api_version', "2022-05-01") # type: str + api_version = kwargs.pop("api_version", "2022-05-01") # type: Literal["2022-05-01"] if credential is None: raise ValueError("Parameter 'credential' must not be None.") @@ -51,22 +52,21 @@ def __init__( self.credential = credential self.subscription_id = subscription_id self.api_version = api_version - self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) - kwargs.setdefault('sdk_moniker', 'mgmt-storage/{}'.format(VERSION)) + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) self._configure(**kwargs) - def _configure( - self, - **kwargs: Any - ) -> None: - self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) - self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) - self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) - self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) - self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) - self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) - self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) - self.authentication_policy = kwargs.get('authentication_policy') + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") if self.credential and not self.authentication_policy: - self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py index b4faeb5a4346..8490b6ec82ea 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/_storage_management_client.py @@ -9,20 +9,41 @@ from copy import deepcopy from typing import Any, Awaitable, TYPE_CHECKING -from msrest import Deserializer, Serializer - from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from .. import models +from ..._serialization import Deserializer, Serializer from ._configuration import StorageManagementClientConfiguration -from .operations import BlobContainersOperations, BlobInventoryPoliciesOperations, BlobServicesOperations, DeletedAccountsOperations, EncryptionScopesOperations, FileServicesOperations, FileSharesOperations, LocalUsersOperations, ManagementPoliciesOperations, ObjectReplicationPoliciesOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, QueueOperations, QueueServicesOperations, SkusOperations, StorageAccountsOperations, TableOperations, TableServicesOperations, UsagesOperations +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + LocalUsersOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -class StorageManagementClient: # pylint: disable=too-many-instance-attributes + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes """The Azure Storage Management API. :ivar operations: Operations operations @@ -74,9 +95,9 @@ class StorageManagementClient: # pylint: disable=too-many-instance-attributes :vartype table_services: azure.mgmt.storage.v2022_05_01.aio.operations.TableServicesOperations :ivar table: TableOperations operations :vartype table: azure.mgmt.storage.v2022_05_01.aio.operations.TableOperations - :param credential: Credential needed for the client to connect to Azure. + :param credential: Credential needed for the client to connect to Azure. Required. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: The ID of the target subscription. + :param subscription_id: The ID of the target subscription. Required. :type subscription_id: str :param base_url: Service URL. Default value is "https://management.azure.com". :type base_url: str @@ -94,28 +115,24 @@ def __init__( base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - self._config = StorageManagementClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) self._deserialize = Deserializer(client_models) self._serialize.client_side_validation = False - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize - ) - self.skus = SkusOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) self.storage_accounts = StorageAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) self.deleted_accounts = DeletedAccountsOperations( self._client, self._config, self._serialize, self._deserialize ) - self.usages = UsagesOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) self.management_policies = ManagementPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -131,43 +148,20 @@ def __init__( self.object_replication_policies = ObjectReplicationPoliciesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.local_users = LocalUsersOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) self.encryption_scopes = EncryptionScopesOperations( self._client, self._config, self._serialize, self._deserialize ) - self.blob_services = BlobServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.blob_containers = BlobContainersOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_services = FileServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.file_shares = FileSharesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue_services = QueueServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.queue = QueueOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table_services = TableServicesOperations( - self._client, self._config, self._serialize, self._deserialize - ) - self.table = TableOperations( - self._client, self._config, self._serialize, self._deserialize - ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) - - def _send_request( - self, - request: HttpRequest, - **kwargs: Any - ) -> Awaitable[AsyncHttpResponse]: + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest @@ -176,7 +170,7 @@ def _send_request( >>> response = await client._send_request(request) - For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/__init__.py index 22f9808d440a..b58975e023a9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/__init__.py @@ -30,27 +30,28 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'LocalUsersOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "LocalUsersOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_operations.py index cac3e69eb52e..df7b34471afb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_containers_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,31 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_containers_operations import build_clear_legal_hold_request, build_create_or_update_immutability_policy_request, build_create_request, build_delete_immutability_policy_request, build_delete_request, build_extend_immutability_policy_request, build_get_immutability_policy_request, build_get_request, build_lease_request, build_list_request, build_lock_immutability_policy_request, build_object_level_worm_request_initial, build_set_legal_hold_request, build_update_request -T = TypeVar('T') +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_object_level_worm_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobContainersOperations: """ .. warning:: @@ -45,7 +75,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,18 +82,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListContainerItems]: + ) -> AsyncIterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -73,36 +102,40 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2022_05_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) + :return: An iterator like instance of either ListContainerItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -110,18 +143,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -138,10 +170,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -151,19 +181,19 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -171,37 +201,124 @@ async def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -211,7 +328,8 @@ async def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -219,10 +337,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -230,63 +347,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -296,7 +499,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -304,72 +508,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -377,72 +577,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -450,10 +646,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -463,16 +658,17 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - @distributed_trace_async + @overload async def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -480,37 +676,124 @@ async def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -520,7 +803,8 @@ async def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -528,70 +812,155 @@ async def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace_async + @overload async def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_clear_legal_hold_request( resource_group_name=resource_group_name, @@ -601,7 +970,8 @@ async def clear_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -609,27 +979,25 @@ async def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update_immutability_policy( self, resource_group_name: str, @@ -637,22 +1005,24 @@ async def create_or_update_immutability_policy( container_name: str, if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -661,44 +1031,149 @@ async def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy or IO :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: 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: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -706,10 +1181,9 @@ async def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -717,17 +1191,16 @@ async def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def get_immutability_policy( @@ -742,16 +1215,16 @@ async def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -762,32 +1235,34 @@ async def get_immutability_policy( "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -795,10 +1270,9 @@ async def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -806,26 +1280,20 @@ async def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def delete_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this @@ -833,52 +1301,54 @@ async def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -886,10 +1356,9 @@ async def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -897,71 +1366,67 @@ async def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace_async async def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -969,10 +1434,9 @@ async def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -980,19 +1444,18 @@ async def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace_async + @overload async def extend_immutability_policy( self, resource_group_name: str, @@ -1000,6 +1463,8 @@ async def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1007,56 +1472,155 @@ async def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1064,10 +1628,9 @@ async def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1075,65 +1638,151 @@ async def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1143,7 +1792,8 @@ async def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1151,52 +1801,48 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_object_level_worm_request_initial( + request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata['url'], + template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1204,10 +1850,9 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1217,16 +1862,11 @@ async def _object_level_worm_initial( # pylint: disable=inconsistent-return-sta if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore - + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace_async - async def begin_object_level_worm( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + async def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites require a container level immutability policy either in locked @@ -1234,16 +1874,16 @@ async def begin_object_level_worm( # pylint: disable=inconsistent-return-statem on the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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. @@ -1255,53 +1895,48 @@ async def begin_object_level_worm( # pylint: disable=inconsistent-return-statem 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_operations.py index d3dfc9a81cf0..3eb063c5b5c9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_inventory_policies_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_inventory_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._blob_inventory_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobInventoryPoliciesOperations: """ .. warning:: @@ -43,52 +63,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -96,78 +117,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy 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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -175,71 +278,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -247,10 +350,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -260,51 +362,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -312,15 +413,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -337,10 +440,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -351,8 +452,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_operations.py index 18e45f665e30..ca365a7866e2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_blob_services_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._blob_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class BlobServicesOperations: """ .. warning:: @@ -43,48 +62,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -130,56 +150,139 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties or IO + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: 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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -189,7 +292,8 @@ async def set_service_properties( blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -197,72 +301,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -270,22 +371,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_operations.py index 8bcd18e42483..683c10b391b5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_deleted_accounts_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -21,9 +30,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._deleted_accounts_operations import build_get_request, build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class DeletedAccountsOperations: """ .. warning:: @@ -43,38 +58,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) + :return: An iterator like instance of either DeletedAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -82,13 +96,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -105,10 +123,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -119,48 +135,43 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace_async - async def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -168,10 +179,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -179,12 +189,11 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_operations.py index d7d3923acc59..86a45f77bc01 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_encryption_scopes_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._encryption_scopes_operations import build_get_request, build_list_request, build_patch_request, build_put_request -T = TypeVar('T') +from ...operations._encryption_scopes_operations import ( + build_get_request, + build_list_request, + build_patch_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class EncryptionScopesOperations: """ .. warning:: @@ -43,14 +63,15 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -58,47 +79,137 @@ async def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -106,10 +217,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -118,73 +228,160 @@ async def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace_async + @overload async def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -192,10 +389,9 @@ async def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -203,62 +399,59 @@ async def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -266,10 +459,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -277,58 +469,57 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.EncryptionScopeListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) + :return: An iterator like instance of either EncryptionScope or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -336,15 +527,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -361,10 +554,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -374,8 +565,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_operations.py index fcd6a55b3791..9eecdc186fda 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,70 +102,152 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties or IO + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: 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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -161,7 +257,8 @@ async def set_service_properties( file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +266,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +336,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_operations.py index 0c3b201ef2e9..408ef2b2a923 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_file_shares_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,24 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._file_shares_operations import build_create_request, build_delete_request, build_get_request, build_lease_request, build_list_request, build_restore_request, build_update_request -T = TypeVar('T') +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_lease_request, + build_list_request, + build_restore_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class FileSharesOperations: """ .. warning:: @@ -43,7 +66,6 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -53,15 +75,15 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.FileShareItems]: + ) -> AsyncIterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -74,33 +96,37 @@ def list( None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) + :return: An iterator like instance of either FileShareItem or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -108,18 +134,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -136,10 +161,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -149,13 +172,11 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace_async + @overload async def create( self, resource_group_name: str, @@ -163,6 +184,8 @@ async def create( share_name: str, file_share: _models.FileShare, expand: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -170,51 +193,147 @@ async def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -222,10 +341,9 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -233,63 +351,149 @@ async def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare 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 - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -299,7 +503,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -307,25 +512,23 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def get( @@ -340,16 +543,16 @@ async def get( """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. Default value is None. @@ -358,31 +561,33 @@ async def get( None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -390,25 +595,23 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements @@ -423,16 +626,16 @@ async def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str @@ -441,34 +644,37 @@ async def delete( # pylint: disable=inconsistent-return-statements snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the - file share contains any snapshots (leased or unleased), the deletion fails. + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. :type include: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -476,10 +682,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -489,52 +694,135 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace_async + @overload async def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2022_05_01.models.DeletedShare + :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: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2022_05_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -544,7 +832,8 @@ async def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -552,10 +841,9 @@ async def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -565,10 +853,9 @@ async def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - - @distributed_trace_async + @overload async def lease( self, resource_group_name: str, @@ -576,60 +863,156 @@ async def lease( share_name: str, x_ms_snapshot: Optional[str] = None, parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse, or the result of cls(response) + :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseShareResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseShareRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, api_version=api_version, content_type=content_type, json=_json, - x_ms_snapshot=x_ms_snapshot, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -637,10 +1020,9 @@ async def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -648,14 +1030,13 @@ async def lease( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_operations.py index ff765c42b371..8711905087cc 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_local_users_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,23 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._local_users_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_keys_request, build_list_request, build_regenerate_password_request -T = TypeVar('T') +from ...operations._local_users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_keys_request, + build_list_request, + build_regenerate_password_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class LocalUsersOperations: """ .. warning:: @@ -43,48 +65,46 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.LocalUsers]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.LocalUser"]: """List the local users associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 LocalUsers or the result of cls(response) + :return: An iterator like instance of either LocalUser or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.LocalUsers] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.LocalUser] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUsers] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -92,15 +112,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -117,10 +139,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +151,50 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any - ) -> _models.LocalUser: + async def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +202,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +212,148 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, username: str, properties: _models.LocalUser, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str - :param properties: The local user associated with a storage account. + :param properties: The local user associated with a storage account. Required. :type properties: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: IO + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: Union[_models.LocalUser, IO], + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Is either a model type or + a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.LocalUser 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 - :return: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - _json = self._serialize.body(properties, 'LocalUser') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalUser") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +361,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +371,57 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> None: """Deletes the local user associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +429,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,53 +442,50 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserKeys: """List SSH authorized keys and shared key of the local user. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserKeys, or the result of cls(response) + :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -407,10 +493,9 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -418,60 +503,57 @@ async def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserKeys', pipeline_response) + deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore @distributed_trace_async async def regenerate_password( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserRegeneratePasswordResult: """Regenerate the local user SSH password. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserRegeneratePasswordResult, or the result of cls(response) + :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserRegeneratePasswordResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] - request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata['url'], + template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) @@ -479,10 +561,9 @@ async def regenerate_password( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -490,12 +571,11 @@ async def regenerate_password( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserRegeneratePasswordResult', pipeline_response) + deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore - + regenerate_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_operations.py index af57d193439e..d80e30e8f6bf 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_management_policies_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar, Union - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._management_policies_operations import build_create_or_update_request, build_delete_request, build_get_request -T = TypeVar('T') +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ManagementPoliciesOperations: """ .. warning:: @@ -41,52 +59,53 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -94,78 +113,160 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :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: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -173,71 +274,71 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -245,10 +346,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -258,5 +358,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_operations.py index b2528239279b..be6d8b429a0b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_object_replication_policies_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._object_replication_policies_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request -T = TypeVar('T') +from ...operations._object_replication_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class ObjectReplicationPoliciesOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -132,58 +152,54 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -191,10 +207,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -202,70 +217,156 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - - @distributed_trace_async + @overload async def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy 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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -273,10 +374,9 @@ async def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -284,62 +384,59 @@ async def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -347,10 +444,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -361,5 +457,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_operations.py index 7db82693bbb5..8221db896277 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class Operations: """ .. warning:: @@ -42,36 +57,36 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) + :return: An iterator like instance of either Operation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -79,12 +94,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -101,10 +121,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -114,8 +132,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py index 41df15d6ebe0..6384ebfd01d9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_endpoint_connections_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,21 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._private_endpoint_connections_operations import build_delete_request, build_get_request, build_list_request, build_put_request -T = TypeVar('T') +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateEndpointConnectionsOperations: """ .. warning:: @@ -43,49 +63,49 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -93,15 +113,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -118,10 +140,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -131,56 +151,52 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -188,10 +204,9 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -199,67 +214,148 @@ async def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace_async + @overload async def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection 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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -267,10 +363,9 @@ async def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -278,60 +373,57 @@ async def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -339,10 +431,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -353,5 +444,4 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_link_resources_operations.py index 35c74205aa51..ad6fafbfc1d2 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_private_link_resources_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -19,9 +27,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._private_link_resources_operations import build_list_by_storage_account_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class PrivateLinkResourcesOperations: """ .. warning:: @@ -41,46 +55,44 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async async def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -88,22 +100,20 @@ async def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_operations.py index 3c74965b65dc..c56160177ef0 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._queue_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueOperations: """ .. warning:: @@ -43,60 +64,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue 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 - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -104,79 +210,163 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -184,72 +374,68 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -257,72 +443,68 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -330,10 +512,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -343,8 +524,7 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -354,15 +534,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> AsyncIterable[_models.ListQueueResource]: + ) -> AsyncIterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -371,32 +551,36 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) + :return: An iterator like instance of either ListQueue or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -404,17 +588,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -431,10 +615,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -444,8 +626,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_operations.py index 0221af40d5f7..034d8c02ed9e 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_queue_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._queue_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._queue_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class QueueServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,70 +102,153 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties or IO + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: 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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -161,7 +258,8 @@ async def set_service_properties( queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +267,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +337,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_operations.py index 374090c9d158..9d47e862016c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_skus_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._skus_operations import build_list_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class SkusOperations: """ .. warning:: @@ -42,38 +57,37 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) + :return: An iterator like instance of either SkuInformation or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -81,13 +95,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -104,10 +122,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -117,8 +133,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_operations.py index 5a893526bef2..b28d5bb839ff 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_storage_accounts_operations.py @@ -6,10 +6,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar, Union, cast +import sys +from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod @@ -22,10 +31,33 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._storage_accounts_operations import build_abort_hierarchical_namespace_migration_request_initial, build_check_name_availability_request, build_create_request_initial, build_delete_request, build_failover_request_initial, build_get_properties_request, build_hierarchical_namespace_migration_request_initial, build_list_account_sas_request, build_list_by_resource_group_request, build_list_keys_request, build_list_request, build_list_service_sas_request, build_regenerate_key_request, build_restore_blob_ranges_request_initial, build_revoke_user_delegation_keys_request, build_update_request -T = TypeVar('T') +from ...operations._storage_accounts_operations import ( + build_abort_hierarchical_namespace_migration_request, + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_hierarchical_namespace_migration_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_restore_blob_ranges_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class StorageAccountsOperations: # pylint: disable=too-many-public-methods """ .. warning:: @@ -45,45 +77,98 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2022_05_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -91,55 +176,63 @@ async def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore async def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -147,10 +240,9 @@ async def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -159,22 +251,23 @@ async def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -183,14 +276,17 @@ async def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCreateParameters + :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 @@ -203,20 +299,100 @@ async def begin_create( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCreateParameters 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. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -224,79 +400,74 @@ async def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -304,10 +475,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -317,15 +487,14 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace_async async def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -333,40 +502,43 @@ async def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2022_05_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -374,32 +546,32 @@ async def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -412,32 +584,117 @@ async def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountUpdateParameters 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 - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -446,7 +703,8 @@ async def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -454,58 +712,56 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -513,13 +769,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -536,10 +796,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -549,49 +807,48 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.StorageAccountListResult]: + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) + :return: An iterator like instance of either StorageAccount or the result of cls(response) :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -599,14 +856,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -623,10 +883,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -636,57 +894,53 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace_async async def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -694,65 +948,138 @@ async def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - - @distributed_trace_async + @overload async def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -761,7 +1088,8 @@ async def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -769,63 +1097,136 @@ async def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - @distributed_trace_async + @overload async def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -834,7 +1235,8 @@ async def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -842,63 +1244,134 @@ async def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - @distributed_trace_async + @overload async def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ServiceSasParameters + :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: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -907,7 +1380,8 @@ async def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -915,50 +1389,47 @@ async def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore async def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -966,10 +1437,9 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -979,26 +1449,20 @@ async def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace_async - async def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncLROPoller[None]: + async def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncLROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1010,82 +1474,75 @@ async def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_hierarchical_namespace_migration_request_initial( + request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, request_type=request_type, - template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + api_version=api_version, + template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1093,43 +1550,38 @@ async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsis request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - + _hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace_async - async def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + async def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param request_type: Required. Hierarchical namespace migration type can either be a hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the - hydration request will migrate the account. + hydration request will migrate the account. Required. :type request_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. @@ -1141,81 +1593,75 @@ async def begin_hierarchical_namespace_migration( # pylint: disable=inconsisten 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + begin_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_abort_hierarchical_namespace_migration_request_initial( + request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1223,37 +1669,33 @@ async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=in request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore - + _abort_hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace_async - async def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + async def begin_abort_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> AsyncLROPoller[None]: """Abort live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1265,85 +1707,90 @@ async def begin_abort_hierarchical_namespace_migration( # pylint: disable=incon 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore async def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1351,10 +1798,9 @@ async def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1362,38 +1808,81 @@ async def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace_async + @overload async def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 @@ -1406,20 +1895,55 @@ async def begin_restore_blob_ranges( cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreParameters 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. + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = await self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -1427,79 +1951,76 @@ async def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(AsyncPollingMethod, AsyncARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: AsyncPollingMethod - elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) - else: polling_method = polling + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling if cont_token: return AsyncLROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace_async async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1507,10 +2028,9 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1520,5 +2040,4 @@ async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-st if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_operations.py index 7cde58154a66..b804071a04b1 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_operations.py @@ -6,10 +6,19 @@ # 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, IO, Optional, TypeVar, Union, overload +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,10 +29,22 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_operations import build_create_request, build_delete_request, build_get_request, build_list_request, build_update_request -T = TypeVar('T') +from ...operations._table_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableOperations: """ .. warning:: @@ -43,62 +64,145 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - - @distributed_trace_async + @overload async def create( self, resource_group_name: str, account_name: str, table_name: str, parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table 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 - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - if parameters is not None: - _json = self._serialize.body(parameters, 'Table') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -106,81 +210,163 @@ async def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - - @distributed_trace_async + @overload async def update( self, resource_group_name: str, account_name: str, table_name: str, parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table 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 - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - if parameters is not None: - _json = self._serialize.body(parameters, 'Table') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -188,71 +374,65 @@ async def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async - async def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -260,71 +440,67 @@ async def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace_async async def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -332,10 +508,9 @@ async def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -345,50 +520,47 @@ async def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> AsyncIterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -396,15 +568,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -421,10 +595,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -434,8 +606,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_operations.py index 3f4028731d62..505792814d8b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_table_services_operations.py @@ -6,9 +6,17 @@ # 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, Optional, TypeVar - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -18,10 +26,20 @@ from ... import models as _models from ..._vendor import _convert_request -from ...operations._table_services_operations import build_get_service_properties_request, build_list_request, build_set_service_properties_request -T = TypeVar('T') +from ...operations._table_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class TableServicesOperations: """ .. warning:: @@ -41,46 +59,42 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -88,70 +102,153 @@ async def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - @distributed_trace_async + @overload async def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties or IO + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: 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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -161,7 +258,8 @@ async def set_service_properties( table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -169,72 +267,69 @@ async def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace_async async def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -242,22 +337,20 @@ async def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_operations.py index c2466ab65765..5665e75374c3 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/aio/operations/_usages_operations.py @@ -6,10 +6,19 @@ # 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, Callable, Dict, Optional, TypeVar +import urllib.parse from azure.core.async_paging import AsyncItemPaged, AsyncList -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.rest import HttpRequest @@ -20,9 +29,15 @@ from ... import models as _models from ..._vendor import _convert_request from ...operations._usages_operations import build_list_by_location_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + class UsagesOperations: """ .. warning:: @@ -42,42 +57,40 @@ def __init__(self, *args, **kwargs) -> None: self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> AsyncIterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_05_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -85,14 +98,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -109,10 +125,8 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -122,8 +136,6 @@ async def get_next(next_link=None): return pipeline_response + return AsyncItemPaged(get_next, extract_data) - return AsyncItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/__init__.py index 9743c8e2a204..b6e348f74275 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/__init__.py @@ -155,289 +155,287 @@ from ._models_py3 import UserAssignedIdentity from ._models_py3 import VirtualNetworkRule - -from ._storage_management_client_enums import ( - AccessTier, - AccountImmutabilityPolicyState, - AccountStatus, - AccountType, - AllowedCopyScope, - AllowedMethods, - BlobInventoryPolicyName, - BlobRestoreProgressStatus, - Bypass, - CreatedByType, - DefaultAction, - DefaultSharePermission, - DirectoryServiceOptions, - DnsEndpointType, - EnabledProtocols, - EncryptionScopeSource, - EncryptionScopeState, - ExpirationAction, - ExtendedLocationTypes, - Format, - GeoReplicationStatus, - HttpProtocol, - IdentityType, - ImmutabilityPolicyState, - ImmutabilityPolicyUpdateType, - InventoryRuleType, - KeyPermission, - KeySource, - KeyType, - Kind, - LargeFileSharesState, - LeaseContainerRequestEnum, - LeaseDuration, - LeaseShareAction, - LeaseState, - LeaseStatus, - ListContainersInclude, - ManagementPolicyName, - MigrationState, - MinimumTlsVersion, - Name, - ObjectType, - Permissions, - PrivateEndpointConnectionProvisioningState, - PrivateEndpointServiceConnectionStatus, - ProvisioningState, - PublicAccess, - PublicNetworkAccess, - Reason, - ReasonCode, - RootSquashType, - RoutingChoice, - RuleType, - Schedule, - Services, - ShareAccessTier, - SignedResource, - SignedResourceTypes, - SkuConversionStatus, - SkuName, - SkuTier, - State, - StorageAccountExpand, - UsageUnit, -) +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountImmutabilityPolicyState +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import AccountType +from ._storage_management_client_enums import AllowedCopyScope +from ._storage_management_client_enums import AllowedMethods +from ._storage_management_client_enums import BlobInventoryPolicyName +from ._storage_management_client_enums import BlobRestoreProgressStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CreatedByType +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DefaultSharePermission +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import DnsEndpointType +from ._storage_management_client_enums import EnabledProtocols +from ._storage_management_client_enums import EncryptionScopeSource +from ._storage_management_client_enums import EncryptionScopeState +from ._storage_management_client_enums import ExpirationAction +from ._storage_management_client_enums import ExtendedLocationTypes +from ._storage_management_client_enums import Format +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import IdentityType +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import InventoryRuleType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import KeyType +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestEnum +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseShareAction +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ListContainersInclude +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MigrationState +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Name +from ._storage_management_client_enums import ObjectType +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._storage_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import PublicNetworkAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RootSquashType +from ._storage_management_client_enums import RoutingChoice +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Schedule +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import ShareAccessTier +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuConversionStatus +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import StorageAccountExpand +from ._storage_management_client_enums import UsageUnit from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'AccessPolicy', - 'AccountImmutabilityPolicyProperties', - 'AccountSasParameters', - 'ActiveDirectoryProperties', - 'AzureEntityResource', - 'AzureFilesIdentityBasedAuthentication', - 'BlobContainer', - 'BlobInventoryPolicy', - 'BlobInventoryPolicyDefinition', - 'BlobInventoryPolicyFilter', - 'BlobInventoryPolicyRule', - 'BlobInventoryPolicySchema', - 'BlobRestoreParameters', - 'BlobRestoreRange', - 'BlobRestoreStatus', - 'BlobServiceItems', - 'BlobServiceProperties', - 'ChangeFeed', - 'CheckNameAvailabilityResult', - 'CloudErrorBody', - 'CorsRule', - 'CorsRules', - 'CustomDomain', - 'DateAfterCreation', - 'DateAfterModification', - 'DeleteRetentionPolicy', - 'DeletedAccount', - 'DeletedAccountListResult', - 'DeletedShare', - 'Dimension', - 'Encryption', - 'EncryptionIdentity', - 'EncryptionScope', - 'EncryptionScopeKeyVaultProperties', - 'EncryptionScopeListResult', - 'EncryptionService', - 'EncryptionServices', - 'Endpoints', - 'ErrorResponse', - 'ErrorResponseBody', - 'ExtendedLocation', - 'FileServiceItems', - 'FileServiceProperties', - 'FileShare', - 'FileShareItem', - 'FileShareItems', - 'GeoReplicationStats', - 'IPRule', - 'Identity', - 'ImmutabilityPolicy', - 'ImmutabilityPolicyProperties', - 'ImmutableStorageAccount', - 'ImmutableStorageWithVersioning', - 'KeyCreationTime', - 'KeyPolicy', - 'KeyVaultProperties', - 'LastAccessTimeTrackingPolicy', - 'LeaseContainerRequest', - 'LeaseContainerResponse', - 'LeaseShareRequest', - 'LeaseShareResponse', - 'LegalHold', - 'LegalHoldProperties', - 'ListAccountSasResponse', - 'ListBlobInventoryPolicy', - 'ListContainerItem', - 'ListContainerItems', - 'ListQueue', - 'ListQueueResource', - 'ListQueueServices', - 'ListServiceSasResponse', - 'ListTableResource', - 'ListTableServices', - 'LocalUser', - 'LocalUserKeys', - 'LocalUserRegeneratePasswordResult', - 'LocalUsers', - 'ManagementPolicy', - 'ManagementPolicyAction', - 'ManagementPolicyBaseBlob', - 'ManagementPolicyDefinition', - 'ManagementPolicyFilter', - 'ManagementPolicyRule', - 'ManagementPolicySchema', - 'ManagementPolicySnapShot', - 'ManagementPolicyVersion', - 'MetricSpecification', - 'Multichannel', - 'NetworkRuleSet', - 'ObjectReplicationPolicies', - 'ObjectReplicationPolicy', - 'ObjectReplicationPolicyFilter', - 'ObjectReplicationPolicyRule', - 'Operation', - 'OperationDisplay', - 'OperationListResult', - 'PermissionScope', - 'PrivateEndpoint', - 'PrivateEndpointConnection', - 'PrivateEndpointConnectionListResult', - 'PrivateLinkResource', - 'PrivateLinkResourceListResult', - 'PrivateLinkServiceConnectionState', - 'ProtectedAppendWritesHistory', - 'ProtocolSettings', - 'ProxyResource', - 'QueueServiceProperties', - 'Resource', - 'ResourceAccessRule', - 'RestorePolicyProperties', - 'Restriction', - 'RoutingPreference', - 'SKUCapability', - 'SasPolicy', - 'ServiceSasParameters', - 'ServiceSpecification', - 'SignedIdentifier', - 'Sku', - 'SkuInformation', - 'SmbSetting', - 'SshPublicKey', - 'StorageAccount', - 'StorageAccountCheckNameAvailabilityParameters', - 'StorageAccountCreateParameters', - 'StorageAccountInternetEndpoints', - 'StorageAccountKey', - 'StorageAccountListKeysResult', - 'StorageAccountListResult', - 'StorageAccountMicrosoftEndpoints', - 'StorageAccountRegenerateKeyParameters', - 'StorageAccountSkuConversionStatus', - 'StorageAccountUpdateParameters', - 'StorageQueue', - 'StorageSkuListResult', - 'SystemData', - 'Table', - 'TableAccessPolicy', - 'TableServiceProperties', - 'TableSignedIdentifier', - 'TagFilter', - 'TagProperty', - 'TrackedResource', - 'UpdateHistoryProperty', - 'Usage', - 'UsageListResult', - 'UsageName', - 'UserAssignedIdentity', - 'VirtualNetworkRule', - 'AccessTier', - 'AccountImmutabilityPolicyState', - 'AccountStatus', - 'AccountType', - 'AllowedCopyScope', - 'AllowedMethods', - 'BlobInventoryPolicyName', - 'BlobRestoreProgressStatus', - 'Bypass', - 'CreatedByType', - 'DefaultAction', - 'DefaultSharePermission', - 'DirectoryServiceOptions', - 'DnsEndpointType', - 'EnabledProtocols', - 'EncryptionScopeSource', - 'EncryptionScopeState', - 'ExpirationAction', - 'ExtendedLocationTypes', - 'Format', - 'GeoReplicationStatus', - 'HttpProtocol', - 'IdentityType', - 'ImmutabilityPolicyState', - 'ImmutabilityPolicyUpdateType', - 'InventoryRuleType', - 'KeyPermission', - 'KeySource', - 'KeyType', - 'Kind', - 'LargeFileSharesState', - 'LeaseContainerRequestEnum', - 'LeaseDuration', - 'LeaseShareAction', - 'LeaseState', - 'LeaseStatus', - 'ListContainersInclude', - 'ManagementPolicyName', - 'MigrationState', - 'MinimumTlsVersion', - 'Name', - 'ObjectType', - 'Permissions', - 'PrivateEndpointConnectionProvisioningState', - 'PrivateEndpointServiceConnectionStatus', - 'ProvisioningState', - 'PublicAccess', - 'PublicNetworkAccess', - 'Reason', - 'ReasonCode', - 'RootSquashType', - 'RoutingChoice', - 'RuleType', - 'Schedule', - 'Services', - 'ShareAccessTier', - 'SignedResource', - 'SignedResourceTypes', - 'SkuConversionStatus', - 'SkuName', - 'SkuTier', - 'State', - 'StorageAccountExpand', - 'UsageUnit', + "AccessPolicy", + "AccountImmutabilityPolicyProperties", + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobInventoryPolicy", + "BlobInventoryPolicyDefinition", + "BlobInventoryPolicyFilter", + "BlobInventoryPolicyRule", + "BlobInventoryPolicySchema", + "BlobRestoreParameters", + "BlobRestoreRange", + "BlobRestoreStatus", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorBody", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "DeletedAccount", + "DeletedAccountListResult", + "DeletedShare", + "Dimension", + "Encryption", + "EncryptionIdentity", + "EncryptionScope", + "EncryptionScopeKeyVaultProperties", + "EncryptionScopeListResult", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ErrorResponse", + "ErrorResponseBody", + "ExtendedLocation", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "ImmutableStorageAccount", + "ImmutableStorageWithVersioning", + "KeyCreationTime", + "KeyPolicy", + "KeyVaultProperties", + "LastAccessTimeTrackingPolicy", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LeaseShareRequest", + "LeaseShareResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListBlobInventoryPolicy", + "ListContainerItem", + "ListContainerItems", + "ListQueue", + "ListQueueResource", + "ListQueueServices", + "ListServiceSasResponse", + "ListTableResource", + "ListTableServices", + "LocalUser", + "LocalUserKeys", + "LocalUserRegeneratePasswordResult", + "LocalUsers", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "ManagementPolicyVersion", + "MetricSpecification", + "Multichannel", + "NetworkRuleSet", + "ObjectReplicationPolicies", + "ObjectReplicationPolicy", + "ObjectReplicationPolicyFilter", + "ObjectReplicationPolicyRule", + "Operation", + "OperationDisplay", + "OperationListResult", + "PermissionScope", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProtectedAppendWritesHistory", + "ProtocolSettings", + "ProxyResource", + "QueueServiceProperties", + "Resource", + "ResourceAccessRule", + "RestorePolicyProperties", + "Restriction", + "RoutingPreference", + "SKUCapability", + "SasPolicy", + "ServiceSasParameters", + "ServiceSpecification", + "SignedIdentifier", + "Sku", + "SkuInformation", + "SmbSetting", + "SshPublicKey", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountInternetEndpoints", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountMicrosoftEndpoints", + "StorageAccountRegenerateKeyParameters", + "StorageAccountSkuConversionStatus", + "StorageAccountUpdateParameters", + "StorageQueue", + "StorageSkuListResult", + "SystemData", + "Table", + "TableAccessPolicy", + "TableServiceProperties", + "TableSignedIdentifier", + "TagFilter", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "UserAssignedIdentity", + "VirtualNetworkRule", + "AccessTier", + "AccountImmutabilityPolicyState", + "AccountStatus", + "AccountType", + "AllowedCopyScope", + "AllowedMethods", + "BlobInventoryPolicyName", + "BlobRestoreProgressStatus", + "Bypass", + "CreatedByType", + "DefaultAction", + "DefaultSharePermission", + "DirectoryServiceOptions", + "DnsEndpointType", + "EnabledProtocols", + "EncryptionScopeSource", + "EncryptionScopeState", + "ExpirationAction", + "ExtendedLocationTypes", + "Format", + "GeoReplicationStatus", + "HttpProtocol", + "IdentityType", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "InventoryRuleType", + "KeyPermission", + "KeySource", + "KeyType", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestEnum", + "LeaseDuration", + "LeaseShareAction", + "LeaseState", + "LeaseStatus", + "ListContainersInclude", + "ManagementPolicyName", + "MigrationState", + "MinimumTlsVersion", + "Name", + "ObjectType", + "Permissions", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicAccess", + "PublicNetworkAccess", + "Reason", + "ReasonCode", + "RootSquashType", + "RoutingChoice", + "RuleType", + "Schedule", + "Services", + "ShareAccessTier", + "SignedResource", + "SignedResourceTypes", + "SkuConversionStatus", + "SkuName", + "SkuTier", + "State", + "StorageAccountExpand", + "UsageUnit", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py index 3b68d56ab053..5088c1e6fbd7 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_models_py3.py @@ -1,4 +1,5 @@ # coding=utf-8 +# pylint: disable=too-many-lines # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. See License.txt in the project root for license information. @@ -7,17 +8,22 @@ # -------------------------------------------------------------------------- import datetime +import sys from typing import Dict, List, Optional, TYPE_CHECKING, Union -from azure.core.exceptions import HttpResponseError -import msrest.serialization +from ... import _serialization + +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 - import __init__ as _models + from .. import models as _models -class AccessPolicy(msrest.serialization.Model): +class AccessPolicy(_serialization.Model): """AccessPolicy. :ivar start_time: Start time of the access policy. @@ -29,9 +35,9 @@ class AccessPolicy(msrest.serialization.Model): """ _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'permission': {'key': 'permission', 'type': 'str'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "permission": {"key": "permission", "type": "str"}, } def __init__( @@ -50,13 +56,13 @@ def __init__( :keyword permission: List of abbreviated permissions. :paramtype permission: str """ - super(AccessPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_time = start_time self.expiry_time = expiry_time self.permission = permission -class AccountImmutabilityPolicyProperties(msrest.serialization.Model): +class AccountImmutabilityPolicyProperties(_serialization.Model): """This defines account-level immutability policy properties. :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the @@ -68,7 +74,7 @@ class AccountImmutabilityPolicyProperties(msrest.serialization.Model): increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", - "Locked", "Disabled". + "Locked", and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2022_05_01.models.AccountImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for disabled and unlocked time-based retention policies. When enabled, new blocks can be written to an append @@ -78,13 +84,13 @@ class AccountImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'immutability_period_since_creation_in_days': {'maximum': 146000, 'minimum': 1}, + "immutability_period_since_creation_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'allowProtectedAppendWrites', 'type': 'bool'}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "state": {"key": "state", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, } def __init__( @@ -105,7 +111,7 @@ def __init__( increase of the immutability retention time. A policy can only be created in a Disabled or Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", - "Locked", "Disabled". + "Locked", and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2022_05_01.models.AccountImmutabilityPolicyState :keyword allow_protected_append_writes: This property can only be changed for disabled and unlocked time-based retention policies. When enabled, new blocks can be written to an append @@ -113,60 +119,60 @@ def __init__( any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes: bool """ - super(AccountImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = state self.allow_protected_append_writes = allow_protected_append_writes -class AccountSasParameters(msrest.serialization.Model): +class AccountSasParameters(_serialization.Model): """The parameters to list SAS credentials of a storage account. All required parameters must be populated in order to send to Azure. - :ivar services: Required. The signed services accessible with the account SAS. Possible values - include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". :vartype services: str or ~azure.mgmt.storage.v2022_05_01.models.Services - :ivar resource_types: Required. The signed resource types that are accessible with the account - SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. - Known values are: "s", "c", "o". + Required. Known values are: "s", "c", and "o". :vartype resource_types: str or ~azure.mgmt.storage.v2022_05_01.models.SignedResourceTypes - :ivar permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2022_05_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2022_05_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime - :ivar shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. :vartype shared_access_expiry_time: ~datetime.datetime :ivar key_to_sign: The key to sign the account SAS token with. :vartype key_to_sign: str """ _validation = { - 'services': {'required': True}, - 'resource_types': {'required': True}, - 'permissions': {'required': True}, - 'shared_access_expiry_time': {'required': True}, + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, } _attribute_map = { - 'services': {'key': 'signedServices', 'type': 'str'}, - 'resource_types': {'key': 'signedResourceTypes', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, } def __init__( @@ -183,33 +189,34 @@ def __init__( **kwargs ): """ - :keyword services: Required. The signed services accessible with the account SAS. Possible - values include: Blob (b), Queue (q), Table (t), File (f). Known values are: "b", "q", "t", "f". + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". :paramtype services: str or ~azure.mgmt.storage.v2022_05_01.models.Services - :keyword resource_types: Required. The signed resource types that are accessible with the - account SAS. Service (s): Access to service-level APIs; Container (c): Access to - container-level APIs; Object (o): Access to object-level APIs for blobs, queue messages, table - entities, and files. Known values are: "s", "c", "o". + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". :paramtype resource_types: str or ~azure.mgmt.storage.v2022_05_01.models.SignedResourceTypes - :keyword permissions: Required. The signed permissions for the account SAS. Possible values - include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process - (p). Known values are: "r", "d", "w", "l", "a", "c", "u", "p". + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2022_05_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2022_05_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime - :keyword shared_access_expiry_time: Required. The time at which the shared access signature - becomes invalid. + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. :paramtype shared_access_expiry_time: ~datetime.datetime :keyword key_to_sign: The key to sign the account SAS token with. :paramtype key_to_sign: str """ - super(AccountSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.resource_types = resource_types self.permissions = permissions @@ -220,19 +227,19 @@ def __init__( self.key_to_sign = key_to_sign -class ActiveDirectoryProperties(msrest.serialization.Model): +class ActiveDirectoryProperties(_serialization.Model): """Settings properties for Active Directory (AD). All required parameters must be populated in order to send to Azure. - :ivar domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :vartype domain_name: str :ivar net_bios_domain_name: Specifies the NetBIOS domain name. :vartype net_bios_domain_name: str :ivar forest_name: Specifies the Active Directory forest to get. :vartype forest_name: str - :ivar domain_guid: Required. Specifies the domain GUID. + :ivar domain_guid: Specifies the domain GUID. Required. :vartype domain_guid: str :ivar domain_sid: Specifies the security identifier (SID). :vartype domain_sid: str @@ -241,24 +248,24 @@ class ActiveDirectoryProperties(msrest.serialization.Model): :ivar sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. :vartype sam_account_name: str :ivar account_type: Specifies the Active Directory account type for Azure Storage. Known values - are: "User", "Computer". + are: "User" and "Computer". :vartype account_type: str or ~azure.mgmt.storage.v2022_05_01.models.AccountType """ _validation = { - 'domain_name': {'required': True}, - 'domain_guid': {'required': True}, + "domain_name": {"required": True}, + "domain_guid": {"required": True}, } _attribute_map = { - 'domain_name': {'key': 'domainName', 'type': 'str'}, - 'net_bios_domain_name': {'key': 'netBiosDomainName', 'type': 'str'}, - 'forest_name': {'key': 'forestName', 'type': 'str'}, - 'domain_guid': {'key': 'domainGuid', 'type': 'str'}, - 'domain_sid': {'key': 'domainSid', 'type': 'str'}, - 'azure_storage_sid': {'key': 'azureStorageSid', 'type': 'str'}, - 'sam_account_name': {'key': 'samAccountName', 'type': 'str'}, - 'account_type': {'key': 'accountType', 'type': 'str'}, + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, + "sam_account_name": {"key": "samAccountName", "type": "str"}, + "account_type": {"key": "accountType", "type": "str"}, } def __init__( @@ -275,14 +282,14 @@ def __init__( **kwargs ): """ - :keyword domain_name: Required. Specifies the primary domain that the AD DNS server is - authoritative for. + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. :paramtype domain_name: str :keyword net_bios_domain_name: Specifies the NetBIOS domain name. :paramtype net_bios_domain_name: str :keyword forest_name: Specifies the Active Directory forest to get. :paramtype forest_name: str - :keyword domain_guid: Required. Specifies the domain GUID. + :keyword domain_guid: Specifies the domain GUID. Required. :paramtype domain_guid: str :keyword domain_sid: Specifies the security identifier (SID). :paramtype domain_sid: str @@ -291,10 +298,10 @@ def __init__( :keyword sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. :paramtype sam_account_name: str :keyword account_type: Specifies the Active Directory account type for Azure Storage. Known - values are: "User", "Computer". + values are: "User" and "Computer". :paramtype account_type: str or ~azure.mgmt.storage.v2022_05_01.models.AccountType """ - super(ActiveDirectoryProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.domain_name = domain_name self.net_bios_domain_name = net_bios_domain_name self.forest_name = forest_name @@ -305,7 +312,7 @@ def __init__( self.account_type = account_type -class Resource(msrest.serialization.Model): +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. @@ -321,24 +328,20 @@ class Resource(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Resource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None self.name = None self.type = None @@ -362,36 +365,32 @@ class AzureEntityResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(AzureEntityResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.etag = None -class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): +class AzureFilesIdentityBasedAuthentication(_serialization.Model): """Settings for Azure Files identity based authentication. All required parameters must be populated in order to send to Azure. - :ivar directory_service_options: Required. Indicates the directory service used. Note that this - enum may be extended in the future. Known values are: "None", "AADDS", "AD", "AADKERB". + :ivar directory_service_options: Indicates the directory service used. Note that this enum may + be extended in the future. Required. Known values are: "None", "AADDS", "AD", and "AADKERB". :vartype directory_service_options: str or ~azure.mgmt.storage.v2022_05_01.models.DirectoryServiceOptions :ivar active_directory_properties: Required if directoryServiceOptions are AD, optional if they @@ -400,20 +399,20 @@ class AzureFilesIdentityBasedAuthentication(msrest.serialization.Model): ~azure.mgmt.storage.v2022_05_01.models.ActiveDirectoryProperties :ivar default_share_permission: Default share permission for users using Kerberos authentication if RBAC role is not assigned. Known values are: "None", - "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and "StorageFileDataSmbShareElevatedContributor". :vartype default_share_permission: str or ~azure.mgmt.storage.v2022_05_01.models.DefaultSharePermission """ _validation = { - 'directory_service_options': {'required': True}, + "directory_service_options": {"required": True}, } _attribute_map = { - 'directory_service_options': {'key': 'directoryServiceOptions', 'type': 'str'}, - 'active_directory_properties': {'key': 'activeDirectoryProperties', 'type': 'ActiveDirectoryProperties'}, - 'default_share_permission': {'key': 'defaultSharePermission', 'type': 'str'}, + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, + "default_share_permission": {"key": "defaultSharePermission", "type": "str"}, } def __init__( @@ -425,8 +424,9 @@ def __init__( **kwargs ): """ - :keyword directory_service_options: Required. Indicates the directory service used. Note that - this enum may be extended in the future. Known values are: "None", "AADDS", "AD", "AADKERB". + :keyword directory_service_options: Indicates the directory service used. Note that this enum + may be extended in the future. Required. Known values are: "None", "AADDS", "AD", and + "AADKERB". :paramtype directory_service_options: str or ~azure.mgmt.storage.v2022_05_01.models.DirectoryServiceOptions :keyword active_directory_properties: Required if directoryServiceOptions are AD, optional if @@ -435,18 +435,18 @@ def __init__( ~azure.mgmt.storage.v2022_05_01.models.ActiveDirectoryProperties :keyword default_share_permission: Default share permission for users using Kerberos authentication if RBAC role is not assigned. Known values are: "None", - "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and "StorageFileDataSmbShareElevatedContributor". :paramtype default_share_permission: str or ~azure.mgmt.storage.v2022_05_01.models.DefaultSharePermission """ - super(AzureFilesIdentityBasedAuthentication, self).__init__(**kwargs) + super().__init__(**kwargs) self.directory_service_options = directory_service_options self.active_directory_properties = active_directory_properties self.default_share_permission = default_share_permission -class BlobContainer(AzureEntityResource): +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the blob container, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -476,17 +476,18 @@ class BlobContainer(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -516,48 +517,51 @@ class BlobContainer(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, - 'enable_nfs_v3_root_squash': {'key': 'properties.enableNfsV3RootSquash', 'type': 'bool'}, - 'enable_nfs_v3_all_squash': {'key': 'properties.enableNfsV3AllSquash', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, } def __init__( @@ -580,7 +584,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -594,7 +598,7 @@ def __init__( :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. :paramtype enable_nfs_v3_all_squash: bool """ - super(BlobContainer, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -638,59 +642,55 @@ class BlobInventoryPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified_time": {"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'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'BlobInventoryPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "BlobInventoryPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.BlobInventoryPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs): """ :keyword policy: The storage account blob inventory policy object. It is composed of policy rules. :paramtype policy: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicySchema """ - super(BlobInventoryPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.last_modified_time = None self.policy = policy -class BlobInventoryPolicyDefinition(msrest.serialization.Model): +class BlobInventoryPolicyDefinition(_serialization.Model): """An object that defines the blob inventory rule. All required parameters must be populated in order to send to Azure. :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyFilter - :ivar format: Required. This is a required field, it specifies the format for the inventory - files. Known values are: "Csv", "Parquet". + :ivar format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". :vartype format: str or ~azure.mgmt.storage.v2022_05_01.models.Format - :ivar schedule: Required. This is a required field. This field is used to schedule an inventory - formation. Known values are: "Daily", "Weekly". + :ivar schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". :vartype schedule: str or ~azure.mgmt.storage.v2022_05_01.models.Schedule - :ivar object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Known values are: "Blob", "Container". + :ivar object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". :vartype object_type: str or ~azure.mgmt.storage.v2022_05_01.models.ObjectType - :ivar schema_fields: Required. This is a required field. This field specifies the fields and - properties of the object to be included in the inventory. The Schema field value 'Name' is - always required. The valid values for this field for the 'Blob' definition.objectType include - 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, + :ivar schema_fields: This is a required field. This field specifies the fields and properties + of the object to be included in the inventory. The Schema field value 'Name' is always + required. The valid values for this field for the 'Blob' definition.objectType include 'Name, + Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, AccessTierChangeTime, AccessTierInferred, Tags, Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime, Tags, Etag, ContentType, ContentEncoding, ContentLanguage, ContentCRC64, CacheControl, ContentDisposition, @@ -705,23 +705,23 @@ class BlobInventoryPolicyDefinition(msrest.serialization.Model): DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, DeletionId' are valid only for Hns enabled accounts.Schema field - values 'Tags, TagCount' are only valid for Non-Hns accounts. + values 'Tags, TagCount' are only valid for Non-Hns accounts. Required. :vartype schema_fields: list[str] """ _validation = { - 'format': {'required': True}, - 'schedule': {'required': True}, - 'object_type': {'required': True}, - 'schema_fields': {'required': True}, + "format": {"required": True}, + "schedule": {"required": True}, + "object_type": {"required": True}, + "schema_fields": {"required": True}, } _attribute_map = { - 'filters': {'key': 'filters', 'type': 'BlobInventoryPolicyFilter'}, - 'format': {'key': 'format', 'type': 'str'}, - 'schedule': {'key': 'schedule', 'type': 'str'}, - 'object_type': {'key': 'objectType', 'type': 'str'}, - 'schema_fields': {'key': 'schemaFields', 'type': '[str]'}, + "filters": {"key": "filters", "type": "BlobInventoryPolicyFilter"}, + "format": {"key": "format", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "schema_fields": {"key": "schemaFields", "type": "[str]"}, } def __init__( @@ -737,16 +737,17 @@ def __init__( """ :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyFilter - :keyword format: Required. This is a required field, it specifies the format for the inventory - files. Known values are: "Csv", "Parquet". + :keyword format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". :paramtype format: str or ~azure.mgmt.storage.v2022_05_01.models.Format - :keyword schedule: Required. This is a required field. This field is used to schedule an - inventory formation. Known values are: "Daily", "Weekly". + :keyword schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". :paramtype schedule: str or ~azure.mgmt.storage.v2022_05_01.models.Schedule - :keyword object_type: Required. This is a required field. This field specifies the scope of the - inventory created either at the blob or container level. Known values are: "Blob", "Container". + :keyword object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". :paramtype object_type: str or ~azure.mgmt.storage.v2022_05_01.models.ObjectType - :keyword schema_fields: Required. This is a required field. This field specifies the fields and + :keyword schema_fields: This is a required field. This field specifies the fields and properties of the object to be included in the inventory. The Schema field value 'Name' is always required. The valid values for this field for the 'Blob' definition.objectType include 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, @@ -764,10 +765,10 @@ def __init__( DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, Group, Permissions, Acl, DeletionId' are valid only for Hns enabled accounts.Schema field - values 'Tags, TagCount' are only valid for Non-Hns accounts. + values 'Tags, TagCount' are only valid for Non-Hns accounts. Required. :paramtype schema_fields: list[str] """ - super(BlobInventoryPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.filters = filters self.format = format self.schedule = schedule @@ -775,7 +776,7 @@ def __init__( self.schema_fields = schema_fields -class BlobInventoryPolicyFilter(msrest.serialization.Model): +class BlobInventoryPolicyFilter(_serialization.Model): """An object that defines the blob inventory rule filter conditions. For 'Blob' definition.objectType all filter properties are applicable, 'blobTypes' is required and others are optional. For 'Container' definition.objectType only prefixMatch is applicable and is optional. :ivar prefix_match: An array of strings with maximum 10 blob prefixes to be included in the @@ -806,12 +807,12 @@ class BlobInventoryPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'exclude_prefix': {'key': 'excludePrefix', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'include_blob_versions': {'key': 'includeBlobVersions', 'type': 'bool'}, - 'include_snapshots': {'key': 'includeSnapshots', 'type': 'bool'}, - 'include_deleted': {'key': 'includeDeleted', 'type': 'bool'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "exclude_prefix": {"key": "excludePrefix", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "include_blob_versions": {"key": "includeBlobVersions", "type": "bool"}, + "include_snapshots": {"key": "includeSnapshots", "type": "bool"}, + "include_deleted": {"key": "includeDeleted", "type": "bool"}, } def __init__( @@ -852,7 +853,7 @@ def __init__( excluded. :paramtype include_deleted: bool """ - super(BlobInventoryPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.exclude_prefix = exclude_prefix self.blob_types = blob_types @@ -861,35 +862,35 @@ def __init__( self.include_deleted = include_deleted -class BlobInventoryPolicyRule(msrest.serialization.Model): +class BlobInventoryPolicyRule(_serialization.Model): """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Rule is enabled when set to true. + :ivar enabled: Rule is enabled when set to true. Required. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :ivar destination: Container name where blob inventory files are stored. Must be pre-created. + Required. :vartype destination: str - :ivar definition: Required. An object that defines the blob inventory policy rule. + :ivar definition: An object that defines the blob inventory policy rule. Required. :vartype definition: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyDefinition """ _validation = { - 'enabled': {'required': True}, - 'name': {'required': True}, - 'destination': {'required': True}, - 'definition': {'required': True}, + "enabled": {"required": True}, + "name": {"required": True}, + "destination": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'destination': {'key': 'destination', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'BlobInventoryPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "destination": {"key": "destination", "type": "str"}, + "definition": {"key": "definition", "type": "BlobInventoryPolicyDefinition"}, } def __init__( @@ -902,55 +903,55 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Rule is enabled when set to true. + :keyword enabled: Rule is enabled when set to true. Required. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword destination: Required. Container name where blob inventory files are stored. Must be - pre-created. + :keyword destination: Container name where blob inventory files are stored. Must be + pre-created. Required. :paramtype destination: str - :keyword definition: Required. An object that defines the blob inventory policy rule. + :keyword definition: An object that defines the blob inventory policy rule. Required. :paramtype definition: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyDefinition """ - super(BlobInventoryPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.destination = destination self.definition = definition -class BlobInventoryPolicySchema(msrest.serialization.Model): +class BlobInventoryPolicySchema(_serialization.Model): """The storage account blob inventory policy rules. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Policy is enabled if set to true. + :ivar enabled: Policy is enabled if set to true. Required. :vartype enabled: bool :ivar destination: Deprecated Property from API version 2021-04-01 onwards, the required destination container name must be specified at the rule level 'policy.rule.destination'. :vartype destination: str - :ivar type: Required. The valid value is Inventory. Known values are: "Inventory". + :ivar type: The valid value is Inventory. Required. "Inventory" :vartype type: str or ~azure.mgmt.storage.v2022_05_01.models.InventoryRuleType - :ivar rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :ivar rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :vartype rules: list[~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyRule] """ _validation = { - 'enabled': {'required': True}, - 'destination': {'readonly': True}, - 'type': {'required': True}, - 'rules': {'required': True}, + "enabled": {"required": True}, + "destination": {"readonly": True}, + "type": {"required": True}, + "rules": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'destination': {'key': 'destination', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'rules': {'key': 'rules', 'type': '[BlobInventoryPolicyRule]'}, + "enabled": {"key": "enabled", "type": "bool"}, + "destination": {"key": "destination", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rules": {"key": "rules", "type": "[BlobInventoryPolicyRule]"}, } def __init__( @@ -962,100 +963,88 @@ def __init__( **kwargs ): """ - :keyword enabled: Required. Policy is enabled if set to true. + :keyword enabled: Policy is enabled if set to true. Required. :paramtype enabled: bool - :keyword type: Required. The valid value is Inventory. Known values are: "Inventory". + :keyword type: The valid value is Inventory. Required. "Inventory" :paramtype type: str or ~azure.mgmt.storage.v2022_05_01.models.InventoryRuleType - :keyword rules: Required. The storage account blob inventory policy rules. The rule is applied - when it is enabled. + :keyword rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. :paramtype rules: list[~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyRule] """ - super(BlobInventoryPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.destination = None self.type = type self.rules = rules -class BlobRestoreParameters(msrest.serialization.Model): +class BlobRestoreParameters(_serialization.Model): """Blob restore parameters. All required parameters must be populated in order to send to Azure. - :ivar time_to_restore: Required. Restore blob to the specified time. + :ivar time_to_restore: Restore blob to the specified time. Required. :vartype time_to_restore: ~datetime.datetime - :ivar blob_ranges: Required. Blob ranges to restore. + :ivar blob_ranges: Blob ranges to restore. Required. :vartype blob_ranges: list[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreRange] """ _validation = { - 'time_to_restore': {'required': True}, - 'blob_ranges': {'required': True}, + "time_to_restore": {"required": True}, + "blob_ranges": {"required": True}, } _attribute_map = { - 'time_to_restore': {'key': 'timeToRestore', 'type': 'iso-8601'}, - 'blob_ranges': {'key': 'blobRanges', 'type': '[BlobRestoreRange]'}, + "time_to_restore": {"key": "timeToRestore", "type": "iso-8601"}, + "blob_ranges": {"key": "blobRanges", "type": "[BlobRestoreRange]"}, } - def __init__( - self, - *, - time_to_restore: datetime.datetime, - blob_ranges: List["_models.BlobRestoreRange"], - **kwargs - ): + def __init__(self, *, time_to_restore: datetime.datetime, blob_ranges: List["_models.BlobRestoreRange"], **kwargs): """ - :keyword time_to_restore: Required. Restore blob to the specified time. + :keyword time_to_restore: Restore blob to the specified time. Required. :paramtype time_to_restore: ~datetime.datetime - :keyword blob_ranges: Required. Blob ranges to restore. + :keyword blob_ranges: Blob ranges to restore. Required. :paramtype blob_ranges: list[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreRange] """ - super(BlobRestoreParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.time_to_restore = time_to_restore self.blob_ranges = blob_ranges -class BlobRestoreRange(msrest.serialization.Model): +class BlobRestoreRange(_serialization.Model): """Blob range. All required parameters must be populated in order to send to Azure. - :ivar start_range: Required. Blob start range. This is inclusive. Empty means account start. + :ivar start_range: Blob start range. This is inclusive. Empty means account start. Required. :vartype start_range: str - :ivar end_range: Required. Blob end range. This is exclusive. Empty means account end. + :ivar end_range: Blob end range. This is exclusive. Empty means account end. Required. :vartype end_range: str """ _validation = { - 'start_range': {'required': True}, - 'end_range': {'required': True}, + "start_range": {"required": True}, + "end_range": {"required": True}, } _attribute_map = { - 'start_range': {'key': 'startRange', 'type': 'str'}, - 'end_range': {'key': 'endRange', 'type': 'str'}, + "start_range": {"key": "startRange", "type": "str"}, + "end_range": {"key": "endRange", "type": "str"}, } - def __init__( - self, - *, - start_range: str, - end_range: str, - **kwargs - ): + def __init__(self, *, start_range: str, end_range: str, **kwargs): """ - :keyword start_range: Required. Blob start range. This is inclusive. Empty means account start. + :keyword start_range: Blob start range. This is inclusive. Empty means account start. Required. :paramtype start_range: str - :keyword end_range: Required. Blob end range. This is exclusive. Empty means account end. + :keyword end_range: Blob end range. This is exclusive. Empty means account end. Required. :paramtype end_range: str """ - super(BlobRestoreRange, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_range = start_range self.end_range = end_range -class BlobRestoreStatus(msrest.serialization.Model): +class BlobRestoreStatus(_serialization.Model): """Blob restore status. Variables are only populated by the server, and will be ignored when sending a request. @@ -1063,7 +1052,7 @@ class BlobRestoreStatus(msrest.serialization.Model): :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", - "Complete", "Failed". + "Complete", and "Failed". :vartype status: str or ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreProgressStatus :ivar failure_reason: Failure reason when blob restore is failed. :vartype failure_reason: str @@ -1074,33 +1063,29 @@ class BlobRestoreStatus(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'failure_reason': {'readonly': True}, - 'restore_id': {'readonly': True}, - 'parameters': {'readonly': True}, + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "restore_id": {"readonly": True}, + "parameters": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'failure_reason': {'key': 'failureReason', 'type': 'str'}, - 'restore_id': {'key': 'restoreId', 'type': 'str'}, - 'parameters': {'key': 'parameters', 'type': 'BlobRestoreParameters'}, + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "restore_id": {"key": "restoreId", "type": "str"}, + "parameters": {"key": "parameters", "type": "BlobRestoreParameters"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobRestoreStatus, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.failure_reason = None self.restore_id = None self.parameters = None -class BlobServiceItems(msrest.serialization.Model): +class BlobServiceItems(_serialization.Model): """BlobServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -1110,24 +1095,20 @@ class BlobServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobServiceProperties]'}, + "value": {"key": "value", "type": "[BlobServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(BlobServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class BlobServiceProperties(Resource): +class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attributes """The properties of a storage account’s Blob service. Variables are only populated by the server, and will be ignored when sending a request. @@ -1170,26 +1151,32 @@ class BlobServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'default_service_version': {'key': 'properties.defaultServiceVersion', 'type': 'str'}, - 'delete_retention_policy': {'key': 'properties.deleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'is_versioning_enabled': {'key': 'properties.isVersioningEnabled', 'type': 'bool'}, - 'automatic_snapshot_policy_enabled': {'key': 'properties.automaticSnapshotPolicyEnabled', 'type': 'bool'}, - 'change_feed': {'key': 'properties.changeFeed', 'type': 'ChangeFeed'}, - 'restore_policy': {'key': 'properties.restorePolicy', 'type': 'RestorePolicyProperties'}, - 'container_delete_retention_policy': {'key': 'properties.containerDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'last_access_time_tracking_policy': {'key': 'properties.lastAccessTimeTrackingPolicy', 'type': 'LastAccessTimeTrackingPolicy'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "is_versioning_enabled": {"key": "properties.isVersioningEnabled", "type": "bool"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, + "restore_policy": {"key": "properties.restorePolicy", "type": "RestorePolicyProperties"}, + "container_delete_retention_policy": { + "key": "properties.containerDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "last_access_time_tracking_policy": { + "key": "properties.lastAccessTimeTrackingPolicy", + "type": "LastAccessTimeTrackingPolicy", + }, } def __init__( @@ -1236,7 +1223,7 @@ def __init__( :paramtype last_access_time_tracking_policy: ~azure.mgmt.storage.v2022_05_01.models.LastAccessTimeTrackingPolicy """ - super(BlobServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.default_service_version = default_service_version @@ -1249,7 +1236,7 @@ def __init__( self.last_access_time_tracking_policy = last_access_time_tracking_policy -class ChangeFeed(msrest.serialization.Model): +class ChangeFeed(_serialization.Model): """The blob service properties for change feed events. :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. @@ -1261,21 +1248,15 @@ class ChangeFeed(msrest.serialization.Model): """ _validation = { - 'retention_in_days': {'maximum': 146000, 'minimum': 1}, + "retention_in_days": {"maximum": 146000, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'retention_in_days': {'key': 'retentionInDays', 'type': 'int'}, + "enabled": {"key": "enabled", "type": "bool"}, + "retention_in_days": {"key": "retentionInDays", "type": "int"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - retention_in_days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, retention_in_days: Optional[int] = None, **kwargs): """ :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. :paramtype enabled: bool @@ -1284,12 +1265,12 @@ def __init__( retention of the change feed. :paramtype retention_in_days: int """ - super(ChangeFeed, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.retention_in_days = retention_in_days -class CheckNameAvailabilityResult(msrest.serialization.Model): +class CheckNameAvailabilityResult(_serialization.Model): """The CheckNameAvailability operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -1299,7 +1280,7 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): and cannot be used. :vartype name_available: bool :ivar reason: Gets the reason that a storage account name could not be used. The Reason element - is only returned if NameAvailable is false. Known values are: "AccountNameInvalid", + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and "AlreadyExists". :vartype reason: str or ~azure.mgmt.storage.v2022_05_01.models.Reason :ivar message: Gets an error message explaining the Reason value in more detail. @@ -1307,30 +1288,26 @@ class CheckNameAvailabilityResult(msrest.serialization.Model): """ _validation = { - 'name_available': {'readonly': True}, - 'reason': {'readonly': True}, - 'message': {'readonly': True}, + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, } _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(CheckNameAvailabilityResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name_available = None self.reason = None self.message = None -class CloudErrorBody(msrest.serialization.Model): +class CloudErrorBody(_serialization.Model): """An error response from the Storage service. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -1347,10 +1324,10 @@ class CloudErrorBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, } def __init__( @@ -1375,49 +1352,49 @@ def __init__( :keyword details: A list of additional details about the error. :paramtype details: list[~azure.mgmt.storage.v2022_05_01.models.CloudErrorBody] """ - super(CloudErrorBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message self.target = target self.details = details -class CorsRule(msrest.serialization.Model): +class CorsRule(_serialization.Model): """Specifies a CORS rule for the Blob service. All required parameters must be populated in order to send to Azure. - :ivar allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. :vartype allowed_origins: list[str] - :ivar allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2022_05_01.models.AllowedMethods] - :ivar max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. :vartype max_age_in_seconds: int - :ivar exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. :vartype exposed_headers: list[str] - :ivar allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. :vartype allowed_headers: list[str] """ _validation = { - 'allowed_origins': {'required': True}, - 'allowed_methods': {'required': True}, - 'max_age_in_seconds': {'required': True}, - 'exposed_headers': {'required': True}, - 'allowed_headers': {'required': True}, + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, } _attribute_map = { - 'allowed_origins': {'key': 'allowedOrigins', 'type': '[str]'}, - 'allowed_methods': {'key': 'allowedMethods', 'type': '[str]'}, - 'max_age_in_seconds': {'key': 'maxAgeInSeconds', 'type': 'int'}, - 'exposed_headers': {'key': 'exposedHeaders', 'type': '[str]'}, - 'allowed_headers': {'key': 'allowedHeaders', 'type': '[str]'}, + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, } def __init__( @@ -1431,23 +1408,23 @@ def __init__( **kwargs ): """ - :keyword allowed_origins: Required. Required if CorsRule element is present. A list of origin - domains that will be allowed via CORS, or "*" to allow all domains. + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. :paramtype allowed_origins: list[str] - :keyword allowed_methods: Required. Required if CorsRule element is present. A list of HTTP - methods that are allowed to be executed by the origin. + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2022_05_01.models.AllowedMethods] - :keyword max_age_in_seconds: Required. Required if CorsRule element is present. The number of - seconds that the client/browser should cache a preflight response. + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. :paramtype max_age_in_seconds: int - :keyword exposed_headers: Required. Required if CorsRule element is present. A list of response - headers to expose to CORS clients. + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. :paramtype exposed_headers: list[str] - :keyword allowed_headers: Required. Required if CorsRule element is present. A list of headers - allowed to be part of the cross-origin request. + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. :paramtype allowed_headers: list[str] """ - super(CorsRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.allowed_origins = allowed_origins self.allowed_methods = allowed_methods self.max_age_in_seconds = max_age_in_seconds @@ -1455,7 +1432,7 @@ def __init__( self.allowed_headers = allowed_headers -class CorsRules(msrest.serialization.Model): +class CorsRules(_serialization.Model): """Sets the CORS rules. You can include up to five CorsRule elements in the request. :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the @@ -1464,31 +1441,26 @@ class CorsRules(msrest.serialization.Model): """ _attribute_map = { - 'cors_rules': {'key': 'corsRules', 'type': '[CorsRule]'}, + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, } - def __init__( - self, - *, - cors_rules: Optional[List["_models.CorsRule"]] = None, - **kwargs - ): + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): """ :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the request. :paramtype cors_rules: list[~azure.mgmt.storage.v2022_05_01.models.CorsRule] """ - super(CorsRules, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors_rules = cors_rules -class CustomDomain(msrest.serialization.Model): +class CustomDomain(_serialization.Model): """The custom domain assigned to this storage account. This can be set via Update. All required parameters must be populated in order to send to Azure. - :ivar name: Required. Gets or sets the custom domain name assigned to the storage account. Name - is the CNAME source. + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :vartype name: str :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. @@ -1496,41 +1468,35 @@ class CustomDomain(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, + "name": {"required": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'use_sub_domain_name': {'key': 'useSubDomainName', 'type': 'bool'}, + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, } - def __init__( - self, - *, - name: str, - use_sub_domain_name: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): """ - :keyword name: Required. Gets or sets the custom domain name assigned to the storage account. - Name is the CNAME source. + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. :paramtype name: str :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default value is false. This should only be set on updates. :paramtype use_sub_domain_name: bool """ - super(CustomDomain, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.use_sub_domain_name = use_sub_domain_name -class DateAfterCreation(msrest.serialization.Model): +class DateAfterCreation(_serialization.Model): """Object to define snapshot and version action conditions. All required parameters must be populated in order to send to Azure. - :ivar days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :vartype days_after_creation_greater_than: float :ivar days_after_last_tier_change_greater_than: Value indicating the age in days after last blob tier change time. This property is only applicable for tierToArchive actions and requires @@ -1540,13 +1506,13 @@ class DateAfterCreation(msrest.serialization.Model): """ _validation = { - 'days_after_creation_greater_than': {'required': True, 'minimum': 0, 'multiple': 1}, - 'days_after_last_tier_change_greater_than': {'minimum': 0, 'multiple': 1}, + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, + "days_after_last_tier_change_greater_than": {"minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, - 'days_after_last_tier_change_greater_than': {'key': 'daysAfterLastTierChangeGreaterThan', 'type': 'float'}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, + "days_after_last_tier_change_greater_than": {"key": "daysAfterLastTierChangeGreaterThan", "type": "float"}, } def __init__( @@ -1557,8 +1523,8 @@ def __init__( **kwargs ): """ - :keyword days_after_creation_greater_than: Required. Value indicating the age in days after - creation. + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. :paramtype days_after_creation_greater_than: float :keyword days_after_last_tier_change_greater_than: Value indicating the age in days after last blob tier change time. This property is only applicable for tierToArchive actions and requires @@ -1566,12 +1532,12 @@ def __init__( will be archived if both the conditions are satisfied. :paramtype days_after_last_tier_change_greater_than: float """ - super(DateAfterCreation, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_creation_greater_than = days_after_creation_greater_than self.days_after_last_tier_change_greater_than = days_after_last_tier_change_greater_than -class DateAfterModification(msrest.serialization.Model): +class DateAfterModification(_serialization.Model): """Object to define the base blob action conditions. Properties daysAfterModificationGreaterThan, daysAfterLastAccessTimeGreaterThan and daysAfterCreationGreaterThan are mutually exclusive. The daysAfterLastTierChangeGreaterThan property is only applicable for tierToArchive actions which requires daysAfterModificationGreaterThan to be set, also it cannot be used in conjunction with daysAfterLastAccessTimeGreaterThan or daysAfterCreationGreaterThan. :ivar days_after_modification_greater_than: Value indicating the age in days after last @@ -1591,17 +1557,17 @@ class DateAfterModification(msrest.serialization.Model): """ _validation = { - 'days_after_modification_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_last_access_time_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_last_tier_change_greater_than': {'minimum': 0, 'multiple': 1}, - 'days_after_creation_greater_than': {'minimum': 0, 'multiple': 1}, + "days_after_modification_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_access_time_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_tier_change_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_creation_greater_than": {"minimum": 0, "multiple": 1}, } _attribute_map = { - 'days_after_modification_greater_than': {'key': 'daysAfterModificationGreaterThan', 'type': 'float'}, - 'days_after_last_access_time_greater_than': {'key': 'daysAfterLastAccessTimeGreaterThan', 'type': 'float'}, - 'days_after_last_tier_change_greater_than': {'key': 'daysAfterLastTierChangeGreaterThan', 'type': 'float'}, - 'days_after_creation_greater_than': {'key': 'daysAfterCreationGreaterThan', 'type': 'float'}, + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, + "days_after_last_access_time_greater_than": {"key": "daysAfterLastAccessTimeGreaterThan", "type": "float"}, + "days_after_last_tier_change_greater_than": {"key": "daysAfterLastTierChangeGreaterThan", "type": "float"}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, } def __init__( @@ -1630,7 +1596,7 @@ def __init__( creation. :paramtype days_after_creation_greater_than: float """ - super(DateAfterModification, self).__init__(**kwargs) + super().__init__(**kwargs) self.days_after_modification_greater_than = days_after_modification_greater_than self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than self.days_after_last_tier_change_greater_than = days_after_last_tier_change_greater_than @@ -1653,24 +1619,20 @@ class ProxyResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ProxyResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) class DeletedAccount(ProxyResource): @@ -1700,34 +1662,30 @@ class DeletedAccount(ProxyResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'storage_account_resource_id': {'readonly': True}, - 'location': {'readonly': True}, - 'restore_reference': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'deletion_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'storage_account_resource_id': {'key': 'properties.storageAccountResourceId', 'type': 'str'}, - 'location': {'key': 'properties.location', 'type': 'str'}, - 'restore_reference': {'key': 'properties.restoreReference', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'str'}, - 'deletion_time': {'key': 'properties.deletionTime', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccount, self).__init__(**kwargs) + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "storage_account_resource_id": {"readonly": True}, + "location": {"readonly": True}, + "restore_reference": {"readonly": True}, + "creation_time": {"readonly": True}, + "deletion_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "location": {"key": "properties.location", "type": "str"}, + "restore_reference": {"key": "properties.restoreReference", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "str"}, + "deletion_time": {"key": "properties.deletionTime", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.storage_account_resource_id = None self.location = None self.restore_reference = None @@ -1735,7 +1693,7 @@ def __init__( self.deletion_time = None -class DeletedAccountListResult(msrest.serialization.Model): +class DeletedAccountListResult(_serialization.Model): """The response from the List Deleted Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -1748,70 +1706,60 @@ class DeletedAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[DeletedAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[DeletedAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(DeletedAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class DeletedShare(msrest.serialization.Model): +class DeletedShare(_serialization.Model): """The deleted share to be restored. All required parameters must be populated in order to send to Azure. - :ivar deleted_share_name: Required. Required. Identify the name of the deleted share that will - be restored. + :ivar deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :vartype deleted_share_name: str - :ivar deleted_share_version: Required. Required. Identify the version of the deleted share that - will be restored. + :ivar deleted_share_version: Required. Identify the version of the deleted share that will be + restored. Required. :vartype deleted_share_version: str """ _validation = { - 'deleted_share_name': {'required': True}, - 'deleted_share_version': {'required': True}, + "deleted_share_name": {"required": True}, + "deleted_share_version": {"required": True}, } _attribute_map = { - 'deleted_share_name': {'key': 'deletedShareName', 'type': 'str'}, - 'deleted_share_version': {'key': 'deletedShareVersion', 'type': 'str'}, + "deleted_share_name": {"key": "deletedShareName", "type": "str"}, + "deleted_share_version": {"key": "deletedShareVersion", "type": "str"}, } - def __init__( - self, - *, - deleted_share_name: str, - deleted_share_version: str, - **kwargs - ): + def __init__(self, *, deleted_share_name: str, deleted_share_version: str, **kwargs): """ - :keyword deleted_share_name: Required. Required. Identify the name of the deleted share that - will be restored. + :keyword deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. :paramtype deleted_share_name: str - :keyword deleted_share_version: Required. Required. Identify the version of the deleted share - that will be restored. + :keyword deleted_share_version: Required. Identify the version of the deleted share that will + be restored. Required. :paramtype deleted_share_version: str """ - super(DeletedShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.deleted_share_name = deleted_share_name self.deleted_share_version = deleted_share_version -class DeleteRetentionPolicy(msrest.serialization.Model): +class DeleteRetentionPolicy(_serialization.Model): """The service properties for soft delete. :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. @@ -1826,13 +1774,13 @@ class DeleteRetentionPolicy(msrest.serialization.Model): """ _validation = { - 'days': {'maximum': 365, 'minimum': 1}, + "days": {"maximum": 365, "minimum": 1}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - 'allow_permanent_delete': {'key': 'allowPermanentDelete', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "allow_permanent_delete": {"key": "allowPermanentDelete", "type": "bool"}, } def __init__( @@ -1854,13 +1802,13 @@ def __init__( property only applies to blob service and does not apply to containers or file share. :paramtype allow_permanent_delete: bool """ - super(DeleteRetentionPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days self.allow_permanent_delete = allow_permanent_delete -class Dimension(msrest.serialization.Model): +class Dimension(_serialization.Model): """Dimension of blobs, possibly be blob type or access tier. :ivar name: Display name of dimension. @@ -1870,36 +1818,30 @@ class Dimension(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, } - def __init__( - self, - *, - name: Optional[str] = None, - display_name: Optional[str] = None, - **kwargs - ): + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): """ :keyword name: Display name of dimension. :paramtype name: str :keyword display_name: Display name of dimension. :paramtype display_name: str """ - super(Dimension, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name -class Encryption(msrest.serialization.Model): +class Encryption(_serialization.Model): """The encryption settings on the storage account. :ivar services: List of services which support encryption. :vartype services: ~azure.mgmt.storage.v2022_05_01.models.EncryptionServices :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): - Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", - "Microsoft.Keyvault". Default value: "Microsoft.Storage". + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :vartype key_source: str or ~azure.mgmt.storage.v2022_05_01.models.KeySource :ivar require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1911,18 +1853,18 @@ class Encryption(msrest.serialization.Model): """ _attribute_map = { - 'services': {'key': 'services', 'type': 'EncryptionServices'}, - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'require_infrastructure_encryption': {'key': 'requireInfrastructureEncryption', 'type': 'bool'}, - 'key_vault_properties': {'key': 'keyvaultproperties', 'type': 'KeyVaultProperties'}, - 'encryption_identity': {'key': 'identity', 'type': 'EncryptionIdentity'}, + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, + "encryption_identity": {"key": "identity", "type": "EncryptionIdentity"}, } def __init__( self, *, services: Optional["_models.EncryptionServices"] = None, - key_source: Optional[Union[str, "_models.KeySource"]] = "Microsoft.Storage", + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", require_infrastructure_encryption: Optional[bool] = None, key_vault_properties: Optional["_models.KeyVaultProperties"] = None, encryption_identity: Optional["_models.EncryptionIdentity"] = None, @@ -1932,8 +1874,8 @@ def __init__( :keyword services: List of services which support encryption. :paramtype services: ~azure.mgmt.storage.v2022_05_01.models.EncryptionServices :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): - Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage", - "Microsoft.Keyvault". Default value: "Microsoft.Storage". + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". :paramtype key_source: str or ~azure.mgmt.storage.v2022_05_01.models.KeySource :keyword require_infrastructure_encryption: A boolean indicating whether or not the service applies a secondary layer of encryption with platform managed keys for data at rest. @@ -1943,7 +1885,7 @@ def __init__( :keyword encryption_identity: The identity to be used with service-side encryption at rest. :paramtype encryption_identity: ~azure.mgmt.storage.v2022_05_01.models.EncryptionIdentity """ - super(Encryption, self).__init__(**kwargs) + super().__init__(**kwargs) self.services = services self.key_source = key_source self.require_infrastructure_encryption = require_infrastructure_encryption @@ -1951,7 +1893,7 @@ def __init__( self.encryption_identity = encryption_identity -class EncryptionIdentity(msrest.serialization.Model): +class EncryptionIdentity(_serialization.Model): """Encryption identity for the storage account. :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be @@ -1964,8 +1906,8 @@ class EncryptionIdentity(msrest.serialization.Model): """ _attribute_map = { - 'encryption_user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, - 'encryption_federated_identity_client_id': {'key': 'federatedIdentityClientId', 'type': 'str'}, + "encryption_user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, + "encryption_federated_identity_client_id": {"key": "federatedIdentityClientId", "type": "str"}, } def __init__( @@ -1984,7 +1926,7 @@ def __init__( server-side encryption on the storage account. :paramtype encryption_federated_identity_client_id: str """ - super(EncryptionIdentity, self).__init__(**kwargs) + super().__init__(**kwargs) self.encryption_user_assigned_identity = encryption_user_assigned_identity self.encryption_federated_identity_client_id = encryption_federated_identity_client_id @@ -2003,11 +1945,11 @@ class EncryptionScope(Resource): "Microsoft.Storage/storageAccounts". :vartype type: str :ivar source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :vartype source: str or ~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeSource :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, - Disabled. Known values are: "Enabled", "Disabled". + Disabled. Known values are: "Enabled" and "Disabled". :vartype state: str or ~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeState :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. :vartype creation_time: ~datetime.datetime @@ -2024,23 +1966,23 @@ class EncryptionScope(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'source': {'key': 'properties.source', 'type': 'str'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'key_vault_properties': {'key': 'properties.keyVaultProperties', 'type': 'EncryptionScopeKeyVaultProperties'}, - 'require_infrastructure_encryption': {'key': 'properties.requireInfrastructureEncryption', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "EncryptionScopeKeyVaultProperties"}, + "require_infrastructure_encryption": {"key": "properties.requireInfrastructureEncryption", "type": "bool"}, } def __init__( @@ -2054,11 +1996,11 @@ def __init__( ): """ :keyword source: The provider for the encryption scope. Possible values (case-insensitive): - Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage", + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and "Microsoft.KeyVault". :paramtype source: str or ~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeSource :keyword state: The state of the encryption scope. Possible values (case-insensitive): - Enabled, Disabled. Known values are: "Enabled", "Disabled". + Enabled, Disabled. Known values are: "Enabled" and "Disabled". :paramtype state: str or ~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeState :keyword key_vault_properties: The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. @@ -2068,7 +2010,7 @@ def __init__( applies a secondary layer of encryption with platform managed keys for data at rest. :paramtype require_infrastructure_encryption: bool """ - super(EncryptionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.source = source self.state = state self.creation_time = None @@ -2077,7 +2019,7 @@ def __init__( self.require_infrastructure_encryption = require_infrastructure_encryption -class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): +class EncryptionScopeKeyVaultProperties(_serialization.Model): """The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. Variables are only populated by the server, and will be ignored when sending a request. @@ -2094,35 +2036,30 @@ class EncryptionScopeKeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, } _attribute_map = { - 'key_uri': {'key': 'keyUri', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, + "key_uri": {"key": "keyUri", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - key_uri: Optional[str] = None, - **kwargs - ): + def __init__(self, *, key_uri: Optional[str] = None, **kwargs): """ :keyword key_uri: The object identifier for a key vault key object. When applied, the encryption scope will use the key referenced by the identifier to enable customer-managed key support on this encryption scope. :paramtype key_uri: str """ - super(EncryptionScopeKeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_uri = key_uri self.current_versioned_key_identifier = None self.last_key_rotation_timestamp = None -class EncryptionScopeListResult(msrest.serialization.Model): +class EncryptionScopeListResult(_serialization.Model): """List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. Variables are only populated by the server, and will be ignored when sending a request. @@ -2135,27 +2072,23 @@ class EncryptionScopeListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[EncryptionScope]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[EncryptionScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(EncryptionScopeListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class EncryptionService(msrest.serialization.Model): +class EncryptionService(_serialization.Model): """A service that allows server-side encryption to be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -2168,26 +2101,22 @@ class EncryptionService(msrest.serialization.Model): :vartype last_enabled_time: ~datetime.datetime :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a - default service key is used. Known values are: "Service", "Account". + default service key is used. Known values are: "Service" and "Account". :vartype key_type: str or ~azure.mgmt.storage.v2022_05_01.models.KeyType """ _validation = { - 'last_enabled_time': {'readonly': True}, + "last_enabled_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'key_type': {'key': 'keyType', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "key_type": {"key": "keyType", "type": "str"}, } def __init__( - self, - *, - enabled: Optional[bool] = None, - key_type: Optional[Union[str, "_models.KeyType"]] = None, - **kwargs + self, *, enabled: Optional[bool] = None, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs ): """ :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is @@ -2195,16 +2124,16 @@ def __init__( :paramtype enabled: bool :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies - that a default service key is used. Known values are: "Service", "Account". + that a default service key is used. Known values are: "Service" and "Account". :paramtype key_type: str or ~azure.mgmt.storage.v2022_05_01.models.KeyType """ - super(EncryptionService, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.last_enabled_time = None self.key_type = key_type -class EncryptionServices(msrest.serialization.Model): +class EncryptionServices(_serialization.Model): """A list of services that support encryption. :ivar blob: The encryption function of the blob storage service. @@ -2218,10 +2147,10 @@ class EncryptionServices(msrest.serialization.Model): """ _attribute_map = { - 'blob': {'key': 'blob', 'type': 'EncryptionService'}, - 'file': {'key': 'file', 'type': 'EncryptionService'}, - 'table': {'key': 'table', 'type': 'EncryptionService'}, - 'queue': {'key': 'queue', 'type': 'EncryptionService'}, + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, } def __init__( @@ -2243,14 +2172,14 @@ def __init__( :keyword queue: The encryption function of the queue storage service. :paramtype queue: ~azure.mgmt.storage.v2022_05_01.models.EncryptionService """ - super(EncryptionServices, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = blob self.file = file self.table = table self.queue = queue -class Endpoints(msrest.serialization.Model): +class Endpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. Variables are only populated by the server, and will be ignored when sending a request. @@ -2276,23 +2205,23 @@ class Endpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, - 'microsoft_endpoints': {'key': 'microsoftEndpoints', 'type': 'StorageAccountMicrosoftEndpoints'}, - 'internet_endpoints': {'key': 'internetEndpoints', 'type': 'StorageAccountInternetEndpoints'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + "microsoft_endpoints": {"key": "microsoftEndpoints", "type": "StorageAccountMicrosoftEndpoints"}, + "internet_endpoints": {"key": "internetEndpoints", "type": "StorageAccountInternetEndpoints"}, } def __init__( @@ -2310,7 +2239,7 @@ def __init__( :paramtype internet_endpoints: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountInternetEndpoints """ - super(Endpoints, self).__init__(**kwargs) + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -2321,7 +2250,7 @@ def __init__( self.internet_endpoints = internet_endpoints -class ErrorResponse(msrest.serialization.Model): +class ErrorResponse(_serialization.Model): """An error response from the storage resource provider. :ivar error: Azure Storage Resource Provider error response body. @@ -2329,24 +2258,19 @@ class ErrorResponse(msrest.serialization.Model): """ _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorResponseBody'}, + "error": {"key": "error", "type": "ErrorResponseBody"}, } - def __init__( - self, - *, - error: Optional["_models.ErrorResponseBody"] = None, - **kwargs - ): + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): """ :keyword error: Azure Storage Resource Provider error response body. :paramtype error: ~azure.mgmt.storage.v2022_05_01.models.ErrorResponseBody """ - super(ErrorResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.error = error -class ErrorResponseBody(msrest.serialization.Model): +class ErrorResponseBody(_serialization.Model): """Error response body contract. :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed @@ -2358,17 +2282,11 @@ class ErrorResponseBody(msrest.serialization.Model): """ _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, } - def __init__( - self, - *, - code: Optional[str] = None, - message: Optional[str] = None, - **kwargs - ): + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): """ :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. @@ -2377,23 +2295,23 @@ def __init__( interface. :paramtype message: str """ - super(ErrorResponseBody, self).__init__(**kwargs) + super().__init__(**kwargs) self.code = code self.message = message -class ExtendedLocation(msrest.serialization.Model): +class ExtendedLocation(_serialization.Model): """The complex type of the extended location. :ivar name: The name of the extended location. :vartype name: str - :ivar type: The type of the extended location. Known values are: "EdgeZone". + :ivar type: The type of the extended location. "EdgeZone" :vartype type: str or ~azure.mgmt.storage.v2022_05_01.models.ExtendedLocationTypes """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } def __init__( @@ -2406,15 +2324,15 @@ def __init__( """ :keyword name: The name of the extended location. :paramtype name: str - :keyword type: The type of the extended location. Known values are: "EdgeZone". + :keyword type: The type of the extended location. "EdgeZone" :paramtype type: str or ~azure.mgmt.storage.v2022_05_01.models.ExtendedLocationTypes """ - super(ExtendedLocation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.type = type -class FileServiceItems(msrest.serialization.Model): +class FileServiceItems(_serialization.Model): """FileServiceItems. Variables are only populated by the server, and will be ignored when sending a request. @@ -2424,20 +2342,16 @@ class FileServiceItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileServiceProperties]'}, + "value": {"key": "value", "type": "[FileServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileServiceItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None @@ -2468,20 +2382,23 @@ class FileServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'sku': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, - 'share_delete_retention_policy': {'key': 'properties.shareDeleteRetentionPolicy', 'type': 'DeleteRetentionPolicy'}, - 'protocol_settings': {'key': 'properties.protocolSettings', 'type': 'ProtocolSettings'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "share_delete_retention_policy": { + "key": "properties.shareDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "protocol_settings": {"key": "properties.protocolSettings", "type": "ProtocolSettings"}, } def __init__( @@ -2503,14 +2420,14 @@ def __init__( :keyword protocol_settings: Protocol settings for file service. :paramtype protocol_settings: ~azure.mgmt.storage.v2022_05_01.models.ProtocolSettings """ - super(FileServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = None self.cors = cors self.share_delete_retention_policy = share_delete_retention_policy self.protocol_settings = protocol_settings -class FileShare(AzureEntityResource): +class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attributes """Properties of the file share, including Id, resource name, resource type, Etag. Variables are only populated by the server, and will be ignored when sending a request. @@ -2533,10 +2450,10 @@ class FileShare(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2022_05_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2022_05_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2548,7 +2465,7 @@ class FileShare(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2556,14 +2473,14 @@ class FileShare(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseStatus :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Known values are: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2022_05_01.models.SignedIdentifier] @@ -2573,48 +2490,48 @@ class FileShare(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2635,19 +2552,19 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2022_05_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2022_05_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2022_05_01.models.SignedIdentifier] """ - super(FileShare, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2668,7 +2585,7 @@ def __init__( self.snapshot_time = None -class FileShareItem(AzureEntityResource): +class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The file share properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -2691,10 +2608,10 @@ class FileShareItem(AzureEntityResource): less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :vartype share_quota: int :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only - be specified when creating a share. Known values are: "SMB", "NFS". + be specified when creating a share. Known values are: "SMB" and "NFS". :vartype enabled_protocols: str or ~azure.mgmt.storage.v2022_05_01.models.EnabledProtocols :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :vartype root_squash: str or ~azure.mgmt.storage.v2022_05_01.models.RootSquashType :ivar version: The version of the share. :vartype version: str @@ -2706,7 +2623,7 @@ class FileShareItem(AzureEntityResource): :vartype remaining_retention_days: int :ivar access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.ShareAccessTier :ivar access_tier_change_time: Indicates the last modification time for share access tier. :vartype access_tier_change_time: ~datetime.datetime @@ -2714,14 +2631,14 @@ class FileShareItem(AzureEntityResource): :vartype access_tier_status: str :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this value may not include all recently created or recently resized files. - :vartype share_usage_bytes: long - :ivar lease_status: The lease status of the share. Known values are: "Locked", "Unlocked". + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseStatus :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, - only when the share is leased. Known values are: "Infinite", "Fixed". + only when the share is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseDuration :ivar signed_identifiers: List of stored access policies specified on the share. :vartype signed_identifiers: list[~azure.mgmt.storage.v2022_05_01.models.SignedIdentifier] @@ -2731,48 +2648,48 @@ class FileShareItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'share_quota': {'maximum': 102400, 'minimum': 1}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'access_tier_change_time': {'readonly': True}, - 'access_tier_status': {'readonly': True}, - 'share_usage_bytes': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'snapshot_time': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'share_quota': {'key': 'properties.shareQuota', 'type': 'int'}, - 'enabled_protocols': {'key': 'properties.enabledProtocols', 'type': 'str'}, - 'root_squash': {'key': 'properties.rootSquash', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'access_tier_change_time': {'key': 'properties.accessTierChangeTime', 'type': 'iso-8601'}, - 'access_tier_status': {'key': 'properties.accessTierStatus', 'type': 'str'}, - 'share_usage_bytes': {'key': 'properties.shareUsageBytes', 'type': 'long'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[SignedIdentifier]'}, - 'snapshot_time': {'key': 'properties.snapshotTime', 'type': 'iso-8601'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, } def __init__( @@ -2793,19 +2710,19 @@ def __init__( less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. :paramtype share_quota: int :keyword enabled_protocols: The authentication protocol that is used for the file share. Can - only be specified when creating a share. Known values are: "SMB", "NFS". + only be specified when creating a share. Known values are: "SMB" and "NFS". :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2022_05_01.models.EnabledProtocols :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known - values are: "NoRootSquash", "RootSquash", "AllSquash". + values are: "NoRootSquash", "RootSquash", and "AllSquash". :paramtype root_squash: str or ~azure.mgmt.storage.v2022_05_01.models.RootSquashType :keyword access_tier: Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known - values are: "TransactionOptimized", "Hot", "Cool", "Premium". + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.ShareAccessTier :keyword signed_identifiers: List of stored access policies specified on the share. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2022_05_01.models.SignedIdentifier] """ - super(FileShareItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.metadata = metadata self.share_quota = share_quota @@ -2826,7 +2743,7 @@ def __init__( self.snapshot_time = None -class FileShareItems(msrest.serialization.Model): +class FileShareItems(_serialization.Model): """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. Variables are only populated by the server, and will be ignored when sending a request. @@ -2839,27 +2756,23 @@ class FileShareItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[FileShareItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(FileShareItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class GeoReplicationStats(msrest.serialization.Model): +class GeoReplicationStats(_serialization.Model): """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -2868,7 +2781,7 @@ class GeoReplicationStats(msrest.serialization.Model): the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the primary location to the secondary location is in progress.This typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary - location is temporarily unavailable. Known values are: "Live", "Bootstrap", "Unavailable". + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". :vartype status: str or ~azure.mgmt.storage.v2022_05_01.models.GeoReplicationStatus :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to be available for read operations. Primary writes following this point in time may or may not be @@ -2881,30 +2794,26 @@ class GeoReplicationStats(msrest.serialization.Model): """ _validation = { - 'status': {'readonly': True}, - 'last_sync_time': {'readonly': True}, - 'can_failover': {'readonly': True}, + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, } _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'last_sync_time': {'key': 'lastSyncTime', 'type': 'iso-8601'}, - 'can_failover': {'key': 'canFailover', 'type': 'bool'}, + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(GeoReplicationStats, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.status = None self.last_sync_time = None self.can_failover = None -class Identity(msrest.serialization.Model): +class Identity(_serialization.Model): """Identity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -2915,8 +2824,8 @@ class Identity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :ivar type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :ivar type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :vartype type: str or ~azure.mgmt.storage.v2022_05_01.models.IdentityType :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2926,16 +2835,16 @@ class Identity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'type': {'required': True}, + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{UserAssignedIdentity}'}, + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, } def __init__( @@ -2946,8 +2855,8 @@ def __init__( **kwargs ): """ - :keyword type: Required. The identity type. Known values are: "None", "SystemAssigned", - "UserAssigned", "SystemAssigned,UserAssigned". + :keyword type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". :paramtype type: str or ~azure.mgmt.storage.v2022_05_01.models.IdentityType :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set of User Assigned identities that will be used with this storage account. The key is the ARM @@ -2955,7 +2864,7 @@ def __init__( :paramtype user_assigned_identities: dict[str, ~azure.mgmt.storage.v2022_05_01.models.UserAssignedIdentity] """ - super(Identity, self).__init__(**kwargs) + super().__init__(**kwargs) self.principal_id = None self.tenant_id = None self.type = type @@ -2981,7 +2890,7 @@ class ImmutabilityPolicy(AzureEntityResource): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -2999,22 +2908,25 @@ class ImmutabilityPolicy(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'properties.allowProtectedAppendWritesAll', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -3043,14 +2955,14 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(ImmutabilityPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days self.state = None self.allow_protected_append_writes = allow_protected_append_writes self.allow_protected_append_writes_all = allow_protected_append_writes_all -class ImmutabilityPolicyProperties(msrest.serialization.Model): +class ImmutabilityPolicyProperties(_serialization.Model): """The properties of an ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3063,7 +2975,7 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): container since the policy creation, in days. :vartype immutability_period_since_creation_in_days: int :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked - and Unlocked. Known values are: "Locked", "Unlocked". + and Unlocked. Known values are: "Locked" and "Unlocked". :vartype state: str or ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicyState :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based retention policies. When enabled, new blocks can be written to an append blob while maintaining @@ -3081,18 +2993,21 @@ class ImmutabilityPolicyProperties(msrest.serialization.Model): """ _validation = { - 'etag': {'readonly': True}, - 'update_history': {'readonly': True}, - 'state': {'readonly': True}, + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, } _attribute_map = { - 'etag': {'key': 'etag', 'type': 'str'}, - 'update_history': {'key': 'updateHistory', 'type': '[UpdateHistoryProperty]'}, - 'immutability_period_since_creation_in_days': {'key': 'properties.immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'state': {'key': 'properties.state', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'properties.allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'properties.allowProtectedAppendWritesAll', 'type': 'bool'}, + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -3121,7 +3036,7 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(ImmutabilityPolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.etag = None self.update_history = None self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days @@ -3130,7 +3045,7 @@ def __init__( self.allow_protected_append_writes_all = allow_protected_append_writes_all -class ImmutableStorageAccount(msrest.serialization.Model): +class ImmutableStorageAccount(_serialization.Model): """This property enables and defines account-level immutability. Enabling the feature auto-enables Blob Versioning. :ivar enabled: A boolean flag which enables account-level immutability. All the containers @@ -3146,8 +3061,8 @@ class ImmutableStorageAccount(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'immutability_policy': {'key': 'immutabilityPolicy', 'type': 'AccountImmutabilityPolicyProperties'}, + "enabled": {"key": "enabled", "type": "bool"}, + "immutability_policy": {"key": "immutabilityPolicy", "type": "AccountImmutabilityPolicyProperties"}, } def __init__( @@ -3169,12 +3084,12 @@ def __init__( :paramtype immutability_policy: ~azure.mgmt.storage.v2022_05_01.models.AccountImmutabilityPolicyProperties """ - super(ImmutableStorageAccount, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.immutability_policy = immutability_policy -class ImmutableStorageWithVersioning(msrest.serialization.Model): +class ImmutableStorageWithVersioning(_serialization.Model): """Object level immutability properties of the container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3185,81 +3100,68 @@ class ImmutableStorageWithVersioning(msrest.serialization.Model): :ivar time_stamp: Returns the date and time the object level immutability was enabled. :vartype time_stamp: ~datetime.datetime :ivar migration_state: This property denotes the container level immutability to object level - immutability migration state. Known values are: "InProgress", "Completed". + immutability migration state. Known values are: "InProgress" and "Completed". :vartype migration_state: str or ~azure.mgmt.storage.v2022_05_01.models.MigrationState """ _validation = { - 'time_stamp': {'readonly': True}, - 'migration_state': {'readonly': True}, + "time_stamp": {"readonly": True}, + "migration_state": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'time_stamp': {'key': 'timeStamp', 'type': 'iso-8601'}, - 'migration_state': {'key': 'migrationState', 'type': 'str'}, + "enabled": {"key": "enabled", "type": "bool"}, + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "migration_state": {"key": "migrationState", "type": "str"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: This is an immutable property, when set to true it enables object level immutability at the container level. :paramtype enabled: bool """ - super(ImmutableStorageWithVersioning, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.time_stamp = None self.migration_state = None -class IPRule(msrest.serialization.Model): +class IPRule(_serialization.Model): """IP rule with specific IP or IP range in CIDR format. All required parameters must be populated in order to send to Azure. - :ivar ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :vartype ip_address_or_range: str - :ivar action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :ivar action: The action of IP ACL rule. Default value is "Allow". :vartype action: str """ _validation = { - 'ip_address_or_range': {'required': True}, + "ip_address_or_range": {"required": True}, } _attribute_map = { - 'ip_address_or_range': {'key': 'value', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, } - def __init__( - self, - *, - ip_address_or_range: str, - action: Optional[str] = None, - **kwargs - ): + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): """ - :keyword ip_address_or_range: Required. Specifies the IP or IP range in CIDR format. Only IPV4 - address is allowed. + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. :paramtype ip_address_or_range: str - :keyword action: The action of IP ACL rule. The only acceptable values to pass in are None and - "Allow". The default value is None. + :keyword action: The action of IP ACL rule. Default value is "Allow". :paramtype action: str """ - super(IPRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.ip_address_or_range = ip_address_or_range self.action = action -class KeyCreationTime(msrest.serialization.Model): +class KeyCreationTime(_serialization.Model): """Storage account keys creation time. :ivar key1: @@ -3269,60 +3171,49 @@ class KeyCreationTime(msrest.serialization.Model): """ _attribute_map = { - 'key1': {'key': 'key1', 'type': 'iso-8601'}, - 'key2': {'key': 'key2', 'type': 'iso-8601'}, + "key1": {"key": "key1", "type": "iso-8601"}, + "key2": {"key": "key2", "type": "iso-8601"}, } - def __init__( - self, - *, - key1: Optional[datetime.datetime] = None, - key2: Optional[datetime.datetime] = None, - **kwargs - ): + def __init__(self, *, key1: Optional[datetime.datetime] = None, key2: Optional[datetime.datetime] = None, **kwargs): """ :keyword key1: :paramtype key1: ~datetime.datetime :keyword key2: :paramtype key2: ~datetime.datetime """ - super(KeyCreationTime, self).__init__(**kwargs) + super().__init__(**kwargs) self.key1 = key1 self.key2 = key2 -class KeyPolicy(msrest.serialization.Model): +class KeyPolicy(_serialization.Model): """KeyPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar key_expiration_period_in_days: Required. The key expiration period in days. + :ivar key_expiration_period_in_days: The key expiration period in days. Required. :vartype key_expiration_period_in_days: int """ _validation = { - 'key_expiration_period_in_days': {'required': True}, + "key_expiration_period_in_days": {"required": True}, } _attribute_map = { - 'key_expiration_period_in_days': {'key': 'keyExpirationPeriodInDays', 'type': 'int'}, + "key_expiration_period_in_days": {"key": "keyExpirationPeriodInDays", "type": "int"}, } - def __init__( - self, - *, - key_expiration_period_in_days: int, - **kwargs - ): + def __init__(self, *, key_expiration_period_in_days: int, **kwargs): """ - :keyword key_expiration_period_in_days: Required. The key expiration period in days. + :keyword key_expiration_period_in_days: The key expiration period in days. Required. :paramtype key_expiration_period_in_days: int """ - super(KeyPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_expiration_period_in_days = key_expiration_period_in_days -class KeyVaultProperties(msrest.serialization.Model): +class KeyVaultProperties(_serialization.Model): """Properties of key vault. Variables are only populated by the server, and will be ignored when sending a request. @@ -3344,18 +3235,21 @@ class KeyVaultProperties(msrest.serialization.Model): """ _validation = { - 'current_versioned_key_identifier': {'readonly': True}, - 'last_key_rotation_timestamp': {'readonly': True}, - 'current_versioned_key_expiration_timestamp': {'readonly': True}, + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, + "current_versioned_key_expiration_timestamp": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyname', 'type': 'str'}, - 'key_version': {'key': 'keyversion', 'type': 'str'}, - 'key_vault_uri': {'key': 'keyvaulturi', 'type': 'str'}, - 'current_versioned_key_identifier': {'key': 'currentVersionedKeyIdentifier', 'type': 'str'}, - 'last_key_rotation_timestamp': {'key': 'lastKeyRotationTimestamp', 'type': 'iso-8601'}, - 'current_versioned_key_expiration_timestamp': {'key': 'currentVersionedKeyExpirationTimestamp', 'type': 'iso-8601'}, + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, + "current_versioned_key_expiration_timestamp": { + "key": "currentVersionedKeyExpirationTimestamp", + "type": "iso-8601", + }, } def __init__( @@ -3374,7 +3268,7 @@ def __init__( :keyword key_vault_uri: The Uri of KeyVault. :paramtype key_vault_uri: str """ - super(KeyVaultProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name self.key_version = key_version self.key_vault_uri = key_vault_uri @@ -3383,15 +3277,15 @@ def __init__( self.current_versioned_key_expiration_timestamp = None -class LastAccessTimeTrackingPolicy(msrest.serialization.Model): +class LastAccessTimeTrackingPolicy(_serialization.Model): """The blob service properties for Last access time based tracking policy. All required parameters must be populated in order to send to Azure. - :ivar enable: Required. When set to true last access time based tracking is enabled. + :ivar enable: When set to true last access time based tracking is enabled. Required. :vartype enable: bool :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently - read only. Known values are: "AccessTimeTracking". + read only. "AccessTimeTracking" :vartype name: str or ~azure.mgmt.storage.v2022_05_01.models.Name :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3403,14 +3297,14 @@ class LastAccessTimeTrackingPolicy(msrest.serialization.Model): """ _validation = { - 'enable': {'required': True}, + "enable": {"required": True}, } _attribute_map = { - 'enable': {'key': 'enable', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'tracking_granularity_in_days': {'key': 'trackingGranularityInDays', 'type': 'int'}, - 'blob_type': {'key': 'blobType', 'type': '[str]'}, + "enable": {"key": "enable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "tracking_granularity_in_days": {"key": "trackingGranularityInDays", "type": "int"}, + "blob_type": {"key": "blobType", "type": "[str]"}, } def __init__( @@ -3423,10 +3317,10 @@ def __init__( **kwargs ): """ - :keyword enable: Required. When set to true last access time based tracking is enabled. + :keyword enable: When set to true last access time based tracking is enabled. Required. :paramtype enable: bool :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is - currently read only. Known values are: "AccessTimeTracking". + currently read only. "AccessTimeTracking" :paramtype name: str or ~azure.mgmt.storage.v2022_05_01.models.Name :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in days, typically how often the blob object should be tracked.This field is currently read only @@ -3436,20 +3330,20 @@ def __init__( supported value. This field is currently read only. :paramtype blob_type: list[str] """ - super(LastAccessTimeTrackingPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.enable = enable self.name = name self.tracking_granularity_in_days = tracking_granularity_in_days self.blob_type = blob_type -class LeaseContainerRequest(msrest.serialization.Model): +class LeaseContainerRequest(_serialization.Model): """Lease Container request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequestEnum :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3465,15 +3359,15 @@ class LeaseContainerRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -3487,8 +3381,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequestEnum :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3502,7 +3396,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseContainerRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -3510,7 +3404,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseContainerResponse(msrest.serialization.Model): +class LeaseContainerResponse(_serialization.Model): """Lease Container response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -3521,17 +3415,11 @@ class LeaseContainerResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the container, or to renew, change, or release the lease. @@ -3539,18 +3427,18 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseContainerResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LeaseShareRequest(msrest.serialization.Model): +class LeaseShareRequest(_serialization.Model): """Lease Share request schema. All required parameters must be populated in order to send to Azure. - :ivar action: Required. Specifies the lease action. Can be one of the available actions. Known - values are: "Acquire", "Renew", "Change", "Release", "Break". + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". :vartype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseShareAction :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. :vartype lease_id: str @@ -3566,15 +3454,15 @@ class LeaseShareRequest(msrest.serialization.Model): """ _validation = { - 'action': {'required': True}, + "action": {"required": True}, } _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'break_period': {'key': 'breakPeriod', 'type': 'int'}, - 'lease_duration': {'key': 'leaseDuration', 'type': 'int'}, - 'proposed_lease_id': {'key': 'proposedLeaseId', 'type': 'str'}, + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, } def __init__( @@ -3588,8 +3476,8 @@ def __init__( **kwargs ): """ - :keyword action: Required. Specifies the lease action. Can be one of the available actions. - Known values are: "Acquire", "Renew", "Change", "Release", "Break". + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". :paramtype action: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseShareAction :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. :paramtype lease_id: str @@ -3603,7 +3491,7 @@ def __init__( GUID string format. :paramtype proposed_lease_id: str """ - super(LeaseShareRequest, self).__init__(**kwargs) + super().__init__(**kwargs) self.action = action self.lease_id = lease_id self.break_period = break_period @@ -3611,7 +3499,7 @@ def __init__( self.proposed_lease_id = proposed_lease_id -class LeaseShareResponse(msrest.serialization.Model): +class LeaseShareResponse(_serialization.Model): """Lease Share response schema. :ivar lease_id: Returned unique lease ID that must be included with any request to delete the @@ -3622,17 +3510,11 @@ class LeaseShareResponse(msrest.serialization.Model): """ _attribute_map = { - 'lease_id': {'key': 'leaseId', 'type': 'str'}, - 'lease_time_seconds': {'key': 'leaseTimeSeconds', 'type': 'str'}, + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, } - def __init__( - self, - *, - lease_id: Optional[str] = None, - lease_time_seconds: Optional[str] = None, - **kwargs - ): + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): """ :keyword lease_id: Returned unique lease ID that must be included with any request to delete the share, or to renew, change, or release the lease. @@ -3640,12 +3522,12 @@ def __init__( :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. :paramtype lease_time_seconds: str """ - super(LeaseShareResponse, self).__init__(**kwargs) + super().__init__(**kwargs) self.lease_id = lease_id self.lease_time_seconds = lease_time_seconds -class LegalHold(msrest.serialization.Model): +class LegalHold(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3657,8 +3539,8 @@ class LegalHold(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and is - normalized to lower case at SRP. + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. :vartype tags: list[str] :ivar allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks @@ -3667,39 +3549,33 @@ class LegalHold(msrest.serialization.Model): """ _validation = { - 'has_legal_hold': {'readonly': True}, - 'tags': {'required': True}, + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[str]'}, - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, } - def __init__( - self, - *, - tags: List[str], - allow_protected_append_writes_all: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, tags: List[str], allow_protected_append_writes_all: Optional[bool] = None, **kwargs): """ - :keyword tags: Required. A set of tags. Each tag should be 3 to 23 alphanumeric characters and - is normalized to lower case at SRP. + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. :paramtype tags: list[str] :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes_all: bool """ - super(LegalHold, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags self.allow_protected_append_writes_all = allow_protected_append_writes_all -class LegalHoldProperties(msrest.serialization.Model): +class LegalHoldProperties(_serialization.Model): """The LegalHold property of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -3709,7 +3585,7 @@ class LegalHoldProperties(msrest.serialization.Model): legal hold tags are cleared out. There can be a maximum of 1000 blob containers with hasLegalHold=true for a given account. :vartype has_legal_hold: bool - :ivar tags: A set of tags. The list of LegalHold tags of a blob container. + :ivar tags: The list of LegalHold tags of a blob container. :vartype tags: list[~azure.mgmt.storage.v2022_05_01.models.TagProperty] :ivar protected_append_writes_history: Protected append blob writes history. :vartype protected_append_writes_history: @@ -3717,13 +3593,16 @@ class LegalHoldProperties(msrest.serialization.Model): """ _validation = { - 'has_legal_hold': {'readonly': True}, + "has_legal_hold": {"readonly": True}, } _attribute_map = { - 'has_legal_hold': {'key': 'hasLegalHold', 'type': 'bool'}, - 'tags': {'key': 'tags', 'type': '[TagProperty]'}, - 'protected_append_writes_history': {'key': 'protectedAppendWritesHistory', 'type': 'ProtectedAppendWritesHistory'}, + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, + "protected_append_writes_history": { + "key": "protectedAppendWritesHistory", + "type": "ProtectedAppendWritesHistory", + }, } def __init__( @@ -3734,19 +3613,19 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. The list of LegalHold tags of a blob container. + :keyword tags: The list of LegalHold tags of a blob container. :paramtype tags: list[~azure.mgmt.storage.v2022_05_01.models.TagProperty] :keyword protected_append_writes_history: Protected append blob writes history. :paramtype protected_append_writes_history: ~azure.mgmt.storage.v2022_05_01.models.ProtectedAppendWritesHistory """ - super(LegalHoldProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.has_legal_hold = None self.tags = tags self.protected_append_writes_history = protected_append_writes_history -class ListAccountSasResponse(msrest.serialization.Model): +class ListAccountSasResponse(_serialization.Model): """The List SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -3756,24 +3635,20 @@ class ListAccountSasResponse(msrest.serialization.Model): """ _validation = { - 'account_sas_token': {'readonly': True}, + "account_sas_token": {"readonly": True}, } _attribute_map = { - 'account_sas_token': {'key': 'accountSasToken', 'type': 'str'}, + "account_sas_token": {"key": "accountSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListAccountSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.account_sas_token = None -class ListBlobInventoryPolicy(msrest.serialization.Model): +class ListBlobInventoryPolicy(_serialization.Model): """List of blob inventory policies returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -3783,24 +3658,20 @@ class ListBlobInventoryPolicy(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[BlobInventoryPolicy]'}, + "value": {"key": "value", "type": "[BlobInventoryPolicy]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListBlobInventoryPolicy, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListContainerItem(AzureEntityResource): +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes """The blob container properties be listed out. Variables are only populated by the server, and will be ignored when sending a request. @@ -3830,17 +3701,18 @@ class ListContainerItem(AzureEntityResource): default. :vartype deny_encryption_scope_override: bool :ivar public_access: Specifies whether data in the container may be accessed publicly and the - level of access. Known values are: "Container", "Blob", "None". + level of access. Known values are: "Container", "Blob", and "None". :vartype public_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicAccess :ivar last_modified_time: Returns the date and time the container was last modified. :vartype last_modified_time: ~datetime.datetime - :ivar lease_status: The lease status of the container. Known values are: "Locked", "Unlocked". + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". :vartype lease_status: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseStatus :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", - "Expired", "Breaking", "Broken". + "Expired", "Breaking", and "Broken". :vartype lease_state: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseState :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed - duration, only when the container is leased. Known values are: "Infinite", "Fixed". + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". :vartype lease_duration: str or ~azure.mgmt.storage.v2022_05_01.models.LeaseDuration :ivar metadata: A name-value pair to associate with the container as metadata. :vartype metadata: dict[str, str] @@ -3870,48 +3742,51 @@ class ListContainerItem(AzureEntityResource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'etag': {'readonly': True}, - 'version': {'readonly': True}, - 'deleted': {'readonly': True}, - 'deleted_time': {'readonly': True}, - 'remaining_retention_days': {'readonly': True}, - 'last_modified_time': {'readonly': True}, - 'lease_status': {'readonly': True}, - 'lease_state': {'readonly': True}, - 'lease_duration': {'readonly': True}, - 'immutability_policy': {'readonly': True}, - 'legal_hold': {'readonly': True}, - 'has_legal_hold': {'readonly': True}, - 'has_immutability_policy': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'version': {'key': 'properties.version', 'type': 'str'}, - 'deleted': {'key': 'properties.deleted', 'type': 'bool'}, - 'deleted_time': {'key': 'properties.deletedTime', 'type': 'iso-8601'}, - 'remaining_retention_days': {'key': 'properties.remainingRetentionDays', 'type': 'int'}, - 'default_encryption_scope': {'key': 'properties.defaultEncryptionScope', 'type': 'str'}, - 'deny_encryption_scope_override': {'key': 'properties.denyEncryptionScopeOverride', 'type': 'bool'}, - 'public_access': {'key': 'properties.publicAccess', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'lease_status': {'key': 'properties.leaseStatus', 'type': 'str'}, - 'lease_state': {'key': 'properties.leaseState', 'type': 'str'}, - 'lease_duration': {'key': 'properties.leaseDuration', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'immutability_policy': {'key': 'properties.immutabilityPolicy', 'type': 'ImmutabilityPolicyProperties'}, - 'legal_hold': {'key': 'properties.legalHold', 'type': 'LegalHoldProperties'}, - 'has_legal_hold': {'key': 'properties.hasLegalHold', 'type': 'bool'}, - 'has_immutability_policy': {'key': 'properties.hasImmutabilityPolicy', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageWithVersioning'}, - 'enable_nfs_v3_root_squash': {'key': 'properties.enableNfsV3RootSquash', 'type': 'bool'}, - 'enable_nfs_v3_all_squash': {'key': 'properties.enableNfsV3AllSquash', 'type': 'bool'}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, } def __init__( @@ -3934,7 +3809,7 @@ def __init__( default. :paramtype deny_encryption_scope_override: bool :keyword public_access: Specifies whether data in the container may be accessed publicly and - the level of access. Known values are: "Container", "Blob", "None". + the level of access. Known values are: "Container", "Blob", and "None". :paramtype public_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicAccess :keyword metadata: A name-value pair to associate with the container as metadata. :paramtype metadata: dict[str, str] @@ -3948,7 +3823,7 @@ def __init__( :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. :paramtype enable_nfs_v3_all_squash: bool """ - super(ListContainerItem, self).__init__(**kwargs) + super().__init__(**kwargs) self.version = None self.deleted = None self.deleted_time = None @@ -3970,7 +3845,7 @@ def __init__( self.enable_nfs_v3_all_squash = enable_nfs_v3_all_squash -class ListContainerItems(msrest.serialization.Model): +class ListContainerItems(_serialization.Model): """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. Variables are only populated by the server, and will be ignored when sending a request. @@ -3983,22 +3858,18 @@ class ListContainerItems(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListContainerItem]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListContainerItems, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None @@ -4021,33 +3892,28 @@ class ListQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(ListQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata -class ListQueueResource(msrest.serialization.Model): +class ListQueueResource(_serialization.Model): """Response schema. Contains list of queues returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -4059,27 +3925,23 @@ class ListQueueResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[ListQueue]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[ListQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListQueueServices(msrest.serialization.Model): +class ListQueueServices(_serialization.Model): """ListQueueServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -4089,24 +3951,20 @@ class ListQueueServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[QueueServiceProperties]'}, + "value": {"key": "value", "type": "[QueueServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListQueueServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class ListServiceSasResponse(msrest.serialization.Model): +class ListServiceSasResponse(_serialization.Model): """The List service SAS credentials operation response. Variables are only populated by the server, and will be ignored when sending a request. @@ -4116,24 +3974,20 @@ class ListServiceSasResponse(msrest.serialization.Model): """ _validation = { - 'service_sas_token': {'readonly': True}, + "service_sas_token": {"readonly": True}, } _attribute_map = { - 'service_sas_token': {'key': 'serviceSasToken', 'type': 'str'}, + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListServiceSasResponse, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.service_sas_token = None -class ListTableResource(msrest.serialization.Model): +class ListTableResource(_serialization.Model): """Response schema. Contains list of tables returned. Variables are only populated by the server, and will be ignored when sending a request. @@ -4145,27 +3999,23 @@ class ListTableResource(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[Table]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[Table]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableResource, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class ListTableServices(msrest.serialization.Model): +class ListTableServices(_serialization.Model): """ListTableServices. Variables are only populated by the server, and will be ignored when sending a request. @@ -4175,24 +4025,20 @@ class ListTableServices(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[TableServiceProperties]'}, + "value": {"key": "value", "type": "[TableServiceProperties]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(ListTableServices, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class LocalUser(Resource): +class LocalUser(Resource): # pylint: disable=too-many-instance-attributes """The local user associated with the storage accounts. Variables are only populated by the server, and will be ignored when sending a request. @@ -4227,25 +4073,25 @@ class LocalUser(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - 'sid': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "sid": {"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'}, - 'permission_scopes': {'key': 'properties.permissionScopes', 'type': '[PermissionScope]'}, - 'home_directory': {'key': 'properties.homeDirectory', 'type': 'str'}, - 'ssh_authorized_keys': {'key': 'properties.sshAuthorizedKeys', 'type': '[SshPublicKey]'}, - 'sid': {'key': 'properties.sid', 'type': 'str'}, - 'has_shared_key': {'key': 'properties.hasSharedKey', 'type': 'bool'}, - 'has_ssh_key': {'key': 'properties.hasSshKey', 'type': 'bool'}, - 'has_ssh_password': {'key': 'properties.hasSshPassword', 'type': 'bool'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "system_data": {"key": "systemData", "type": "SystemData"}, + "permission_scopes": {"key": "properties.permissionScopes", "type": "[PermissionScope]"}, + "home_directory": {"key": "properties.homeDirectory", "type": "str"}, + "ssh_authorized_keys": {"key": "properties.sshAuthorizedKeys", "type": "[SshPublicKey]"}, + "sid": {"key": "properties.sid", "type": "str"}, + "has_shared_key": {"key": "properties.hasSharedKey", "type": "bool"}, + "has_ssh_key": {"key": "properties.hasSshKey", "type": "bool"}, + "has_ssh_password": {"key": "properties.hasSshPassword", "type": "bool"}, } def __init__( @@ -4276,7 +4122,7 @@ def __init__( existing SSH password. :paramtype has_ssh_password: bool """ - super(LocalUser, self).__init__(**kwargs) + super().__init__(**kwargs) self.system_data = None self.permission_scopes = permission_scopes self.home_directory = home_directory @@ -4287,7 +4133,7 @@ def __init__( self.has_ssh_password = has_ssh_password -class LocalUserKeys(msrest.serialization.Model): +class LocalUserKeys(_serialization.Model): """The Storage Account Local User keys. Variables are only populated by the server, and will be ignored when sending a request. @@ -4299,30 +4145,25 @@ class LocalUserKeys(msrest.serialization.Model): """ _validation = { - 'shared_key': {'readonly': True}, + "shared_key": {"readonly": True}, } _attribute_map = { - 'ssh_authorized_keys': {'key': 'sshAuthorizedKeys', 'type': '[SshPublicKey]'}, - 'shared_key': {'key': 'sharedKey', 'type': 'str'}, + "ssh_authorized_keys": {"key": "sshAuthorizedKeys", "type": "[SshPublicKey]"}, + "shared_key": {"key": "sharedKey", "type": "str"}, } - def __init__( - self, - *, - ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, - **kwargs - ): + def __init__(self, *, ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs): """ :keyword ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. :paramtype ssh_authorized_keys: list[~azure.mgmt.storage.v2022_05_01.models.SshPublicKey] """ - super(LocalUserKeys, self).__init__(**kwargs) + super().__init__(**kwargs) self.ssh_authorized_keys = ssh_authorized_keys self.shared_key = None -class LocalUserRegeneratePasswordResult(msrest.serialization.Model): +class LocalUserRegeneratePasswordResult(_serialization.Model): """The secrets of Storage Account Local User. Variables are only populated by the server, and will be ignored when sending a request. @@ -4333,24 +4174,20 @@ class LocalUserRegeneratePasswordResult(msrest.serialization.Model): """ _validation = { - 'ssh_password': {'readonly': True}, + "ssh_password": {"readonly": True}, } _attribute_map = { - 'ssh_password': {'key': 'sshPassword', 'type': 'str'}, + "ssh_password": {"key": "sshPassword", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(LocalUserRegeneratePasswordResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.ssh_password = None -class LocalUsers(msrest.serialization.Model): +class LocalUsers(_serialization.Model): """List storage account local users. :ivar value: The local users associated with the storage account. @@ -4358,20 +4195,15 @@ class LocalUsers(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[LocalUser]'}, + "value": {"key": "value", "type": "[LocalUser]"}, } - def __init__( - self, - *, - value: Optional[List["_models.LocalUser"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.LocalUser"]] = None, **kwargs): """ :keyword value: The local users associated with the storage account. :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.LocalUser] """ - super(LocalUsers, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -4396,37 +4228,32 @@ class ManagementPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'last_modified_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'last_modified_time': {'key': 'properties.lastModifiedTime', 'type': 'iso-8601'}, - 'policy': {'key': 'properties.policy', 'type': 'ManagementPolicySchema'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, } - def __init__( - self, - *, - policy: Optional["_models.ManagementPolicySchema"] = None, - **kwargs - ): + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): """ :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. :paramtype policy: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicySchema """ - super(ManagementPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.last_modified_time = None self.policy = policy -class ManagementPolicyAction(msrest.serialization.Model): +class ManagementPolicyAction(_serialization.Model): """Actions are applied to the filtered blobs when the execution condition is met. :ivar base_blob: The management policy action for base blob. @@ -4438,9 +4265,9 @@ class ManagementPolicyAction(msrest.serialization.Model): """ _attribute_map = { - 'base_blob': {'key': 'baseBlob', 'type': 'ManagementPolicyBaseBlob'}, - 'snapshot': {'key': 'snapshot', 'type': 'ManagementPolicySnapShot'}, - 'version': {'key': 'version', 'type': 'ManagementPolicyVersion'}, + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, + "version": {"key": "version", "type": "ManagementPolicyVersion"}, } def __init__( @@ -4459,13 +4286,13 @@ def __init__( :keyword version: The management policy action for version. :paramtype version: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyVersion """ - super(ManagementPolicyAction, self).__init__(**kwargs) + super().__init__(**kwargs) self.base_blob = base_blob self.snapshot = snapshot self.version = version -class ManagementPolicyBaseBlob(msrest.serialization.Model): +class ManagementPolicyBaseBlob(_serialization.Model): """Management policy action for base blob. :ivar tier_to_cool: The function to tier blobs to cool storage. Support blobs currently at Hot @@ -4482,10 +4309,10 @@ class ManagementPolicyBaseBlob(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterModification'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterModification'}, - 'delete': {'key': 'delete', 'type': 'DateAfterModification'}, - 'enable_auto_tier_to_hot_from_cool': {'key': 'enableAutoTierToHotFromCool', 'type': 'bool'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, + "enable_auto_tier_to_hot_from_cool": {"key": "enableAutoTierToHotFromCool", "type": "bool"}, } def __init__( @@ -4511,31 +4338,31 @@ def __init__( tierToCool.daysAfterLastAccessTimeGreaterThan. :paramtype enable_auto_tier_to_hot_from_cool: bool """ - super(ManagementPolicyBaseBlob, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool -class ManagementPolicyDefinition(msrest.serialization.Model): +class ManagementPolicyDefinition(_serialization.Model): """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. All required parameters must be populated in order to send to Azure. - :ivar actions: Required. An object that defines the action set. + :ivar actions: An object that defines the action set. Required. :vartype actions: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyAction :ivar filters: An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyFilter """ _validation = { - 'actions': {'required': True}, + "actions": {"required": True}, } _attribute_map = { - 'actions': {'key': 'actions', 'type': 'ManagementPolicyAction'}, - 'filters': {'key': 'filters', 'type': 'ManagementPolicyFilter'}, + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, } def __init__( @@ -4546,25 +4373,25 @@ def __init__( **kwargs ): """ - :keyword actions: Required. An object that defines the action set. + :keyword actions: An object that defines the action set. Required. :paramtype actions: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyAction :keyword filters: An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyFilter """ - super(ManagementPolicyDefinition, self).__init__(**kwargs) + super().__init__(**kwargs) self.actions = actions self.filters = filters -class ManagementPolicyFilter(msrest.serialization.Model): +class ManagementPolicyFilter(_serialization.Model): """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. All required parameters must be populated in order to send to Azure. :ivar prefix_match: An array of strings for prefixes to be match. :vartype prefix_match: list[str] - :ivar blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :ivar blob_types: An array of predefined enum values. Currently blockBlob supports all tiering + and delete actions. Only delete actions are supported for appendBlob. Required. :vartype blob_types: list[str] :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. @@ -4572,13 +4399,13 @@ class ManagementPolicyFilter(msrest.serialization.Model): """ _validation = { - 'blob_types': {'required': True}, + "blob_types": {"required": True}, } _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'blob_types': {'key': 'blobTypes', 'type': '[str]'}, - 'blob_index_match': {'key': 'blobIndexMatch', 'type': '[TagFilter]'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "blob_index_match": {"key": "blobIndexMatch", "type": "[TagFilter]"}, } def __init__( @@ -4592,46 +4419,46 @@ def __init__( """ :keyword prefix_match: An array of strings for prefixes to be match. :paramtype prefix_match: list[str] - :keyword blob_types: Required. An array of predefined enum values. Currently blockBlob supports - all tiering and delete actions. Only delete actions are supported for appendBlob. + :keyword blob_types: An array of predefined enum values. Currently blockBlob supports all + tiering and delete actions. Only delete actions are supported for appendBlob. Required. :paramtype blob_types: list[str] :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 tag filters. :paramtype blob_index_match: list[~azure.mgmt.storage.v2022_05_01.models.TagFilter] """ - super(ManagementPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.blob_types = blob_types self.blob_index_match = blob_index_match -class ManagementPolicyRule(msrest.serialization.Model): +class ManagementPolicyRule(_serialization.Model): """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. All required parameters must be populated in order to send to Azure. :ivar enabled: Rule is enabled if set to true. :vartype enabled: bool - :ivar name: Required. A rule name can contain any combination of alpha numeric characters. Rule - name is case-sensitive. It must be unique within a policy. + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. :vartype name: str - :ivar type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" :vartype type: str or ~azure.mgmt.storage.v2022_05_01.models.RuleType - :ivar definition: Required. An object that defines the Lifecycle rule. + :ivar definition: An object that defines the Lifecycle rule. Required. :vartype definition: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyDefinition """ _validation = { - 'name': {'required': True}, - 'type': {'required': True}, - 'definition': {'required': True}, + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'definition': {'key': 'definition', 'type': 'ManagementPolicyDefinition'}, + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, } def __init__( @@ -4646,55 +4473,52 @@ def __init__( """ :keyword enabled: Rule is enabled if set to true. :paramtype enabled: bool - :keyword name: Required. A rule name can contain any combination of alpha numeric characters. - Rule name is case-sensitive. It must be unique within a policy. + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. :paramtype name: str - :keyword type: Required. The valid value is Lifecycle. Known values are: "Lifecycle". + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" :paramtype type: str or ~azure.mgmt.storage.v2022_05_01.models.RuleType - :keyword definition: Required. An object that defines the Lifecycle rule. + :keyword definition: An object that defines the Lifecycle rule. Required. :paramtype definition: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyDefinition """ - super(ManagementPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.name = name self.type = type self.definition = definition -class ManagementPolicySchema(msrest.serialization.Model): +class ManagementPolicySchema(_serialization.Model): """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. All required parameters must be populated in order to send to Azure. - :ivar rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :vartype rules: list[~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyRule] """ _validation = { - 'rules': {'required': True}, + "rules": {"required": True}, } _attribute_map = { - 'rules': {'key': 'rules', 'type': '[ManagementPolicyRule]'}, + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, } - def __init__( - self, - *, - rules: List["_models.ManagementPolicyRule"], - **kwargs - ): + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): """ - :keyword rules: Required. The Storage Account ManagementPolicies Rules. See more details in: + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. :paramtype rules: list[~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyRule] """ - super(ManagementPolicySchema, self).__init__(**kwargs) + super().__init__(**kwargs) self.rules = rules -class ManagementPolicySnapShot(msrest.serialization.Model): +class ManagementPolicySnapShot(_serialization.Model): """Management policy action for snapshot. :ivar tier_to_cool: The function to tier blob snapshot to cool storage. Support blob snapshot @@ -4708,9 +4532,9 @@ class ManagementPolicySnapShot(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -4731,13 +4555,13 @@ def __init__( :keyword delete: The function to delete the blob snapshot. :paramtype delete: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation """ - super(ManagementPolicySnapShot, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class ManagementPolicyVersion(msrest.serialization.Model): +class ManagementPolicyVersion(_serialization.Model): """Management policy action for blob version. :ivar tier_to_cool: The function to tier blob version to cool storage. Support blob version @@ -4751,9 +4575,9 @@ class ManagementPolicyVersion(msrest.serialization.Model): """ _attribute_map = { - 'tier_to_cool': {'key': 'tierToCool', 'type': 'DateAfterCreation'}, - 'tier_to_archive': {'key': 'tierToArchive', 'type': 'DateAfterCreation'}, - 'delete': {'key': 'delete', 'type': 'DateAfterCreation'}, + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, } def __init__( @@ -4774,13 +4598,13 @@ def __init__( :keyword delete: The function to delete the blob version. :paramtype delete: ~azure.mgmt.storage.v2022_05_01.models.DateAfterCreation """ - super(ManagementPolicyVersion, self).__init__(**kwargs) + super().__init__(**kwargs) self.tier_to_cool = tier_to_cool self.tier_to_archive = tier_to_archive self.delete = delete -class MetricSpecification(msrest.serialization.Model): +class MetricSpecification(_serialization.Model): """Metric specification of operation. :ivar name: Name of metric specification. @@ -4804,15 +4628,15 @@ class MetricSpecification(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display_name': {'key': 'displayName', 'type': 'str'}, - 'display_description': {'key': 'displayDescription', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'dimensions': {'key': 'dimensions', 'type': '[Dimension]'}, - 'aggregation_type': {'key': 'aggregationType', 'type': 'str'}, - 'fill_gap_with_zero': {'key': 'fillGapWithZero', 'type': 'bool'}, - 'category': {'key': 'category', 'type': 'str'}, - 'resource_id_dimension_name_override': {'key': 'resourceIdDimensionNameOverride', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, } def __init__( @@ -4849,7 +4673,7 @@ def __init__( :keyword resource_id_dimension_name_override: Account Resource Id. :paramtype resource_id_dimension_name_override: str """ - super(MetricSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display_name = display_name self.display_description = display_description @@ -4861,7 +4685,7 @@ def __init__( self.resource_id_dimension_name_override = resource_id_dimension_name_override -class Multichannel(msrest.serialization.Model): +class Multichannel(_serialization.Model): """Multichannel setting. Applies to Premium FileStorage only. :ivar enabled: Indicates whether multichannel is enabled. @@ -4869,32 +4693,27 @@ class Multichannel(msrest.serialization.Model): """ _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, + "enabled": {"key": "enabled", "type": "bool"}, } - def __init__( - self, - *, - enabled: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): """ :keyword enabled: Indicates whether multichannel is enabled. :paramtype enabled: bool """ - super(Multichannel, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled -class NetworkRuleSet(msrest.serialization.Model): +class NetworkRuleSet(_serialization.Model): """Network rule set. All required parameters must be populated in order to send to Azure. :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), - or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", - "AzureServices". Default value: "AzureServices". + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". :vartype bypass: str or ~azure.mgmt.storage.v2022_05_01.models.Bypass :ivar resource_access_rules: Sets the resource access rules. :vartype resource_access_rules: list[~azure.mgmt.storage.v2022_05_01.models.ResourceAccessRule] @@ -4902,28 +4721,28 @@ class NetworkRuleSet(msrest.serialization.Model): :vartype virtual_network_rules: list[~azure.mgmt.storage.v2022_05_01.models.VirtualNetworkRule] :ivar ip_rules: Sets the IP ACL rules. :vartype ip_rules: list[~azure.mgmt.storage.v2022_05_01.models.IPRule] - :ivar default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". :vartype default_action: str or ~azure.mgmt.storage.v2022_05_01.models.DefaultAction """ _validation = { - 'default_action': {'required': True}, + "default_action": {"required": True}, } _attribute_map = { - 'bypass': {'key': 'bypass', 'type': 'str'}, - 'resource_access_rules': {'key': 'resourceAccessRules', 'type': '[ResourceAccessRule]'}, - 'virtual_network_rules': {'key': 'virtualNetworkRules', 'type': '[VirtualNetworkRule]'}, - 'ip_rules': {'key': 'ipRules', 'type': '[IPRule]'}, - 'default_action': {'key': 'defaultAction', 'type': 'str'}, + "bypass": {"key": "bypass", "type": "str"}, + "resource_access_rules": {"key": "resourceAccessRules", "type": "[ResourceAccessRule]"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, } def __init__( self, *, default_action: Union[str, "_models.DefaultAction"] = "Allow", - bypass: Optional[Union[str, "_models.Bypass"]] = "AzureServices", + bypass: Union[str, "_models.Bypass"] = "AzureServices", resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, ip_rules: Optional[List["_models.IPRule"]] = None, @@ -4933,7 +4752,7 @@ def __init__( :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", - "Metrics", "AzureServices". Default value: "AzureServices". + "Metrics", and "AzureServices". :paramtype bypass: str or ~azure.mgmt.storage.v2022_05_01.models.Bypass :keyword resource_access_rules: Sets the resource access rules. :paramtype resource_access_rules: @@ -4943,11 +4762,11 @@ def __init__( list[~azure.mgmt.storage.v2022_05_01.models.VirtualNetworkRule] :keyword ip_rules: Sets the IP ACL rules. :paramtype ip_rules: list[~azure.mgmt.storage.v2022_05_01.models.IPRule] - :keyword default_action: Required. Specifies the default action of allow or deny when no other - rules match. Known values are: "Allow", "Deny". Default value: "Allow". + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". :paramtype default_action: str or ~azure.mgmt.storage.v2022_05_01.models.DefaultAction """ - super(NetworkRuleSet, self).__init__(**kwargs) + super().__init__(**kwargs) self.bypass = bypass self.resource_access_rules = resource_access_rules self.virtual_network_rules = virtual_network_rules @@ -4955,7 +4774,7 @@ def __init__( self.default_action = default_action -class ObjectReplicationPolicies(msrest.serialization.Model): +class ObjectReplicationPolicies(_serialization.Model): """List storage account object replication policies. :ivar value: The replication policy between two storage accounts. @@ -4963,20 +4782,15 @@ class ObjectReplicationPolicies(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[ObjectReplicationPolicy]'}, + "value": {"key": "value", "type": "[ObjectReplicationPolicy]"}, } - def __init__( - self, - *, - value: Optional[List["_models.ObjectReplicationPolicy"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs): """ :keyword value: The replication policy between two storage accounts. :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy] """ - super(ObjectReplicationPolicies, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -5008,22 +4822,22 @@ class ObjectReplicationPolicy(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'policy_id': {'readonly': True}, - 'enabled_time': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_id": {"readonly": True}, + "enabled_time": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'policy_id': {'key': 'properties.policyId', 'type': 'str'}, - 'enabled_time': {'key': 'properties.enabledTime', 'type': 'iso-8601'}, - 'source_account': {'key': 'properties.sourceAccount', 'type': 'str'}, - 'destination_account': {'key': 'properties.destinationAccount', 'type': 'str'}, - 'rules': {'key': 'properties.rules', 'type': '[ObjectReplicationPolicyRule]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "enabled_time": {"key": "properties.enabledTime", "type": "iso-8601"}, + "source_account": {"key": "properties.sourceAccount", "type": "str"}, + "destination_account": {"key": "properties.destinationAccount", "type": "str"}, + "rules": {"key": "properties.rules", "type": "[ObjectReplicationPolicyRule]"}, } def __init__( @@ -5044,7 +4858,7 @@ def __init__( :keyword rules: The storage account object replication rules. :paramtype rules: list[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicyRule] """ - super(ObjectReplicationPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.policy_id = None self.enabled_time = None self.source_account = source_account @@ -5052,7 +4866,7 @@ def __init__( self.rules = rules -class ObjectReplicationPolicyFilter(msrest.serialization.Model): +class ObjectReplicationPolicyFilter(_serialization.Model): """Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the filter. If multiple filters are defined, a logical AND is performed on all filters. :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin @@ -5064,17 +4878,11 @@ class ObjectReplicationPolicyFilter(msrest.serialization.Model): """ _attribute_map = { - 'prefix_match': {'key': 'prefixMatch', 'type': '[str]'}, - 'min_creation_time': {'key': 'minCreationTime', 'type': 'str'}, + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "min_creation_time": {"key": "minCreationTime", "type": "str"}, } - def __init__( - self, - *, - prefix_match: Optional[List[str]] = None, - min_creation_time: Optional[str] = None, - **kwargs - ): + def __init__(self, *, prefix_match: Optional[List[str]] = None, min_creation_time: Optional[str] = None, **kwargs): """ :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin with the specified prefix. @@ -5083,12 +4891,12 @@ def __init__( It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. :paramtype min_creation_time: str """ - super(ObjectReplicationPolicyFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.prefix_match = prefix_match self.min_creation_time = min_creation_time -class ObjectReplicationPolicyRule(msrest.serialization.Model): +class ObjectReplicationPolicyRule(_serialization.Model): """The replication policy rule between two containers. All required parameters must be populated in order to send to Azure. @@ -5096,24 +4904,24 @@ class ObjectReplicationPolicyRule(msrest.serialization.Model): :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :vartype rule_id: str - :ivar source_container: Required. Required. Source container name. + :ivar source_container: Required. Source container name. Required. :vartype source_container: str - :ivar destination_container: Required. Required. Destination container name. + :ivar destination_container: Required. Destination container name. Required. :vartype destination_container: str :ivar filters: Optional. An object that defines the filter set. :vartype filters: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicyFilter """ _validation = { - 'source_container': {'required': True}, - 'destination_container': {'required': True}, + "source_container": {"required": True}, + "destination_container": {"required": True}, } _attribute_map = { - 'rule_id': {'key': 'ruleId', 'type': 'str'}, - 'source_container': {'key': 'sourceContainer', 'type': 'str'}, - 'destination_container': {'key': 'destinationContainer', 'type': 'str'}, - 'filters': {'key': 'filters', 'type': 'ObjectReplicationPolicyFilter'}, + "rule_id": {"key": "ruleId", "type": "str"}, + "source_container": {"key": "sourceContainer", "type": "str"}, + "destination_container": {"key": "destinationContainer", "type": "str"}, + "filters": {"key": "filters", "type": "ObjectReplicationPolicyFilter"}, } def __init__( @@ -5129,21 +4937,21 @@ def __init__( :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is required for put policy on source account. :paramtype rule_id: str - :keyword source_container: Required. Required. Source container name. + :keyword source_container: Required. Source container name. Required. :paramtype source_container: str - :keyword destination_container: Required. Required. Destination container name. + :keyword destination_container: Required. Destination container name. Required. :paramtype destination_container: str :keyword filters: Optional. An object that defines the filter set. :paramtype filters: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicyFilter """ - super(ObjectReplicationPolicyRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.rule_id = rule_id self.source_container = source_container self.destination_container = destination_container self.filters = filters -class Operation(msrest.serialization.Model): +class Operation(_serialization.Model): """Storage REST API operation definition. :ivar name: Operation name: {provider}/{resource}/{operation}. @@ -5157,10 +4965,10 @@ class Operation(msrest.serialization.Model): """ _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'service_specification': {'key': 'properties.serviceSpecification', 'type': 'ServiceSpecification'}, + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, } def __init__( @@ -5182,14 +4990,14 @@ def __init__( :keyword service_specification: One property of operation, include metric specifications. :paramtype service_specification: ~azure.mgmt.storage.v2022_05_01.models.ServiceSpecification """ - super(Operation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.display = display self.origin = origin self.service_specification = service_specification -class OperationDisplay(msrest.serialization.Model): +class OperationDisplay(_serialization.Model): """Display metadata associated with the operation. :ivar provider: Service provider: Microsoft Storage. @@ -5203,10 +5011,10 @@ class OperationDisplay(msrest.serialization.Model): """ _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, } def __init__( @@ -5228,14 +5036,14 @@ def __init__( :keyword description: Description of the operation. :paramtype description: str """ - super(OperationDisplay, self).__init__(**kwargs) + super().__init__(**kwargs) self.provider = provider self.resource = resource self.operation = operation self.description = description -class OperationListResult(msrest.serialization.Model): +class OperationListResult(_serialization.Model): """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. :ivar value: List of Storage operations supported by the Storage resource provider. @@ -5243,75 +5051,63 @@ class OperationListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, + "value": {"key": "value", "type": "[Operation]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Operation"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): """ :keyword value: List of Storage operations supported by the Storage resource provider. :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.Operation] """ - super(OperationListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PermissionScope(msrest.serialization.Model): +class PermissionScope(_serialization.Model): """PermissionScope. All required parameters must be populated in order to send to Azure. - :ivar permissions: Required. The permissions for the local user. Possible values include: Read - (r), Write (w), Delete (d), List (l), and Create (c). + :ivar permissions: The permissions for the local user. Possible values include: Read (r), Write + (w), Delete (d), List (l), and Create (c). Required. :vartype permissions: str - :ivar service: Required. The service used by the local user, e.g. blob, file. + :ivar service: The service used by the local user, e.g. blob, file. Required. :vartype service: str - :ivar resource_name: Required. The name of resource, normally the container name or the file - share name, used by the local user. + :ivar resource_name: The name of resource, normally the container name or the file share name, + used by the local user. Required. :vartype resource_name: str """ _validation = { - 'permissions': {'required': True}, - 'service': {'required': True}, - 'resource_name': {'required': True}, + "permissions": {"required": True}, + "service": {"required": True}, + "resource_name": {"required": True}, } _attribute_map = { - 'permissions': {'key': 'permissions', 'type': 'str'}, - 'service': {'key': 'service', 'type': 'str'}, - 'resource_name': {'key': 'resourceName', 'type': 'str'}, + "permissions": {"key": "permissions", "type": "str"}, + "service": {"key": "service", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, } - def __init__( - self, - *, - permissions: str, - service: str, - resource_name: str, - **kwargs - ): + def __init__(self, *, permissions: str, service: str, resource_name: str, **kwargs): """ - :keyword permissions: Required. The permissions for the local user. Possible values include: - Read (r), Write (w), Delete (d), List (l), and Create (c). + :keyword permissions: The permissions for the local user. Possible values include: Read (r), + Write (w), Delete (d), List (l), and Create (c). Required. :paramtype permissions: str - :keyword service: Required. The service used by the local user, e.g. blob, file. + :keyword service: The service used by the local user, e.g. blob, file. Required. :paramtype service: str - :keyword resource_name: Required. The name of resource, normally the container name or the file - share name, used by the local user. + :keyword resource_name: The name of resource, normally the container name or the file share + name, used by the local user. Required. :paramtype resource_name: str """ - super(PermissionScope, self).__init__(**kwargs) + super().__init__(**kwargs) self.permissions = permissions self.service = service self.resource_name = resource_name -class PrivateEndpoint(msrest.serialization.Model): +class PrivateEndpoint(_serialization.Model): """The Private Endpoint resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -5321,20 +5117,16 @@ class PrivateEndpoint(msrest.serialization.Model): """ _validation = { - 'id': {'readonly': True}, + "id": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(PrivateEndpoint, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.id = None @@ -5358,25 +5150,28 @@ class PrivateEndpointConnection(Resource): :vartype private_link_service_connection_state: ~azure.mgmt.storage.v2022_05_01.models.PrivateLinkServiceConnectionState :ivar provisioning_state: The provisioning state of the private endpoint connection resource. - Known values are: "Succeeded", "Creating", "Deleting", "Failed". + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". :vartype provisioning_state: str or ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnectionProvisioningState """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'provisioning_state': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'private_endpoint': {'key': 'properties.privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'properties.privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, } def __init__( @@ -5394,13 +5189,13 @@ def __init__( :paramtype private_link_service_connection_state: ~azure.mgmt.storage.v2022_05_01.models.PrivateLinkServiceConnectionState """ - super(PrivateEndpointConnection, self).__init__(**kwargs) + super().__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state self.provisioning_state = None -class PrivateEndpointConnectionListResult(msrest.serialization.Model): +class PrivateEndpointConnectionListResult(_serialization.Model): """List of private endpoint connection associated with the specified storage account. :ivar value: Array of private endpoint connections. @@ -5408,20 +5203,15 @@ class PrivateEndpointConnectionListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateEndpointConnection]'}, + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateEndpointConnection"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): """ :keyword value: Array of private endpoint connections. :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection] """ - super(PrivateEndpointConnectionListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value @@ -5447,39 +5237,34 @@ class PrivateLinkResource(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'group_id': {'readonly': True}, - 'required_members': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'group_id': {'key': 'properties.groupId', 'type': 'str'}, - 'required_members': {'key': 'properties.requiredMembers', 'type': '[str]'}, - 'required_zone_names': {'key': 'properties.requiredZoneNames', 'type': '[str]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "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, - *, - required_zone_names: Optional[List[str]] = None, - **kwargs - ): + def __init__(self, *, required_zone_names: Optional[List[str]] = None, **kwargs): """ :keyword required_zone_names: The private link resource Private link DNS zone name. :paramtype required_zone_names: list[str] """ - super(PrivateLinkResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.group_id = None self.required_members = None self.required_zone_names = required_zone_names -class PrivateLinkResourceListResult(msrest.serialization.Model): +class PrivateLinkResourceListResult(_serialization.Model): """A list of private link resources. :ivar value: Array of private link resources. @@ -5487,28 +5272,23 @@ class PrivateLinkResourceListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[PrivateLinkResource]'}, + "value": {"key": "value", "type": "[PrivateLinkResource]"}, } - def __init__( - self, - *, - value: Optional[List["_models.PrivateLinkResource"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): """ :keyword value: Array of private link resources. :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.PrivateLinkResource] """ - super(PrivateLinkResourceListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class PrivateLinkServiceConnectionState(msrest.serialization.Model): +class PrivateLinkServiceConnectionState(_serialization.Model): """A collection of information about the state of the connection between service consumer and provider. :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner - of the service. Known values are: "Pending", "Approved", "Rejected". + of the service. Known values are: "Pending", "Approved", and "Rejected". :vartype status: str or ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointServiceConnectionStatus :ivar description: The reason for approval/rejection of the connection. @@ -5519,9 +5299,9 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): """ _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'action_required': {'key': 'actionRequired', 'type': 'str'}, + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "action_required": {"key": "actionRequired", "type": "str"}, } def __init__( @@ -5534,7 +5314,7 @@ def __init__( ): """ :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the - owner of the service. Known values are: "Pending", "Approved", "Rejected". + owner of the service. Known values are: "Pending", "Approved", and "Rejected". :paramtype status: str or ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointServiceConnectionStatus :keyword description: The reason for approval/rejection of the connection. @@ -5543,13 +5323,13 @@ def __init__( updates on the consumer. :paramtype action_required: str """ - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) + super().__init__(**kwargs) self.status = status self.description = description self.action_required = action_required -class ProtectedAppendWritesHistory(msrest.serialization.Model): +class ProtectedAppendWritesHistory(_serialization.Model): """Protected append writes history setting for the blob container with Legal holds. Variables are only populated by the server, and will be ignored when sending a request. @@ -5563,32 +5343,27 @@ class ProtectedAppendWritesHistory(msrest.serialization.Model): """ _validation = { - 'timestamp': {'readonly': True}, + "timestamp": {"readonly": True}, } _attribute_map = { - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, } - def __init__( - self, - *, - allow_protected_append_writes_all: Optional[bool] = None, - **kwargs - ): + def __init__(self, *, allow_protected_append_writes_all: Optional[bool] = None, **kwargs): """ :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks can be added and any existing blocks cannot be modified or deleted. :paramtype allow_protected_append_writes_all: bool """ - super(ProtectedAppendWritesHistory, self).__init__(**kwargs) + super().__init__(**kwargs) self.allow_protected_append_writes_all = allow_protected_append_writes_all self.timestamp = None -class ProtocolSettings(msrest.serialization.Model): +class ProtocolSettings(_serialization.Model): """Protocol settings for file service. :ivar smb: Setting for SMB protocol. @@ -5596,20 +5371,15 @@ class ProtocolSettings(msrest.serialization.Model): """ _attribute_map = { - 'smb': {'key': 'smb', 'type': 'SmbSetting'}, + "smb": {"key": "smb", "type": "SmbSetting"}, } - def __init__( - self, - *, - smb: Optional["_models.SmbSetting"] = None, - **kwargs - ): + def __init__(self, *, smb: Optional["_models.SmbSetting"] = None, **kwargs): """ :keyword smb: Setting for SMB protocol. :paramtype smb: ~azure.mgmt.storage.v2022_05_01.models.SmbSetting """ - super(ProtocolSettings, self).__init__(**kwargs) + super().__init__(**kwargs) self.smb = smb @@ -5633,35 +5403,30 @@ class QueueServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Queue service. :paramtype cors: ~azure.mgmt.storage.v2022_05_01.models.CorsRules """ - super(QueueServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class ResourceAccessRule(msrest.serialization.Model): +class ResourceAccessRule(_serialization.Model): """Resource Access Rule. :ivar tenant_id: Tenant Id. @@ -5671,36 +5436,30 @@ class ResourceAccessRule(msrest.serialization.Model): """ _attribute_map = { - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'resource_id': {'key': 'resourceId', 'type': 'str'}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, } - def __init__( - self, - *, - tenant_id: Optional[str] = None, - resource_id: Optional[str] = None, - **kwargs - ): + def __init__(self, *, tenant_id: Optional[str] = None, resource_id: Optional[str] = None, **kwargs): """ :keyword tenant_id: Tenant Id. :paramtype tenant_id: str :keyword resource_id: Resource Id. :paramtype resource_id: str """ - super(ResourceAccessRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.tenant_id = tenant_id self.resource_id = resource_id -class RestorePolicyProperties(msrest.serialization.Model): +class RestorePolicyProperties(_serialization.Model): """The blob service properties for blob restore policy. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar enabled: Required. Blob restore is enabled if set to true. + :ivar enabled: Blob restore is enabled if set to true. Required. :vartype enabled: bool :ivar days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. @@ -5712,41 +5471,35 @@ class RestorePolicyProperties(msrest.serialization.Model): """ _validation = { - 'enabled': {'required': True}, - 'days': {'maximum': 365, 'minimum': 1}, - 'last_enabled_time': {'readonly': True}, - 'min_restore_time': {'readonly': True}, + "enabled": {"required": True}, + "days": {"maximum": 365, "minimum": 1}, + "last_enabled_time": {"readonly": True}, + "min_restore_time": {"readonly": True}, } _attribute_map = { - 'enabled': {'key': 'enabled', 'type': 'bool'}, - 'days': {'key': 'days', 'type': 'int'}, - 'last_enabled_time': {'key': 'lastEnabledTime', 'type': 'iso-8601'}, - 'min_restore_time': {'key': 'minRestoreTime', 'type': 'iso-8601'}, + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "min_restore_time": {"key": "minRestoreTime", "type": "iso-8601"}, } - def __init__( - self, - *, - enabled: bool, - days: Optional[int] = None, - **kwargs - ): + def __init__(self, *, enabled: bool, days: Optional[int] = None, **kwargs): """ - :keyword enabled: Required. Blob restore is enabled if set to true. + :keyword enabled: Blob restore is enabled if set to true. Required. :paramtype enabled: bool :keyword days: how long this blob can be restored. It should be great than zero and less than DeleteRetentionPolicy.days. :paramtype days: int """ - super(RestorePolicyProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.enabled = enabled self.days = days self.last_enabled_time = None self.min_restore_time = None -class Restriction(msrest.serialization.Model): +class Restriction(_serialization.Model): """The restriction because of which SKU cannot be used. Variables are only populated by the server, and will be ignored when sending a request. @@ -5759,45 +5512,40 @@ class Restriction(msrest.serialization.Model): :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :vartype reason_code: str or ~azure.mgmt.storage.v2022_05_01.models.ReasonCode """ _validation = { - 'type': {'readonly': True}, - 'values': {'readonly': True}, + "type": {"readonly": True}, + "values": {"readonly": True}, } _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'values': {'key': 'values', 'type': '[str]'}, - 'reason_code': {'key': 'reasonCode', 'type': 'str'}, + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, } - def __init__( - self, - *, - reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, - **kwargs - ): + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): """ :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the subscription does not belong to that quota. The "NotAvailableForSubscription" is related to - capacity at DC. Known values are: "QuotaId", "NotAvailableForSubscription". + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". :paramtype reason_code: str or ~azure.mgmt.storage.v2022_05_01.models.ReasonCode """ - super(Restriction, self).__init__(**kwargs) + super().__init__(**kwargs) self.type = None self.values = None self.reason_code = reason_code -class RoutingPreference(msrest.serialization.Model): +class RoutingPreference(_serialization.Model): """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :vartype routing_choice: str or ~azure.mgmt.storage.v2022_05_01.models.RoutingChoice :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5808,9 +5556,9 @@ class RoutingPreference(msrest.serialization.Model): """ _attribute_map = { - 'routing_choice': {'key': 'routingChoice', 'type': 'str'}, - 'publish_microsoft_endpoints': {'key': 'publishMicrosoftEndpoints', 'type': 'bool'}, - 'publish_internet_endpoints': {'key': 'publishInternetEndpoints', 'type': 'bool'}, + "routing_choice": {"key": "routingChoice", "type": "str"}, + "publish_microsoft_endpoints": {"key": "publishMicrosoftEndpoints", "type": "bool"}, + "publish_internet_endpoints": {"key": "publishInternetEndpoints", "type": "bool"}, } def __init__( @@ -5823,7 +5571,7 @@ def __init__( ): """ :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. - Known values are: "MicrosoftRouting", "InternetRouting". + Known values are: "MicrosoftRouting" and "InternetRouting". :paramtype routing_choice: str or ~azure.mgmt.storage.v2022_05_01.models.RoutingChoice :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing storage endpoints are to be published. @@ -5832,72 +5580,66 @@ def __init__( storage endpoints are to be published. :paramtype publish_internet_endpoints: bool """ - super(RoutingPreference, self).__init__(**kwargs) + super().__init__(**kwargs) self.routing_choice = routing_choice self.publish_microsoft_endpoints = publish_microsoft_endpoints self.publish_internet_endpoints = publish_internet_endpoints -class SasPolicy(msrest.serialization.Model): +class SasPolicy(_serialization.Model): """SasPolicy assigned to the storage account. All required parameters must be populated in order to send to Azure. - :ivar sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :ivar sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :vartype sas_expiration_period: str - :ivar expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :ivar expiration_action: The SAS expiration action. Can only be Log. "Log" :vartype expiration_action: str or ~azure.mgmt.storage.v2022_05_01.models.ExpirationAction """ _validation = { - 'sas_expiration_period': {'required': True}, - 'expiration_action': {'required': True}, + "sas_expiration_period": {"required": True}, + "expiration_action": {"required": True}, } _attribute_map = { - 'sas_expiration_period': {'key': 'sasExpirationPeriod', 'type': 'str'}, - 'expiration_action': {'key': 'expirationAction', 'type': 'str'}, + "sas_expiration_period": {"key": "sasExpirationPeriod", "type": "str"}, + "expiration_action": {"key": "expirationAction", "type": "str"}, } def __init__( - self, - *, - sas_expiration_period: str, - expiration_action: Union[str, "_models.ExpirationAction"] = "Log", - **kwargs + self, *, sas_expiration_period: str, expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs ): """ - :keyword sas_expiration_period: Required. The SAS expiration period, DD.HH:MM:SS. + :keyword sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. :paramtype sas_expiration_period: str - :keyword expiration_action: Required. The SAS expiration action. Can only be Log. Known values - are: "Log". Default value: "Log". + :keyword expiration_action: The SAS expiration action. Can only be Log. "Log" :paramtype expiration_action: str or ~azure.mgmt.storage.v2022_05_01.models.ExpirationAction """ - super(SasPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.sas_expiration_period = sas_expiration_period self.expiration_action = expiration_action -class ServiceSasParameters(msrest.serialization.Model): +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters to list service SAS credentials of a specific resource. All required parameters must be populated in order to send to Azure. - :ivar canonicalized_resource: Required. The canonical path to the signed resource. + :ivar canonicalized_resource: The canonical path to the signed resource. Required. :vartype canonicalized_resource: str :ivar resource: The signed services accessible with the service SAS. Possible values include: - Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". :vartype resource: str or ~azure.mgmt.storage.v2022_05_01.models.SignedResource :ivar permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :vartype permissions: str or ~azure.mgmt.storage.v2022_05_01.models.Permissions :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :vartype ip_address_or_range: str :ivar protocols: The protocol permitted for a request made with the account SAS. Known values - are: "https,http", "https". + are: "https,http" and "https". :vartype protocols: str or ~azure.mgmt.storage.v2022_05_01.models.HttpProtocol :ivar shared_access_start_time: The time at which the SAS becomes valid. :vartype shared_access_start_time: ~datetime.datetime @@ -5929,29 +5671,29 @@ class ServiceSasParameters(msrest.serialization.Model): """ _validation = { - 'canonicalized_resource': {'required': True}, - 'identifier': {'max_length': 64, 'min_length': 0}, - } - - _attribute_map = { - 'canonicalized_resource': {'key': 'canonicalizedResource', 'type': 'str'}, - 'resource': {'key': 'signedResource', 'type': 'str'}, - 'permissions': {'key': 'signedPermission', 'type': 'str'}, - 'ip_address_or_range': {'key': 'signedIp', 'type': 'str'}, - 'protocols': {'key': 'signedProtocol', 'type': 'str'}, - 'shared_access_start_time': {'key': 'signedStart', 'type': 'iso-8601'}, - 'shared_access_expiry_time': {'key': 'signedExpiry', 'type': 'iso-8601'}, - 'identifier': {'key': 'signedIdentifier', 'type': 'str'}, - 'partition_key_start': {'key': 'startPk', 'type': 'str'}, - 'partition_key_end': {'key': 'endPk', 'type': 'str'}, - 'row_key_start': {'key': 'startRk', 'type': 'str'}, - 'row_key_end': {'key': 'endRk', 'type': 'str'}, - 'key_to_sign': {'key': 'keyToSign', 'type': 'str'}, - 'cache_control': {'key': 'rscc', 'type': 'str'}, - 'content_disposition': {'key': 'rscd', 'type': 'str'}, - 'content_encoding': {'key': 'rsce', 'type': 'str'}, - 'content_language': {'key': 'rscl', 'type': 'str'}, - 'content_type': {'key': 'rsct', 'type': 'str'}, + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, + } + + _attribute_map = { + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, } def __init__( @@ -5978,20 +5720,21 @@ def __init__( **kwargs ): """ - :keyword canonicalized_resource: Required. The canonical path to the signed resource. + :keyword canonicalized_resource: The canonical path to the signed resource. Required. :paramtype canonicalized_resource: str :keyword resource: The signed services accessible with the service SAS. Possible values - include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", "s". + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". :paramtype resource: str or ~azure.mgmt.storage.v2022_05_01.models.SignedResource :keyword permissions: The signed permissions for the service SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known - values are: "r", "d", "w", "l", "a", "c", "u", "p". + values are: "r", "d", "w", "l", "a", "c", "u", and "p". :paramtype permissions: str or ~azure.mgmt.storage.v2022_05_01.models.Permissions :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept requests. :paramtype ip_address_or_range: str :keyword protocols: The protocol permitted for a request made with the account SAS. Known - values are: "https,http", "https". + values are: "https,http" and "https". :paramtype protocols: str or ~azure.mgmt.storage.v2022_05_01.models.HttpProtocol :keyword shared_access_start_time: The time at which the SAS becomes valid. :paramtype shared_access_start_time: ~datetime.datetime @@ -6022,7 +5765,7 @@ def __init__( :keyword content_type: The response header override for content type. :paramtype content_type: str """ - super(ServiceSasParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.canonicalized_resource = canonicalized_resource self.resource = resource self.permissions = permissions @@ -6043,7 +5786,7 @@ def __init__( self.content_type = content_type -class ServiceSpecification(msrest.serialization.Model): +class ServiceSpecification(_serialization.Model): """One property of operation, include metric specifications. :ivar metric_specifications: Metric specifications of operation. @@ -6052,25 +5795,20 @@ class ServiceSpecification(msrest.serialization.Model): """ _attribute_map = { - 'metric_specifications': {'key': 'metricSpecifications', 'type': '[MetricSpecification]'}, + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, } - def __init__( - self, - *, - metric_specifications: Optional[List["_models.MetricSpecification"]] = None, - **kwargs - ): + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): """ :keyword metric_specifications: Metric specifications of operation. :paramtype metric_specifications: list[~azure.mgmt.storage.v2022_05_01.models.MetricSpecification] """ - super(ServiceSpecification, self).__init__(**kwargs) + super().__init__(**kwargs) self.metric_specifications = metric_specifications -class SignedIdentifier(msrest.serialization.Model): +class SignedIdentifier(_serialization.Model): """SignedIdentifier. :ivar id: An unique identifier of the stored access policy. @@ -6080,14 +5818,14 @@ class SignedIdentifier(msrest.serialization.Model): """ _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'access_policy': {'key': 'accessPolicy', 'type': 'AccessPolicy'}, + "id": {"key": "id", "type": "str"}, + "access_policy": {"key": "accessPolicy", "type": "AccessPolicy"}, } def __init__( self, *, - id: Optional[str] = None, + id: Optional[str] = None, # pylint: disable=redefined-builtin access_policy: Optional["_models.AccessPolicy"] = None, **kwargs ): @@ -6097,57 +5835,52 @@ def __init__( :keyword access_policy: Access policy. :paramtype access_policy: ~azure.mgmt.storage.v2022_05_01.models.AccessPolicy """ - super(SignedIdentifier, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.access_policy = access_policy -class Sku(msrest.serialization.Model): +class Sku(_serialization.Model): """The SKU of the storage account. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2022_05_01.models.SkuTier """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, } - def __init__( - self, - *, - name: Union[str, "_models.SkuName"], - **kwargs - ): + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName """ - super(Sku, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None -class SKUCapability(msrest.serialization.Model): +class SKUCapability(_serialization.Model): """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. Variables are only populated by the server, and will be ignored when sending a request. @@ -6160,45 +5893,41 @@ class SKUCapability(msrest.serialization.Model): """ _validation = { - 'name': {'readonly': True}, - 'value': {'readonly': True}, + "name": {"readonly": True}, + "value": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(SKUCapability, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.name = None self.value = None -class SkuInformation(msrest.serialization.Model): +class SkuInformation(_serialization.Model): """Storage SKU and its properties. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :vartype name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName - :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard", + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and "Premium". :vartype tier: str or ~azure.mgmt.storage.v2022_05_01.models.SkuTier :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. :vartype resource_type: str :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", - "BlobStorage", "FileStorage", "BlockBlobStorage". + "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind :ivar locations: The set of locations that the SKU is available. This will be supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). @@ -6212,22 +5941,22 @@ class SkuInformation(msrest.serialization.Model): """ _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'resource_type': {'readonly': True}, - 'kind': {'readonly': True}, - 'locations': {'readonly': True}, - 'capabilities': {'readonly': True}, + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'resource_type': {'key': 'resourceType', 'type': 'str'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'locations': {'key': 'locations', 'type': '[str]'}, - 'capabilities': {'key': 'capabilities', 'type': '[SKUCapability]'}, - 'restrictions': {'key': 'restrictions', 'type': '[Restriction]'}, + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, } def __init__( @@ -6238,16 +5967,16 @@ def __init__( **kwargs ): """ - :keyword name: Required. The SKU name. Required for account creation; optional for update. Note - that in older versions, SKU name was called accountType. Known values are: "Standard_LRS", + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", - "Standard_GZRS", "Standard_RAGZRS". + "Standard_GZRS", and "Standard_RAGZRS". :paramtype name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if there are no restrictions. :paramtype restrictions: list[~azure.mgmt.storage.v2022_05_01.models.Restriction] """ - super(SkuInformation, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.tier = None self.resource_type = None @@ -6257,7 +5986,7 @@ def __init__( self.restrictions = restrictions -class SmbSetting(msrest.serialization.Model): +class SmbSetting(_serialization.Model): """Setting for SMB protocol. :ivar multichannel: Multichannel setting. Applies to Premium FileStorage only. @@ -6277,11 +6006,11 @@ class SmbSetting(msrest.serialization.Model): """ _attribute_map = { - 'multichannel': {'key': 'multichannel', 'type': 'Multichannel'}, - 'versions': {'key': 'versions', 'type': 'str'}, - 'authentication_methods': {'key': 'authenticationMethods', 'type': 'str'}, - 'kerberos_ticket_encryption': {'key': 'kerberosTicketEncryption', 'type': 'str'}, - 'channel_encryption': {'key': 'channelEncryption', 'type': 'str'}, + "multichannel": {"key": "multichannel", "type": "Multichannel"}, + "versions": {"key": "versions", "type": "str"}, + "authentication_methods": {"key": "authenticationMethods", "type": "str"}, + "kerberos_ticket_encryption": {"key": "kerberosTicketEncryption", "type": "str"}, + "channel_encryption": {"key": "channelEncryption", "type": "str"}, } def __init__( @@ -6310,7 +6039,7 @@ def __init__( AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. :paramtype channel_encryption: str """ - super(SmbSetting, self).__init__(**kwargs) + super().__init__(**kwargs) self.multichannel = multichannel self.versions = versions self.authentication_methods = authentication_methods @@ -6318,7 +6047,7 @@ def __init__( self.channel_encryption = channel_encryption -class SshPublicKey(msrest.serialization.Model): +class SshPublicKey(_serialization.Model): """SshPublicKey. :ivar description: Optional. It is used to store the function/usage of the key. @@ -6329,17 +6058,11 @@ class SshPublicKey(msrest.serialization.Model): """ _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'key': {'key': 'key', 'type': 'str'}, + "description": {"key": "description", "type": "str"}, + "key": {"key": "key", "type": "str"}, } - def __init__( - self, - *, - description: Optional[str] = None, - key: Optional[str] = None, - **kwargs - ): + def __init__(self, *, description: Optional[str] = None, key: Optional[str] = None, **kwargs): """ :keyword description: Optional. It is used to store the function/usage of the key. :paramtype description: str @@ -6347,7 +6070,7 @@ def __init__( :code:``', e.g. ssh-rsa AAAABBBB. :paramtype key: str """ - super(SshPublicKey, self).__init__(**kwargs) + super().__init__(**kwargs) self.description = description self.key = key @@ -6367,46 +6090,40 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, } - def __init__( - self, - *, - location: str, - tags: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str """ - super(TrackedResource, self).__init__(**kwargs) + super().__init__(**kwargs) self.tags = tags self.location = location -class StorageAccount(TrackedResource): +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes """The storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -6421,21 +6138,21 @@ class StorageAccount(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :ivar tags: A set of tags. Resource tags. + :ivar tags: Resource tags. :vartype tags: dict[str, str] - :ivar location: Required. The geo-location where the resource lives. + :ivar location: The geo-location where the resource lives. Required. :vartype location: str :ivar sku: Gets the SKU. :vartype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", - "FileStorage", "BlockBlobStorage". + "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity :ivar extended_location: The extendedLocation of the resource. :vartype extended_location: ~azure.mgmt.storage.v2022_05_01.models.ExtendedLocation :ivar provisioning_state: Gets the status of the storage account at the time the operation was - called. Known values are: "Creating", "ResolvingDNS", "Succeeded". + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". :vartype provisioning_state: str or ~azure.mgmt.storage.v2022_05_01.models.ProvisioningState :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob @@ -6444,7 +6161,7 @@ class StorageAccount(TrackedResource): :ivar primary_location: Gets the location of the primary data center for the storage account. :vartype primary_location: str :ivar status_of_primary: Gets the status indicating whether the primary location of the storage - account is available or unavailable. Known values are: "available", "unavailable". + account is available or unavailable. Known values are: "available" and "unavailable". :vartype status_of_primary: str or ~azure.mgmt.storage.v2022_05_01.models.AccountStatus :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to the secondary location. Only the most recent timestamp is retained. This element is not @@ -6456,7 +6173,7 @@ class StorageAccount(TrackedResource): :vartype secondary_location: str :ivar status_of_secondary: Gets the status indicating whether the secondary location of the storage account is available or unavailable. Only available if the SKU name is Standard_GRS or - Standard_RAGRS. Known values are: "available", "unavailable". + Standard_RAGRS. Known values are: "available" and "unavailable". :vartype status_of_secondary: str or ~azure.mgmt.storage.v2022_05_01.models.AccountStatus :ivar creation_time: Gets the creation date and time of the storage account in UTC. :vartype creation_time: ~datetime.datetime @@ -6478,7 +6195,7 @@ class StorageAccount(TrackedResource): :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Known values are: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6500,7 +6217,7 @@ class StorageAccount(TrackedResource): it will be null. :vartype failover_in_progress: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState :ivar private_endpoint_connections: List of private endpoint connection associated with the @@ -6517,7 +6234,7 @@ class StorageAccount(TrackedResource): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6533,7 +6250,7 @@ class StorageAccount(TrackedResource): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess @@ -6543,7 +6260,7 @@ class StorageAccount(TrackedResource): :vartype immutable_storage_with_versioning: ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageAccount :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope :ivar storage_account_sku_conversion_status: This property is readOnly and is set by server during asynchronous storage account sku conversion operations. @@ -6552,90 +6269,102 @@ class StorageAccount(TrackedResource): :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values - are: "Standard", "AzureDnsZone". + are: "Standard" and "AzureDnsZone". :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'sku': {'readonly': True}, - 'kind': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'primary_endpoints': {'readonly': True}, - 'primary_location': {'readonly': True}, - 'status_of_primary': {'readonly': True}, - 'last_geo_failover_time': {'readonly': True}, - 'secondary_location': {'readonly': True}, - 'status_of_secondary': {'readonly': True}, - 'creation_time': {'readonly': True}, - 'custom_domain': {'readonly': True}, - 'sas_policy': {'readonly': True}, - 'key_policy': {'readonly': True}, - 'key_creation_time': {'readonly': True}, - 'secondary_endpoints': {'readonly': True}, - 'encryption': {'readonly': True}, - 'access_tier': {'readonly': True}, - 'network_rule_set': {'readonly': True}, - 'geo_replication_stats': {'readonly': True}, - 'failover_in_progress': {'readonly': True}, - 'private_endpoint_connections': {'readonly': True}, - 'blob_restore_status': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'primary_endpoints': {'key': 'properties.primaryEndpoints', 'type': 'Endpoints'}, - 'primary_location': {'key': 'properties.primaryLocation', 'type': 'str'}, - 'status_of_primary': {'key': 'properties.statusOfPrimary', 'type': 'str'}, - 'last_geo_failover_time': {'key': 'properties.lastGeoFailoverTime', 'type': 'iso-8601'}, - 'secondary_location': {'key': 'properties.secondaryLocation', 'type': 'str'}, - 'status_of_secondary': {'key': 'properties.statusOfSecondary', 'type': 'str'}, - 'creation_time': {'key': 'properties.creationTime', 'type': 'iso-8601'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'key_creation_time': {'key': 'properties.keyCreationTime', 'type': 'KeyCreationTime'}, - 'secondary_endpoints': {'key': 'properties.secondaryEndpoints', 'type': 'Endpoints'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, - 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'geo_replication_stats': {'key': 'properties.geoReplicationStats', 'type': 'GeoReplicationStats'}, - 'failover_in_progress': {'key': 'properties.failoverInProgress', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'properties.privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'blob_restore_status': {'key': 'properties.blobRestoreStatus', 'type': 'BlobRestoreStatus'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, - 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, - 'storage_account_sku_conversion_status': {'key': 'properties.storageAccountSkuConversionStatus', 'type': 'StorageAccountSkuConversionStatus'}, - 'dns_endpoint_type': {'key': 'properties.dnsEndpointType', 'type': 'str'}, - } - - def __init__( + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "sas_policy": {"readonly": True}, + "key_policy": {"readonly": True}, + "key_creation_time": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "blob_restore_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "key_creation_time": {"key": "properties.keyCreationTime", "type": "KeyCreationTime"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "blob_restore_status": {"key": "properties.blobRestoreStatus", "type": "BlobRestoreStatus"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "storage_account_sku_conversion_status": { + "key": "properties.storageAccountSkuConversionStatus", + "type": "StorageAccountSkuConversionStatus", + }, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, location: str, @@ -6663,9 +6392,9 @@ def __init__( **kwargs ): """ - :keyword tags: A set of tags. Resource tags. + :keyword tags: Resource tags. :paramtype tags: dict[str, str] - :keyword location: Required. The geo-location where the resource lives. + :keyword location: The geo-location where the resource lives. Required. :paramtype location: str :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity @@ -6685,7 +6414,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -6696,7 +6425,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6713,7 +6442,7 @@ def __init__( :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess :keyword immutable_storage_with_versioning: The property is immutable and can only be set to @@ -6722,7 +6451,7 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageAccount :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope :keyword storage_account_sku_conversion_status: This property is readOnly and is set by server during asynchronous storage account sku conversion operations. @@ -6731,10 +6460,10 @@ def __init__( :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone - identifier. Known values are: "Standard", "AzureDnsZone". + identifier. Known values are: "Standard" and "AzureDnsZone". :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType """ - super(StorageAccount, self).__init__(tags=tags, location=location, **kwargs) + super().__init__(tags=tags, location=location, **kwargs) self.sku = None self.kind = None self.identity = identity @@ -6779,77 +6508,72 @@ def __init__( self.dns_endpoint_type = dns_endpoint_type -class StorageAccountCheckNameAvailabilityParameters(msrest.serialization.Model): +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): """The parameters used to check the availability of the storage account name. Variables are only populated by the server, and will be ignored when sending a request. All required parameters must be populated in order to send to Azure. - :ivar name: Required. The storage account name. + :ivar name: The storage account name. Required. :vartype name: str - :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Has constant value: + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is "Microsoft.Storage/storageAccounts". :vartype type: str """ _validation = { - 'name': {'required': True}, - 'type': {'required': True, 'constant': True}, + "name": {"required": True}, + "type": {"required": True, "constant": True}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, } type = "Microsoft.Storage/storageAccounts" - def __init__( - self, - *, - name: str, - **kwargs - ): + def __init__(self, *, name: str, **kwargs): """ - :keyword name: Required. The storage account name. + :keyword name: The storage account name. Required. :paramtype name: str """ - super(StorageAccountCheckNameAvailabilityParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name -class StorageAccountCreateParameters(msrest.serialization.Model): +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters used when creating a storage account. All required parameters must be populated in order to send to Azure. - :ivar sku: Required. Required. Gets or sets the SKU name. + :ivar sku: Required. Gets or sets the SKU name. Required. :vartype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku - :ivar kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind - :ivar location: Required. Required. Gets or sets the location of the resource. This will be one - of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :vartype location: str :ivar extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :vartype extended_location: ~azure.mgmt.storage.v2022_05_01.models.ExtendedLocation - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used for viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key with a length no - greater than 128 characters and a value with a length no greater than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess @@ -6869,7 +6593,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Known values are: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -6885,7 +6609,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :vartype is_hns_enabled: bool :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -6896,7 +6620,7 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -6919,49 +6643,55 @@ class StorageAccountCreateParameters(msrest.serialization.Model): :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values - are: "Standard", "AzureDnsZone". + are: "Standard" and "AzureDnsZone". :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType """ _validation = { - 'sku': {'required': True}, - 'kind': {'required': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'extended_location': {'key': 'extendedLocation', 'type': 'ExtendedLocation'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, - 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, - 'is_hns_enabled': {'key': 'properties.isHnsEnabled', 'type': 'bool'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'enable_nfs_v3': {'key': 'properties.isNfsV3Enabled', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, - 'dns_endpoint_type': {'key': 'properties.dnsEndpointType', 'type': 'str'}, - } - - def __init__( + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, sku: "_models.Sku", @@ -6996,33 +6726,33 @@ def __init__( **kwargs ): """ - :keyword sku: Required. Required. Gets or sets the SKU name. + :keyword sku: Required. Gets or sets the SKU name. Required. :paramtype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku - :keyword kind: Required. Required. Indicates the type of storage account. Known values are: - "Storage", "StorageV2", "BlobStorage", "FileStorage", "BlockBlobStorage". + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind - :keyword location: Required. Required. Gets or sets the location of the resource. This will be - one of the supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, - etc.). The geo region of a resource cannot be changed once it is created, but if an identical - geo region is specified on update, the request will succeed. + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. :paramtype location: str :keyword extended_location: Optional. Set the extended location of the resource. If not set, the storage account will be created in Azure main region. Otherwise it will be created in the specified extended location. :paramtype extended_location: ~azure.mgmt.storage.v2022_05_01.models.ExtendedLocation - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used for viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key with a - length no greater than 128 characters and a value with a length no greater than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess :keyword sas_policy: SasPolicy assigned to the storage account. @@ -7041,7 +6771,7 @@ def __init__( :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Known values are: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7057,7 +6787,7 @@ def __init__( :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. :paramtype is_hns_enabled: bool :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -7068,7 +6798,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7091,10 +6821,10 @@ def __init__( :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone - identifier. Known values are: "Standard", "AzureDnsZone". + identifier. Known values are: "Standard" and "AzureDnsZone". :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType """ - super(StorageAccountCreateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.kind = kind self.location = location @@ -7126,7 +6856,7 @@ def __init__( self.dns_endpoint_type = dns_endpoint_type -class StorageAccountInternetEndpoints(msrest.serialization.Model): +class StorageAccountInternetEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -7142,33 +6872,29 @@ class StorageAccountInternetEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountInternetEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.file = None self.web = None self.dfs = None -class StorageAccountKey(msrest.serialization.Model): +class StorageAccountKey(_serialization.Model): """An access key for the storage account. Variables are only populated by the server, and will be ignored when sending a request. @@ -7178,40 +6904,36 @@ class StorageAccountKey(msrest.serialization.Model): :ivar value: Base 64-encoded value of the key. :vartype value: str :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: - "Read", "Full". + "Read" and "Full". :vartype permissions: str or ~azure.mgmt.storage.v2022_05_01.models.KeyPermission :ivar creation_time: Creation time of the key, in round trip date format. :vartype creation_time: ~datetime.datetime """ _validation = { - 'key_name': {'readonly': True}, - 'value': {'readonly': True}, - 'permissions': {'readonly': True}, - 'creation_time': {'readonly': True}, + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, + "creation_time": {"readonly": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - 'permissions': {'key': 'permissions', 'type': 'str'}, - 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountKey, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.key_name = None self.value = None self.permissions = None self.creation_time = None -class StorageAccountListKeysResult(msrest.serialization.Model): +class StorageAccountListKeysResult(_serialization.Model): """The response from the ListKeys operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -7222,24 +6944,20 @@ class StorageAccountListKeysResult(msrest.serialization.Model): """ _validation = { - 'keys': {'readonly': True}, + "keys": {"readonly": True}, } _attribute_map = { - 'keys': {'key': 'keys', 'type': '[StorageAccountKey]'}, + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListKeysResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.keys = None -class StorageAccountListResult(msrest.serialization.Model): +class StorageAccountListResult(_serialization.Model): """The response from the List Storage Accounts operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -7252,27 +6970,23 @@ class StorageAccountListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'next_link': {'readonly': True}, + "value": {"readonly": True}, + "next_link": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[StorageAccount]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.next_link = None -class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): +class StorageAccountMicrosoftEndpoints(_serialization.Model): """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing endpoint. Variables are only populated by the server, and will be ignored when sending a request. @@ -7292,30 +7006,26 @@ class StorageAccountMicrosoftEndpoints(msrest.serialization.Model): """ _validation = { - 'blob': {'readonly': True}, - 'queue': {'readonly': True}, - 'table': {'readonly': True}, - 'file': {'readonly': True}, - 'web': {'readonly': True}, - 'dfs': {'readonly': True}, + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, } _attribute_map = { - 'blob': {'key': 'blob', 'type': 'str'}, - 'queue': {'key': 'queue', 'type': 'str'}, - 'table': {'key': 'table', 'type': 'str'}, - 'file': {'key': 'file', 'type': 'str'}, - 'web': {'key': 'web', 'type': 'str'}, - 'dfs': {'key': 'dfs', 'type': 'str'}, + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageAccountMicrosoftEndpoints, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.blob = None self.queue = None self.table = None @@ -7324,51 +7034,46 @@ def __init__( self.dfs = None -class StorageAccountRegenerateKeyParameters(msrest.serialization.Model): +class StorageAccountRegenerateKeyParameters(_serialization.Model): """The parameters used to regenerate the storage account key. All required parameters must be populated in order to send to Azure. - :ivar key_name: Required. The name of storage keys that want to be regenerated, possible values - are key1, key2, kerb1, kerb2. + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. :vartype key_name: str """ _validation = { - 'key_name': {'required': True}, + "key_name": {"required": True}, } _attribute_map = { - 'key_name': {'key': 'keyName', 'type': 'str'}, + "key_name": {"key": "keyName", "type": "str"}, } - def __init__( - self, - *, - key_name: str, - **kwargs - ): + def __init__(self, *, key_name: str, **kwargs): """ - :keyword key_name: Required. The name of storage keys that want to be regenerated, possible - values are key1, key2, kerb1, kerb2. + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. :paramtype key_name: str """ - super(StorageAccountRegenerateKeyParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.key_name = key_name -class StorageAccountSkuConversionStatus(msrest.serialization.Model): +class StorageAccountSkuConversionStatus(_serialization.Model): """This defines the sku conversion status object for asynchronous sku conversions. Variables are only populated by the server, and will be ignored when sending a request. :ivar sku_conversion_status: This property indicates the current sku conversion status. Known - values are: "InProgress", "Succeeded", "Failed". + values are: "InProgress", "Succeeded", and "Failed". :vartype sku_conversion_status: str or ~azure.mgmt.storage.v2022_05_01.models.SkuConversionStatus :ivar target_sku_name: This property represents the target sku name to which the account sku is being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", - "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", + "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", and "Standard_RAGZRS". :vartype target_sku_name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName :ivar start_time: This property represents the sku conversion start time. @@ -7378,54 +7083,49 @@ class StorageAccountSkuConversionStatus(msrest.serialization.Model): """ _validation = { - 'sku_conversion_status': {'readonly': True}, - 'start_time': {'readonly': True}, - 'end_time': {'readonly': True}, + "sku_conversion_status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, } _attribute_map = { - 'sku_conversion_status': {'key': 'skuConversionStatus', 'type': 'str'}, - 'target_sku_name': {'key': 'targetSkuName', 'type': 'str'}, - 'start_time': {'key': 'startTime', 'type': 'str'}, - 'end_time': {'key': 'endTime', 'type': 'str'}, + "sku_conversion_status": {"key": "skuConversionStatus", "type": "str"}, + "target_sku_name": {"key": "targetSkuName", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "end_time": {"key": "endTime", "type": "str"}, } - def __init__( - self, - *, - target_sku_name: Optional[Union[str, "_models.SkuName"]] = None, - **kwargs - ): + def __init__(self, *, target_sku_name: Optional[Union[str, "_models.SkuName"]] = None, **kwargs): """ :keyword target_sku_name: This property represents the target sku name to which the account sku is being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", - "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", + "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", and "Standard_RAGZRS". :paramtype target_sku_name: str or ~azure.mgmt.storage.v2022_05_01.models.SkuName """ - super(StorageAccountSkuConversionStatus, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku_conversion_status = None self.target_sku_name = target_sku_name self.start_time = None self.end_time = None -class StorageAccountUpdateParameters(msrest.serialization.Model): +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes """The parameters that can be provided when updating the storage account properties. :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :vartype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku - :ivar tags: A set of tags. Gets or sets a list of key value pairs that describe the resource. - These tags can be used in viewing and grouping this resource (across resource groups). A - maximum of 15 tags can be provided for a resource. Each tag must have a key no greater in - length than 128 characters and a value no greater in length than 256 characters. + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :vartype tags: dict[str, str] :ivar identity: The identity of the resource. :vartype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :vartype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7441,7 +7141,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Known values are: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", and "Premium". :vartype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.AccessTier :ivar azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7456,7 +7156,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :ivar network_rule_set: Network rule set. :vartype network_rule_set: ~azure.mgmt.storage.v2022_05_01.models.NetworkRuleSet :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :vartype large_file_shares_state: str or ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState :ivar routing_preference: Maintains information about the network routing choice opted by the @@ -7467,7 +7167,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype allow_blob_public_access: bool :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", - "TLS1_2". + and "TLS1_2". :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7481,7 +7181,7 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): authentication is OAuth or not. The default interpretation is false for this property. :vartype default_to_o_auth_authentication: bool :ivar public_network_access: Allow or disallow public network access to Storage Account. Value - is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled", + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and "Disabled". :vartype public_network_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess @@ -7491,44 +7191,50 @@ class StorageAccountUpdateParameters(msrest.serialization.Model): :vartype immutable_storage_with_versioning: ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageAccount :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values - are: "Standard", "AzureDnsZone". + are: "Standard" and "AzureDnsZone". :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType """ _attribute_map = { - 'sku': {'key': 'sku', 'type': 'Sku'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'identity': {'key': 'identity', 'type': 'Identity'}, - 'kind': {'key': 'kind', 'type': 'str'}, - 'custom_domain': {'key': 'properties.customDomain', 'type': 'CustomDomain'}, - 'encryption': {'key': 'properties.encryption', 'type': 'Encryption'}, - 'sas_policy': {'key': 'properties.sasPolicy', 'type': 'SasPolicy'}, - 'key_policy': {'key': 'properties.keyPolicy', 'type': 'KeyPolicy'}, - 'access_tier': {'key': 'properties.accessTier', 'type': 'str'}, - 'azure_files_identity_based_authentication': {'key': 'properties.azureFilesIdentityBasedAuthentication', 'type': 'AzureFilesIdentityBasedAuthentication'}, - 'enable_https_traffic_only': {'key': 'properties.supportsHttpsTrafficOnly', 'type': 'bool'}, - 'is_sftp_enabled': {'key': 'properties.isSftpEnabled', 'type': 'bool'}, - 'is_local_user_enabled': {'key': 'properties.isLocalUserEnabled', 'type': 'bool'}, - 'network_rule_set': {'key': 'properties.networkAcls', 'type': 'NetworkRuleSet'}, - 'large_file_shares_state': {'key': 'properties.largeFileSharesState', 'type': 'str'}, - 'routing_preference': {'key': 'properties.routingPreference', 'type': 'RoutingPreference'}, - 'allow_blob_public_access': {'key': 'properties.allowBlobPublicAccess', 'type': 'bool'}, - 'minimum_tls_version': {'key': 'properties.minimumTlsVersion', 'type': 'str'}, - 'allow_shared_key_access': {'key': 'properties.allowSharedKeyAccess', 'type': 'bool'}, - 'allow_cross_tenant_replication': {'key': 'properties.allowCrossTenantReplication', 'type': 'bool'}, - 'default_to_o_auth_authentication': {'key': 'properties.defaultToOAuthAuthentication', 'type': 'bool'}, - 'public_network_access': {'key': 'properties.publicNetworkAccess', 'type': 'str'}, - 'immutable_storage_with_versioning': {'key': 'properties.immutableStorageWithVersioning', 'type': 'ImmutableStorageAccount'}, - 'allowed_copy_scope': {'key': 'properties.allowedCopyScope', 'type': 'str'}, - 'dns_endpoint_type': {'key': 'properties.dnsEndpointType', 'type': 'str'}, - } - - def __init__( + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals self, *, sku: Optional["_models.Sku"] = None, @@ -7563,16 +7269,16 @@ def __init__( Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. :paramtype sku: ~azure.mgmt.storage.v2022_05_01.models.Sku - :keyword tags: A set of tags. Gets or sets a list of key value pairs that describe the - resource. These tags can be used in viewing and grouping this resource (across resource - groups). A maximum of 15 tags can be provided for a resource. Each tag must have a key no - greater in length than 128 characters and a value no greater in length than 256 characters. + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. :paramtype tags: dict[str, str] :keyword identity: The identity of the resource. :paramtype identity: ~azure.mgmt.storage.v2022_05_01.models.Identity :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", - "BlockBlobStorage". + and "BlockBlobStorage". :paramtype kind: str or ~azure.mgmt.storage.v2022_05_01.models.Kind :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the CNAME source. Only one custom domain is supported per storage account at this time. To clear @@ -7588,7 +7294,7 @@ def __init__( :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier is used for billing. The 'Premium' access tier is the default value for premium block blobs storage account type and it cannot be changed for the premium block blobs storage account type. - Known values are: "Hot", "Cool", "Premium". + Known values are: "Hot", "Cool", and "Premium". :paramtype access_tier: str or ~azure.mgmt.storage.v2022_05_01.models.AccessTier :keyword azure_files_identity_based_authentication: Provides the identity based authentication settings for Azure Files. @@ -7604,7 +7310,7 @@ def __init__( :keyword network_rule_set: Network rule set. :paramtype network_rule_set: ~azure.mgmt.storage.v2022_05_01.models.NetworkRuleSet :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be - disabled once it is enabled. Known values are: "Disabled", "Enabled". + disabled once it is enabled. Known values are: "Disabled" and "Enabled". :paramtype large_file_shares_state: str or ~azure.mgmt.storage.v2022_05_01.models.LargeFileSharesState :keyword routing_preference: Maintains information about the network routing choice opted by @@ -7615,7 +7321,7 @@ def __init__( :paramtype allow_blob_public_access: bool :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", - "TLS1_1", "TLS1_2". + "TLS1_1", and "TLS1_2". :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2022_05_01.models.MinimumTlsVersion :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be authorized with the account access key via Shared Key. If false, then all requests, including @@ -7630,7 +7336,7 @@ def __init__( :paramtype default_to_o_auth_authentication: bool :keyword public_network_access: Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: - "Enabled", "Disabled". + "Enabled" and "Disabled". :paramtype public_network_access: str or ~azure.mgmt.storage.v2022_05_01.models.PublicNetworkAccess :keyword immutable_storage_with_versioning: The property is immutable and can only be set to @@ -7639,15 +7345,15 @@ def __init__( :paramtype immutable_storage_with_versioning: ~azure.mgmt.storage.v2022_05_01.models.ImmutableStorageAccount :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or - with Private Links to the same VNet. Known values are: "PrivateLink", "AAD". + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_05_01.models.AllowedCopyScope :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone - identifier. Known values are: "Standard", "AzureDnsZone". + identifier. Known values are: "Standard" and "AzureDnsZone". :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_05_01.models.DnsEndpointType """ - super(StorageAccountUpdateParameters, self).__init__(**kwargs) + super().__init__(**kwargs) self.sku = sku self.tags = tags self.identity = identity @@ -7697,36 +7403,31 @@ class StorageQueue(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'approximate_message_count': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "approximate_message_count": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'metadata': {'key': 'properties.metadata', 'type': '{str}'}, - 'approximate_message_count': {'key': 'properties.approximateMessageCount', 'type': 'int'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "approximate_message_count": {"key": "properties.approximateMessageCount", "type": "int"}, } - def __init__( - self, - *, - metadata: Optional[Dict[str, str]] = None, - **kwargs - ): + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): """ :keyword metadata: A name-value pair that represents queue metadata. :paramtype metadata: dict[str, str] """ - super(StorageQueue, self).__init__(**kwargs) + super().__init__(**kwargs) self.metadata = metadata self.approximate_message_count = None -class StorageSkuListResult(msrest.serialization.Model): +class StorageSkuListResult(_serialization.Model): """The response from the List Storage SKUs operation. Variables are only populated by the server, and will be ignored when sending a request. @@ -7736,49 +7437,45 @@ class StorageSkuListResult(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, + "value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': '[SkuInformation]'}, + "value": {"key": "value", "type": "[SkuInformation]"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(StorageSkuListResult, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None -class SystemData(msrest.serialization.Model): +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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :vartype created_by_type: str or ~azure.mgmt.storage.v2022_05_01.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", "Key". + are: "User", "Application", "ManagedIdentity", and "Key". :vartype last_modified_by_type: str or ~azure.mgmt.storage.v2022_05_01.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'}, + "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__( @@ -7796,19 +7493,19 @@ def __init__( :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", "Key". + "User", "Application", "ManagedIdentity", and "Key". :paramtype created_by_type: str or ~azure.mgmt.storage.v2022_05_01.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", "Key". + values are: "User", "Application", "ManagedIdentity", and "Key". :paramtype last_modified_by_type: str or ~azure.mgmt.storage.v2022_05_01.models.CreatedByType :keyword last_modified_at: The timestamp of resource last modification (UTC). :paramtype last_modified_at: ~datetime.datetime """ - super(SystemData, self).__init__(**kwargs) + super().__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type self.created_at = created_at @@ -7837,37 +7534,32 @@ class Table(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'table_name': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "table_name": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'table_name': {'key': 'properties.tableName', 'type': 'str'}, - 'signed_identifiers': {'key': 'properties.signedIdentifiers', 'type': '[TableSignedIdentifier]'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[TableSignedIdentifier]"}, } - def __init__( - self, - *, - signed_identifiers: Optional[List["_models.TableSignedIdentifier"]] = None, - **kwargs - ): + def __init__(self, *, signed_identifiers: Optional[List["_models.TableSignedIdentifier"]] = None, **kwargs): """ :keyword signed_identifiers: List of stored access policies specified on the table. :paramtype signed_identifiers: list[~azure.mgmt.storage.v2022_05_01.models.TableSignedIdentifier] """ - super(Table, self).__init__(**kwargs) + super().__init__(**kwargs) self.table_name = None self.signed_identifiers = signed_identifiers -class TableAccessPolicy(msrest.serialization.Model): +class TableAccessPolicy(_serialization.Model): """Table Access Policy Properties Object. All required parameters must be populated in order to send to Azure. @@ -7876,19 +7568,19 @@ class TableAccessPolicy(msrest.serialization.Model): :vartype start_time: ~datetime.datetime :ivar expiry_time: Expiry time of the access policy. :vartype expiry_time: ~datetime.datetime - :ivar permission: Required. Required. List of abbreviated permissions. Supported permission - values include 'r','a','u','d'. + :ivar permission: Required. List of abbreviated permissions. Supported permission values + include 'r','a','u','d'. Required. :vartype permission: str """ _validation = { - 'permission': {'required': True}, + "permission": {"required": True}, } _attribute_map = { - 'start_time': {'key': 'startTime', 'type': 'iso-8601'}, - 'expiry_time': {'key': 'expiryTime', 'type': 'iso-8601'}, - 'permission': {'key': 'permission', 'type': 'str'}, + "start_time": {"key": "startTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "permission": {"key": "permission", "type": "str"}, } def __init__( @@ -7904,11 +7596,11 @@ def __init__( :paramtype start_time: ~datetime.datetime :keyword expiry_time: Expiry time of the access policy. :paramtype expiry_time: ~datetime.datetime - :keyword permission: Required. Required. List of abbreviated permissions. Supported permission - values include 'r','a','u','d'. + :keyword permission: Required. List of abbreviated permissions. Supported permission values + include 'r','a','u','d'. Required. :paramtype permission: str """ - super(TableAccessPolicy, self).__init__(**kwargs) + super().__init__(**kwargs) self.start_time = start_time self.expiry_time = expiry_time self.permission = permission @@ -7934,124 +7626,112 @@ class TableServiceProperties(Resource): """ _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'cors': {'key': 'properties.cors', 'type': 'CorsRules'}, + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, } - def __init__( - self, - *, - cors: Optional["_models.CorsRules"] = None, - **kwargs - ): + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): """ :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule elements in the request. If no CorsRule elements are included in the request body, all CORS rules will be deleted, and CORS will be disabled for the Table service. :paramtype cors: ~azure.mgmt.storage.v2022_05_01.models.CorsRules """ - super(TableServiceProperties, self).__init__(**kwargs) + super().__init__(**kwargs) self.cors = cors -class TableSignedIdentifier(msrest.serialization.Model): +class TableSignedIdentifier(_serialization.Model): """Object to set Table Access Policy. All required parameters must be populated in order to send to Azure. - :ivar id: Required. unique-64-character-value of the stored access policy. + :ivar id: unique-64-character-value of the stored access policy. Required. :vartype id: str :ivar access_policy: Access policy. :vartype access_policy: ~azure.mgmt.storage.v2022_05_01.models.TableAccessPolicy """ _validation = { - 'id': {'required': True}, + "id": {"required": True}, } _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'access_policy': {'key': 'accessPolicy', 'type': 'TableAccessPolicy'}, + "id": {"key": "id", "type": "str"}, + "access_policy": {"key": "accessPolicy", "type": "TableAccessPolicy"}, } def __init__( self, *, - id: str, + id: str, # pylint: disable=redefined-builtin access_policy: Optional["_models.TableAccessPolicy"] = None, **kwargs ): """ - :keyword id: Required. unique-64-character-value of the stored access policy. + :keyword id: unique-64-character-value of the stored access policy. Required. :paramtype id: str :keyword access_policy: Access policy. :paramtype access_policy: ~azure.mgmt.storage.v2022_05_01.models.TableAccessPolicy """ - super(TableSignedIdentifier, self).__init__(**kwargs) + super().__init__(**kwargs) self.id = id self.access_policy = access_policy -class TagFilter(msrest.serialization.Model): +class TagFilter(_serialization.Model): """Blob index tag based filtering for blob objects. All required parameters must be populated in order to send to Azure. - :ivar name: Required. This is the filter tag name, it can have 1 - 128 characters. + :ivar name: This is the filter tag name, it can have 1 - 128 characters. Required. :vartype name: str - :ivar op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :ivar op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :vartype op: str - :ivar value: Required. This is the filter tag value field used for tag based filtering, it can - have 0 - 256 characters. + :ivar value: This is the filter tag value field used for tag based filtering, it can have 0 - + 256 characters. Required. :vartype value: str """ _validation = { - 'name': {'required': True, 'max_length': 128, 'min_length': 1}, - 'op': {'required': True}, - 'value': {'required': True, 'max_length': 256, 'min_length': 0}, + "name": {"required": True, "max_length": 128, "min_length": 1}, + "op": {"required": True}, + "value": {"required": True, "max_length": 256}, } _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'op': {'key': 'op', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, + "name": {"key": "name", "type": "str"}, + "op": {"key": "op", "type": "str"}, + "value": {"key": "value", "type": "str"}, } - def __init__( - self, - *, - name: str, - op: str, - value: str, - **kwargs - ): + def __init__(self, *, name: str, op: str, value: str, **kwargs): """ - :keyword name: Required. This is the filter tag name, it can have 1 - 128 characters. + :keyword name: This is the filter tag name, it can have 1 - 128 characters. Required. :paramtype name: str - :keyword op: Required. This is the comparison operator which is used for object comparison and - filtering. Only == (equality operator) is currently supported. + :keyword op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. :paramtype op: str - :keyword value: Required. This is the filter tag value field used for tag based filtering, it - can have 0 - 256 characters. + :keyword value: This is the filter tag value field used for tag based filtering, it can have 0 + - 256 characters. Required. :paramtype value: str """ - super(TagFilter, self).__init__(**kwargs) + super().__init__(**kwargs) self.name = name self.op = op self.value = value -class TagProperty(msrest.serialization.Model): +class TagProperty(_serialization.Model): """A tag of the LegalHold of a blob container. Variables are only populated by the server, and will be ignored when sending a request. @@ -8069,28 +7749,24 @@ class TagProperty(msrest.serialization.Model): """ _validation = { - 'tag': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'tag': {'key': 'tag', 'type': 'str'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(TagProperty, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.tag = None self.timestamp = None self.object_identifier = None @@ -8098,13 +7774,13 @@ def __init__( self.upn = None -class UpdateHistoryProperty(msrest.serialization.Model): +class UpdateHistoryProperty(_serialization.Model): """An update history of the ImmutabilityPolicy of a blob container. Variables are only populated by the server, and will be ignored when sending a request. :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: - put, lock and extend. Known values are: "put", "lock", "extend". + put, lock and extend. Known values are: "put", "lock", and "extend". :vartype update: str or ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicyUpdateType :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the container since the policy creation, in days. @@ -8134,23 +7810,23 @@ class UpdateHistoryProperty(msrest.serialization.Model): """ _validation = { - 'update': {'readonly': True}, - 'immutability_period_since_creation_in_days': {'readonly': True}, - 'timestamp': {'readonly': True}, - 'object_identifier': {'readonly': True}, - 'tenant_id': {'readonly': True}, - 'upn': {'readonly': True}, + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, } _attribute_map = { - 'update': {'key': 'update', 'type': 'str'}, - 'immutability_period_since_creation_in_days': {'key': 'immutabilityPeriodSinceCreationInDays', 'type': 'int'}, - 'timestamp': {'key': 'timestamp', 'type': 'iso-8601'}, - 'object_identifier': {'key': 'objectIdentifier', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'upn': {'key': 'upn', 'type': 'str'}, - 'allow_protected_append_writes': {'key': 'allowProtectedAppendWrites', 'type': 'bool'}, - 'allow_protected_append_writes_all': {'key': 'allowProtectedAppendWritesAll', 'type': 'bool'}, + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, } def __init__( @@ -8175,7 +7851,7 @@ def __init__( 'allowProtectedAppendWritesAll' properties are mutually exclusive. :paramtype allow_protected_append_writes_all: bool """ - super(UpdateHistoryProperty, self).__init__(**kwargs) + super().__init__(**kwargs) self.update = None self.immutability_period_since_creation_in_days = None self.timestamp = None @@ -8186,13 +7862,13 @@ def __init__( self.allow_protected_append_writes_all = allow_protected_append_writes_all -class Usage(msrest.serialization.Model): +class Usage(_serialization.Model): """Describes Storage Resource Usage. Variables are only populated by the server, and will be ignored when sending a request. :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", - "Percent", "CountsPerSecond", "BytesPerSecond". + "Percent", "CountsPerSecond", and "BytesPerSecond". :vartype unit: str or ~azure.mgmt.storage.v2022_05_01.models.UsageUnit :ivar current_value: Gets the current count of the allocated resources in the subscription. :vartype current_value: int @@ -8203,33 +7879,29 @@ class Usage(msrest.serialization.Model): """ _validation = { - 'unit': {'readonly': True}, - 'current_value': {'readonly': True}, - 'limit': {'readonly': True}, - 'name': {'readonly': True}, + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, } _attribute_map = { - 'unit': {'key': 'unit', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'int'}, - 'limit': {'key': 'limit', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'UsageName'}, + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(Usage, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.unit = None self.current_value = None self.limit = None self.name = None -class UsageListResult(msrest.serialization.Model): +class UsageListResult(_serialization.Model): """The response from the List Usages operation. :ivar value: Gets or sets the list of Storage Resource Usages. @@ -8237,24 +7909,19 @@ class UsageListResult(msrest.serialization.Model): """ _attribute_map = { - 'value': {'key': 'value', 'type': '[Usage]'}, + "value": {"key": "value", "type": "[Usage]"}, } - def __init__( - self, - *, - value: Optional[List["_models.Usage"]] = None, - **kwargs - ): + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): """ :keyword value: Gets or sets the list of Storage Resource Usages. :paramtype value: list[~azure.mgmt.storage.v2022_05_01.models.Usage] """ - super(UsageListResult, self).__init__(**kwargs) + super().__init__(**kwargs) self.value = value -class UsageName(msrest.serialization.Model): +class UsageName(_serialization.Model): """The usage names that can be used; currently limited to StorageAccount. Variables are only populated by the server, and will be ignored when sending a request. @@ -8266,27 +7933,23 @@ class UsageName(msrest.serialization.Model): """ _validation = { - 'value': {'readonly': True}, - 'localized_value': {'readonly': True}, + "value": {"readonly": True}, + "localized_value": {"readonly": True}, } _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UsageName, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.value = None self.localized_value = None -class UserAssignedIdentity(msrest.serialization.Model): +class UserAssignedIdentity(_serialization.Model): """UserAssignedIdentity for the resource. Variables are only populated by the server, and will be ignored when sending a request. @@ -8298,72 +7961,68 @@ class UserAssignedIdentity(msrest.serialization.Model): """ _validation = { - 'principal_id': {'readonly': True}, - 'client_id': {'readonly': True}, + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, } _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'client_id': {'key': 'clientId', 'type': 'str'}, + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, } - def __init__( - self, - **kwargs - ): - """ - """ - super(UserAssignedIdentity, self).__init__(**kwargs) + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) self.principal_id = None self.client_id = None -class VirtualNetworkRule(msrest.serialization.Model): +class VirtualNetworkRule(_serialization.Model): """Virtual Network rule. All required parameters must be populated in order to send to Azure. - :ivar virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :vartype virtual_network_resource_id: str - :ivar action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :ivar action: The action of virtual network rule. Default value is "Allow". :vartype action: str :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", - "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". :vartype state: str or ~azure.mgmt.storage.v2022_05_01.models.State """ _validation = { - 'virtual_network_resource_id': {'required': True}, + "virtual_network_resource_id": {"required": True}, } _attribute_map = { - 'virtual_network_resource_id': {'key': 'id', 'type': 'str'}, - 'action': {'key': 'action', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, } def __init__( self, *, virtual_network_resource_id: str, - action: Optional[str] = None, + action: Optional[Literal["Allow"]] = None, state: Optional[Union[str, "_models.State"]] = None, **kwargs ): """ - :keyword virtual_network_resource_id: Required. Resource ID of a subnet, for example: + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. :paramtype virtual_network_resource_id: str - :keyword action: The action of virtual network rule. The only acceptable values to pass in are - None and "Allow". The default value is None. + :keyword action: The action of virtual network rule. Default value is "Allow". :paramtype action: str :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", - "Deprovisioning", "Succeeded", "Failed", "NetworkSourceDeleted". + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". :paramtype state: str or ~azure.mgmt.storage.v2022_05_01.models.State """ - super(VirtualNetworkRule, self).__init__(**kwargs) + super().__init__(**kwargs) self.virtual_network_resource_id = virtual_network_resource_id self.action = action self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py index 5218134c47f9..27f7fbc6d9eb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/models/_storage_management_client_enums.py @@ -20,6 +20,7 @@ class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): COOL = "Cool" PREMIUM = "Premium" + class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the policy, Unlocked state allows increase and decrease of immutability retention time and also @@ -33,6 +34,7 @@ class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMet LOCKED = "Locked" DISABLED = "Disabled" + class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the status indicating whether the primary location of the storage account is available or unavailable. @@ -41,13 +43,14 @@ class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): AVAILABLE = "available" UNAVAILABLE = "unavailable" + class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the Active Directory account type for Azure Storage. - """ + """Specifies the Active Directory account type for Azure Storage.""" USER = "User" COMPUTER = "Computer" + class AllowedCopyScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet. @@ -56,7 +59,9 @@ class AllowedCopyScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): PRIVATE_LINK = "PrivateLink" AAD = "AAD" + class AllowedMethods(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AllowedMethods.""" DELETE = "DELETE" GET = "GET" @@ -67,10 +72,13 @@ class AllowedMethods(str, Enum, metaclass=CaseInsensitiveEnumMeta): PUT = "PUT" PATCH = "PATCH" + class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobInventoryPolicyName.""" DEFAULT = "default" + class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - @@ -81,6 +89,7 @@ class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): COMPLETE = "Complete" FAILED = "Failed" + class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to @@ -92,40 +101,41 @@ class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): METRICS = "Metrics" AZURE_SERVICES = "AzureServices" + class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of identity that created the resource. - """ + """The type of identity that created the resource.""" USER = "User" APPLICATION = "Application" MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" + class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the default action of allow or deny when no other rules match. - """ + """Specifies the default action of allow or deny when no other rules match.""" ALLOW = "Allow" DENY = "Deny" + class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Default share permission for users using Kerberos authentication if RBAC role is not assigned. - """ + """Default share permission for users using Kerberos authentication if RBAC role is not assigned.""" NONE = "None" STORAGE_FILE_DATA_SMB_SHARE_READER = "StorageFileDataSmbShareReader" STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = "StorageFileDataSmbShareContributor" STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" + class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the directory service used. Note that this enum may be extended in the future. - """ + """Indicates the directory service used. Note that this enum may be extended in the future.""" NONE = "None" AADDS = "AADDS" AD = "AD" AADKERB = "AADKERB" + class DnsEndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the @@ -135,6 +145,7 @@ class DnsEndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD = "Standard" AZURE_DNS_ZONE = "AzureDnsZone" + class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The authentication protocol that is used for the file share. Can only be specified when creating a share. @@ -143,6 +154,7 @@ class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): SMB = "SMB" NFS = "NFS" + class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, Microsoft.KeyVault. @@ -151,32 +163,33 @@ class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled. - """ + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled.""" ENABLED = "Enabled" DISABLED = "Disabled" + class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SAS expiration action. Can only be Log. - """ + """The SAS expiration action. Can only be Log.""" LOG = "Log" + class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The type of extendedLocation. - """ + """The type of extendedLocation.""" EDGE_ZONE = "EdgeZone" + class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is a required field, it specifies the format for the inventory files. - """ + """This is a required field, it specifies the format for the inventory files.""" CSV = "Csv" PARQUET = "Parquet" + class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status of the secondary location. Possible values are: - Live: Indicates that the secondary location is active and operational. - Bootstrap: Indicates initial synchronization from the @@ -189,29 +202,30 @@ class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): BOOTSTRAP = "Bootstrap" UNAVAILABLE = "Unavailable" + class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The protocol permitted for a request made with the account SAS. - """ + """The protocol permitted for a request made with the account SAS.""" HTTPS_HTTP = "https,http" HTTPS = "https" + class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The identity type. - """ + """The identity type.""" NONE = "None" SYSTEM_ASSIGNED = "SystemAssigned" USER_ASSIGNED = "UserAssigned" SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked. - """ + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and extend. @@ -221,27 +235,29 @@ class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta) LOCK = "lock" EXTEND = "extend" + class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Inventory - """ + """The valid value is Inventory.""" INVENTORY = "Inventory" + class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Permissions for the key -- read-only or full permissions. - """ + """Permissions for the key -- read-only or full permissions.""" READ = "Read" FULL = "Full" + class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, - Microsoft.Keyvault + Microsoft.Keyvault. """ MICROSOFT_STORAGE = "Microsoft.Storage" MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Encryption key type to be used for the encryption service. 'Account' key type implies that an account-scoped encryption key will be used. 'Service' key type implies that a default service @@ -251,9 +267,9 @@ class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): SERVICE = "Service" ACCOUNT = "Account" + class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Indicates the type of storage account. - """ + """Indicates the type of storage account.""" STORAGE = "Storage" STORAGE_V2 = "StorageV2" @@ -261,22 +277,23 @@ class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): FILE_STORAGE = "FileStorage" BLOCK_BLOB_STORAGE = "BlockBlobStorage" + class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled. - """ + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" DISABLED = "Disabled" ENABLED = "Enabled" + class LeaseContainerRequestEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Specifies whether the lease on a container is of infinite or fixed duration, only when the @@ -286,19 +303,19 @@ class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): INFINITE = "Infinite" FIXED = "Fixed" + class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies the lease action. Can be one of the available actions. - """ + """Specifies the lease action. Can be one of the available actions.""" ACQUIRE = "Acquire" RENEW = "Renew" CHANGE = "Change" RELEASE = "Release" - BREAK_ENUM = "Break" + BREAK = "Break" + class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Lease state of the container. - """ + """Lease state of the container.""" AVAILABLE = "Available" LEASED = "Leased" @@ -306,21 +323,26 @@ class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): BREAKING = "Breaking" BROKEN = "Broken" + class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The lease status of the container. - """ + """The lease status of the container.""" LOCKED = "Locked" UNLOCKED = "Unlocked" + class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListContainersInclude.""" DELETED = "deleted" + class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" DEFAULT = "default" + class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This property denotes the container level immutability to object level immutability migration state. @@ -329,6 +351,7 @@ class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): IN_PROGRESS = "InProgress" COMPLETED = "Completed" + class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Set the minimum TLS version to be permitted on requests to storage. The default interpretation is TLS 1.0 for this property. @@ -338,12 +361,13 @@ class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): TLS1_1 = "TLS1_1" TLS1_2 = "TLS1_2" + class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only - """ + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only.""" ACCESS_TIME_TRACKING = "AccessTimeTracking" + class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """This is a required field. This field specifies the scope of the inventory created either at the blob or container level. @@ -352,6 +376,7 @@ class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): BLOB = "Blob" CONTAINER = "Container" + class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). @@ -366,39 +391,40 @@ class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): U = "u" P = "p" + class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The current provisioning state. - """ + """The current provisioning state.""" SUCCEEDED = "Succeeded" CREATING = "Creating" DELETING = "Deleting" FAILED = "Failed" + class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The private endpoint connection status. - """ + """The private endpoint connection status.""" PENDING = "Pending" APPROVED = "Approved" REJECTED = "Rejected" + class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the status of the storage account at the time the operation was called. - """ + """Gets the status of the storage account at the time the operation was called.""" CREATING = "Creating" RESOLVING_DNS = "ResolvingDNS" SUCCEEDED = "Succeeded" + class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Specifies whether data in the container may be accessed publicly and the level of access. - """ + """Specifies whether data in the container may be accessed publicly and the level of access.""" CONTAINER = "Container" BLOB = "Blob" NONE = "None" + class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Allow or disallow public network access to Storage Account. Value is optional but if passed in, must be 'Enabled' or 'Disabled'. @@ -407,6 +433,7 @@ class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): ENABLED = "Enabled" DISABLED = "Disabled" + class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets the reason that a storage account name could not be used. The Reason element is only returned if NameAvailable is false. @@ -415,6 +442,7 @@ class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): ACCOUNT_NAME_INVALID = "AccountNameInvalid" ALREADY_EXISTS = "AlreadyExists" + class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The reason for the restriction. As of now this can be "QuotaId" or "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the @@ -425,34 +453,35 @@ class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): QUOTA_ID = "QuotaId" NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The property is for NFS share only. The default is NoRootSquash. - """ + """The property is for NFS share only. The default is NoRootSquash.""" NO_ROOT_SQUASH = "NoRootSquash" ROOT_SQUASH = "RootSquash" ALL_SQUASH = "AllSquash" + class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Routing Choice defines the kind of network routing opted by the user. - """ + """Routing Choice defines the kind of network routing opted by the user.""" MICROSOFT_ROUTING = "MicrosoftRouting" INTERNET_ROUTING = "InternetRouting" + class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The valid value is Lifecycle - """ + """The valid value is Lifecycle.""" LIFECYCLE = "Lifecycle" + class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This is a required field. This field is used to schedule an inventory formation. - """ + """This is a required field. This field is used to schedule an inventory formation.""" DAILY = "Daily" WEEKLY = "Weekly" + class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue (q), Table (t), File (f). @@ -463,6 +492,7 @@ class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): T = "t" F = "f" + class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. @@ -473,6 +503,7 @@ class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): COOL = "Cool" PREMIUM = "Premium" + class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed services accessible with the service SAS. Possible values include: Blob (b), Container (c), File (f), Share (s). @@ -483,6 +514,7 @@ class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): F = "f" S = "s" + class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The signed resource types that are accessible with the account SAS. Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to @@ -493,14 +525,15 @@ class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): C = "c" O = "o" + class SkuConversionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """This property indicates the current sku conversion status. - """ + """This property indicates the current sku conversion status.""" IN_PROGRESS = "InProgress" SUCCEEDED = "Succeeded" FAILED = "Failed" + class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The SKU name. Required for account creation; optional for update. Note that in older versions, SKU name was called accountType. @@ -515,16 +548,16 @@ class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): STANDARD_GZRS = "Standard_GZRS" STANDARD_RAGZRS = "Standard_RAGZRS" + class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """The SKU tier. This is based on the SKU name. - """ + """The SKU tier. This is based on the SKU name.""" STANDARD = "Standard" PREMIUM = "Premium" + class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the state of virtual network rule. - """ + """Gets the state of virtual network rule.""" PROVISIONING = "Provisioning" DEPROVISIONING = "Deprovisioning" @@ -532,14 +565,16 @@ class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): FAILED = "Failed" NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" + class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountExpand.""" GEO_REPLICATION_STATS = "geoReplicationStats" BLOB_RESTORE_STATUS = "blobRestoreStatus" + class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): - """Gets the unit of measurement. - """ + """Gets the unit of measurement.""" COUNT = "Count" BYTES = "Bytes" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/__init__.py index 22f9808d440a..b58975e023a9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/__init__.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/__init__.py @@ -30,27 +30,28 @@ from ._patch import __all__ as _patch_all from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import from ._patch import patch_sdk as _patch_sdk + __all__ = [ - 'Operations', - 'SkusOperations', - 'StorageAccountsOperations', - 'DeletedAccountsOperations', - 'UsagesOperations', - 'ManagementPoliciesOperations', - 'BlobInventoryPoliciesOperations', - 'PrivateEndpointConnectionsOperations', - 'PrivateLinkResourcesOperations', - 'ObjectReplicationPoliciesOperations', - 'LocalUsersOperations', - 'EncryptionScopesOperations', - 'BlobServicesOperations', - 'BlobContainersOperations', - 'FileServicesOperations', - 'FileSharesOperations', - 'QueueServicesOperations', - 'QueueOperations', - 'TableServicesOperations', - 'TableOperations', + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "LocalUsersOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", ] __all__.extend([p for p in _patch_all if p not in __all__]) -_patch_sdk() \ No newline at end of file +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_operations.py index acf7df0183fa..ccb546a9998f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_containers_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,13 +29,20 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -36,303 +50,253 @@ def build_list_request( *, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobContainer] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_set_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_clear_legal_hold_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LegalHold] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_immutability_policy_request( @@ -341,50 +305,45 @@ def build_create_or_update_immutability_policy_request( container_name: str, subscription_id: str, *, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, if_match: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_immutability_policy_request( @@ -399,37 +358,36 @@ def build_get_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if if_match is not None: - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_immutability_policy_request( @@ -444,36 +402,35 @@ def build_delete_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_lock_immutability_policy_request( @@ -488,34 +445,33 @@ def build_lock_immutability_policy_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_extend_immutability_policy_request( @@ -525,132 +481,113 @@ def build_extend_immutability_policy_request( subscription_id: str, *, if_match: str, - json: Optional[_models.ImmutabilityPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - *, - json: Optional[_models.LeaseContainerRequest] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_object_level_worm_request_initial( - resource_group_name: str, - account_name: str, - container_name: str, - subscription_id: str, - **kwargs: Any +def build_object_level_worm_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "containerName": _SERIALIZER.url("container_name", container_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobContainersOperations: """ @@ -671,7 +608,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -679,18 +615,18 @@ def list( account_name: str, maxpagesize: Optional[str] = None, filter: Optional[str] = None, - include: Optional[Union[str, "_models.ListContainersInclude"]] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, **kwargs: Any - ) -> Iterable[_models.ListContainerItems]: + ) -> Iterable["_models.ListContainerItem"]: """Lists all containers and does not support a prefix like data plane. Also SRP today does not return continuation token. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of containers that can be included in the list. Default value is None. @@ -699,35 +635,39 @@ def list( listed. Default value is None. :type filter: str :param include: Optional, used to include the properties for soft deleted blob containers. - Default value is None. + "deleted" Default value is None. :type include: str or ~azure.mgmt.storage.v2022_05_01.models.ListContainersInclude :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListContainerItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListContainerItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListContainerItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, include=include, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -735,18 +675,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - include=include, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -763,10 +702,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -776,19 +713,19 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Creates a new container under the specified account as described by request body. The container @@ -796,37 +733,124 @@ def create( blobs contained by the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties of the blob container to create. + :param blob_container: Properties of the blob container to create. Required. :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_create_request( resource_group_name=resource_group_name, @@ -836,7 +860,8 @@ def create( api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -844,10 +869,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -855,63 +879,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, container_name: str, blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobContainer: """Updates container properties as specified in request body. Properties not mentioned in the request will be unchanged. Update fails if the specified container doesn't already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param blob_container: Properties to update for the blob container. + :param blob_container: Properties to update for the blob container. Required. :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer 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 - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - _json = self._serialize.body(blob_container, 'BlobContainer') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") request = build_update_request( resource_group_name=resource_group_name, @@ -921,7 +1031,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -929,72 +1040,68 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> _models.BlobContainer: """Gets properties of a specified container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobContainer, or the result of cls(response) + :return: BlobContainer or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobContainer - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobContainer] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -1002,72 +1109,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobContainer', pipeline_response) + deserialized = self._deserialize("BlobContainer", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: """Deletes specified container under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -1075,10 +1178,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -1088,16 +1190,17 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore - - @distributed_trace + @overload def set_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold @@ -1105,37 +1208,124 @@ def set_legal_hold( the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be set to a blob container. + :param legal_hold: The LegalHold property that will be set to a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold 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 - :return: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") request = build_set_legal_hold_request( resource_group_name=resource_group_name, @@ -1145,7 +1335,8 @@ def set_legal_hold( api_version=api_version, content_type=content_type, json=_json, - template_url=self.set_legal_hold.metadata['url'], + content=_content, + template_url=self.set_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1153,80 +1344,166 @@ def set_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore - - @distributed_trace + @overload def clear_legal_hold( self, resource_group_name: str, account_name: str, container_name: str, legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LegalHold: """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent operation. ClearLegalHold clears out only the specified tags in the request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str - :param legal_hold: The LegalHold property that will be clear from a blob container. + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :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: LegalHold, or the result of cls(response) + :return: LegalHold or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ - error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError - } - error_map.update(kwargs.pop('error_map', {}) or {}) - - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LegalHold] - _json = self._serialize.body(legal_hold, 'LegalHold') - - request = build_clear_legal_hold_request( - resource_group_name=resource_group_name, - account_name=account_name, - container_name=container_name, - subscription_id=self._config.subscription_id, + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_05_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + request = build_clear_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.clear_legal_hold.metadata['url'], + content=_content, + template_url=self.clear_legal_hold.metadata["url"], headers=_headers, params=_params, ) @@ -1234,27 +1511,25 @@ def clear_legal_hold( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LegalHold', pipeline_response) + deserialized = self._deserialize("LegalHold", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - clear_legal_hold.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore - - @distributed_trace + @overload def create_or_update_immutability_policy( self, resource_group_name: str, @@ -1262,22 +1537,24 @@ def create_or_update_immutability_policy( container_name: str, if_match: Optional[str] = None, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but not required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -1286,44 +1563,149 @@ def create_or_update_immutability_policy( :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy or IO + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: 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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_create_or_update_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, content_type=content_type, json=_json, - if_match=if_match, - template_url=self.create_or_update_immutability_policy.metadata['url'], + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1331,10 +1713,9 @@ def create_or_update_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1342,17 +1723,16 @@ def create_or_update_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - create_or_update_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def get_immutability_policy( @@ -1367,16 +1747,16 @@ def get_immutability_policy( body. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If @@ -1387,32 +1767,34 @@ def get_immutability_policy( "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_get_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.get_immutability_policy.metadata['url'], + template_url=self.get_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1420,10 +1802,9 @@ def get_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1431,26 +1812,20 @@ def get_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - get_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def delete_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Aborts an unlocked immutability policy. The response of delete has immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this @@ -1458,52 +1833,54 @@ def delete_immutability_policy( container after deleting all expired blobs inside the policy locked container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype immutability_policy_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - immutability_policy_name = kwargs.pop('immutability_policy_name', "default") # type: str - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_delete_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, immutability_policy_name=immutability_policy_name, api_version=api_version, - if_match=if_match, - template_url=self.delete_immutability_policy.metadata['url'], + template_url=self.delete_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1511,10 +1888,9 @@ def delete_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1522,71 +1898,67 @@ def delete_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - delete_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore - + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore @distributed_trace def lock_immutability_policy( - self, - resource_group_name: str, - account_name: str, - container_name: str, - if_match: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any ) -> _models.ImmutabilityPolicy: """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - request = build_lock_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, - api_version=api_version, if_match=if_match, - template_url=self.lock_immutability_policy.metadata['url'], + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1594,10 +1966,9 @@ def lock_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1605,19 +1976,18 @@ def lock_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lock_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore - @distributed_trace + @overload def extend_immutability_policy( self, resource_group_name: str, @@ -1625,6 +1995,8 @@ def extend_immutability_policy( container_name: str, if_match: str, parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ImmutabilityPolicy: """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only @@ -1632,56 +2004,155 @@ def extend_immutability_policy( operation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param if_match: The entity state (ETag) version of the immutability policy to update. A value of "*" can be used to apply the operation only if the immutability policy already exists. If - omitted, this operation will always be applied. + omitted, this operation will always be applied. Required. :type if_match: str :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob container. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy 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 - :return: ImmutabilityPolicy, or the result of cls(response) + :return: ImmutabilityPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ImmutabilityPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ImmutabilityPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] - if parameters is not None: - _json = self._serialize.body(parameters, 'ImmutabilityPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None request = build_extend_immutability_policy_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, + if_match=if_match, api_version=api_version, content_type=content_type, - if_match=if_match, json=_json, - template_url=self.extend_immutability_policy.metadata['url'], + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], headers=_headers, params=_params, ) @@ -1689,10 +2160,9 @@ def extend_immutability_policy( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -1700,65 +2170,151 @@ def extend_immutability_policy( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('ImmutabilityPolicy', pipeline_response) + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - extend_immutability_policy.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore - @distributed_trace + @overload def lease( self, resource_group_name: str, account_name: str, container_name: str, parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseContainerResponse: """The Lease Container operation establishes and manages a lock on a container for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_name: str :param parameters: Lease Container request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerRequest 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 - :return: LeaseContainerResponse, or the result of cls(response) + :return: LeaseContainerResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseContainerResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseContainerResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseContainerRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, @@ -1768,7 +2324,8 @@ def lease( api_version=api_version, content_type=content_type, json=_json, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -1776,52 +2333,48 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('LeaseContainerResponse', pipeline_response) + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_object_level_worm_request_initial( + request = build_object_level_worm_request( resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._object_level_worm_initial.metadata['url'], + template_url=self._object_level_worm_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1829,10 +2382,9 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1842,16 +2394,11 @@ def _object_level_worm_initial( # pylint: disable=inconsistent-return-statement if cls: return cls(pipeline_response, None, {}) - _object_level_worm_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore - + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore @distributed_trace - def begin_object_level_worm( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - container_name: str, - **kwargs: Any + def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any ) -> LROPoller[None]: """This operation migrates a blob container from container level WORM to object level immutability enabled container. Prerequisites require a container level immutability policy either in locked @@ -1859,16 +2406,16 @@ def begin_object_level_worm( # pylint: disable=inconsistent-return-statements on the container. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param container_name: The name of the blob container within the specified storage account. Blob container names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed - by a letter or number. + by a letter or number. Required. :type container_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. @@ -1880,53 +2427,48 @@ def begin_object_level_worm( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._object_level_worm_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, container_name=container_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_object_level_worm.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_operations.py index f4accbb69fa1..d44689b9c3a8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_inventory_policies_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,167 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], - *, - json: Optional[_models.BlobInventoryPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], subscription_id: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobInventoryPoliciesOperations: """ @@ -207,52 +208,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> _models.BlobInventoryPolicy: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -260,78 +262,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobInventoryPolicy: """Sets the blob inventory policy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName - :param properties: The blob inventory policy set to a storage account. + :param properties: The blob inventory policy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy 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 - :return: BlobInventoryPolicy, or the result of cls(response) + :return: BlobInventoryPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] - _json = self._serialize.body(properties, 'BlobInventoryPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -339,71 +423,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobInventoryPolicy', pipeline_response) + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - blob_inventory_policy_name: Union[str, "_models.BlobInventoryPolicyName"], + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], **kwargs: Any ) -> None: """Deletes the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It - should always be 'default'. + should always be 'default'. "default" Required. :type blob_inventory_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -411,10 +495,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -424,51 +507,50 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListBlobInventoryPolicy]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobInventoryPolicy"]: """Gets the blob inventory policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListBlobInventoryPolicy or the result of - cls(response) + :return: An iterator like instance of either BlobInventoryPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListBlobInventoryPolicy] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListBlobInventoryPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -476,15 +558,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -501,10 +585,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -515,8 +597,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_operations.py index 3bdc01deb5e0..393fe97d4ecb 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_blob_services_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,134 +27,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class BlobServicesOperations: """ @@ -168,47 +164,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.BlobServiceItems]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: """List blob services of storage account. It returns a collection of one object named default. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 BlobServiceItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.BlobServiceItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -216,15 +214,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -241,10 +241,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -254,56 +252,139 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.BlobServiceProperties: """Sets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Blob service, including properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties or IO + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: 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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - _json = self._serialize.body(parameters, 'BlobServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -313,7 +394,8 @@ def set_service_properties( blob_services_name=blob_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -321,72 +403,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.BlobServiceProperties: """Gets the properties of a storage account’s Blob service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword blob_services_name: The name of the blob Service within the specified storage account. Blob Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype blob_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: BlobServiceProperties, or the result of cls(response) + :return: BlobServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.BlobServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - blob_services_name = kwargs.pop('blob_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, blob_services_name=blob_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -394,22 +473,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('BlobServiceProperties', pipeline_response) + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_operations.py index a0909a5c3ee0..68f34acbfc0b 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_deleted_accounts_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,81 +27,74 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_get_request( - deleted_account_name: str, - location: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request(deleted_account_name: str, location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "deletedAccountName": _SERIALIZER.url("deleted_account_name", deleted_account_name, 'str', max_length=24, min_length=3), - "location": _SERIALIZER.url("location", location, 'str'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "deletedAccountName": _SERIALIZER.url( + "deleted_account_name", deleted_account_name, "str", max_length=24, min_length=3 + ), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class DeletedAccountsOperations: """ @@ -115,38 +115,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.DeletedAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: """Lists deleted accounts under the subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either DeletedAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.DeletedAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either DeletedAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -154,13 +152,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -177,10 +179,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -191,48 +191,43 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore @distributed_trace - def get( - self, - deleted_account_name: str, - location: str, - **kwargs: Any - ) -> _models.DeletedAccount: + def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: """Get properties of specified deleted account resource. - :param deleted_account_name: Name of the deleted storage account. + :param deleted_account_name: Name of the deleted storage account. Required. :type deleted_account_name: str - :param location: The location of the deleted storage account. + :param location: The location of the deleted storage account. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: DeletedAccount, or the result of cls(response) + :return: DeletedAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.DeletedAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.DeletedAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] - request = build_get_request( deleted_account_name=deleted_account_name, location=location, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -240,10 +235,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -251,12 +245,11 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('DeletedAccount', pipeline_response) + deserialized = self._deserialize("DeletedAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_operations.py index a1687ec3ad1a..a34604f3cdb5 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_encryption_scopes_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,181 +27,164 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_put_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_patch_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - *, - json: Optional[_models.EncryptionScope] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - encryption_scope_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "encryptionScopeName": _SERIALIZER.url("encryption_scope_name", encryption_scope_name, 'str', max_length=63, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class EncryptionScopesOperations: """ @@ -215,14 +205,15 @@ def __init__(self, *args, **kwargs): 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 + @overload def put( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Synchronously creates or updates an encryption scope under the specified storage account. If an @@ -230,47 +221,137 @@ def put( properties, the encryption scope properties will be updated per the specified request. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -278,10 +359,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -290,73 +370,160 @@ def put( raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - @distributed_trace + @overload def patch( self, resource_group_name: str, account_name: str, encryption_scope_name: str, encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.EncryptionScope: """Update encryption scope properties as specified in the request body. Update fails if the specified encryption scope does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str - :param encryption_scope: Encryption scope properties to be used for the update. + :param encryption_scope: Encryption scope properties to be used for the update. Required. :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :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: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - _json = self._serialize.body(encryption_scope, 'EncryptionScope') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") request = build_patch_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.patch.metadata['url'], + content=_content, + template_url=self.patch.metadata["url"], headers=_headers, params=_params, ) @@ -364,10 +531,9 @@ def patch( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -375,62 +541,59 @@ def patch( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - patch.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - encryption_scope_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any ) -> _models.EncryptionScope: """Returns the properties for the specified encryption scope. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param encryption_scope_name: The name of the encryption scope within the specified storage account. Encryption scope names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and - followed by a letter or number. + followed by a letter or number. Required. :type encryption_scope_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: EncryptionScope, or the result of cls(response) + :return: EncryptionScope or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.EncryptionScope - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScope] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -438,10 +601,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -449,58 +611,54 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('EncryptionScope', pipeline_response) + deserialized = self._deserialize("EncryptionScope", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.EncryptionScopeListResult]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.EncryptionScope"]: """Lists all the encryption scopes available under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 EncryptionScopeListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.EncryptionScopeListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.EncryptionScopeListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -508,15 +666,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -533,10 +693,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -546,8 +704,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_operations.py index 9f80e5b5a54b..50454108fc18 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.FileServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class FileServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.FileServiceItems: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: """List all file services in storage accounts. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceItems, or the result of cls(response) + :return: FileServiceItems or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceItems - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,70 +205,152 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceItems', pipeline_response) + deserialized = self._deserialize("FileServiceItems", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileServiceProperties: """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of file services in storage accounts, including CORS - (Cross-Origin Resource Sharing) rules. + (Cross-Origin Resource Sharing) rules. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties or IO + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: 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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - _json = self._serialize.body(parameters, 'FileServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -287,7 +360,8 @@ def set_service_properties( file_services_name=file_services_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +369,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.FileServiceProperties: """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword file_services_name: The name of the file Service within the specified storage account. File Service Name must be "default". Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype file_services_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileServiceProperties, or the result of cls(response) + :return: FileServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - file_services_name = kwargs.pop('file_services_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, file_services_name=file_services_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +439,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileServiceProperties', pipeline_response) + deserialized = self._deserialize("FileServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_operations.py index 1b1f65da2c3e..aaf0c8127d2a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_file_shares_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,13 +27,20 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_request( resource_group_name: str, account_name: str, @@ -40,38 +54,37 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_request( @@ -80,95 +93,80 @@ def build_create_request( share_name: str, subscription_id: str, *, - json: Optional[_models.FileShare] = None, - content: Any = None, expand: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.FileShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( @@ -184,37 +182,36 @@ def build_get_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( @@ -230,84 +227,73 @@ def build_delete_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if include is not None: - _params['$include'] = _SERIALIZER.query("include", include, 'str') + _params["$include"] = _SERIALIZER.query("include", include, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_restore_request( - resource_group_name: str, - account_name: str, - share_name: str, - subscription_id: str, - *, - json: Optional[_models.DeletedShare] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, share_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_lease_request( @@ -316,48 +302,44 @@ def build_lease_request( share_name: str, subscription_id: str, *, - json: Optional[_models.LeaseShareRequest] = None, - content: Any = None, x_ms_snapshot: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "shareName": _SERIALIZER.url("share_name", share_name, 'str', max_length=63, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if x_ms_snapshot is not None: - _headers['x-ms-snapshot'] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, 'str') + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + class FileSharesOperations: """ @@ -378,7 +360,6 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( self, @@ -388,15 +369,15 @@ def list( filter: Optional[str] = None, expand: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.FileShareItems]: + ) -> Iterable["_models.FileShareItem"]: """Lists all shares. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional. Specified maximum number of shares that can be included in the list. Default value is None. @@ -409,32 +390,36 @@ def list( None. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either FileShareItems or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.FileShareItems] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShareItems] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, expand=expand, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -442,18 +427,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - expand=expand, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -470,10 +454,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -483,13 +465,11 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore - @distributed_trace + @overload def create( self, resource_group_name: str, @@ -497,6 +477,8 @@ def create( share_name: str, file_share: _models.FileShare, expand: Optional[str] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Creates a new share under the specified account as described by request body. The share @@ -504,51 +486,147 @@ def create( files contained by the share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties of the file share to create. + :param file_share: Properties of the file share to create. Required. :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare :param expand: Optional, used to expand the properties within share's properties. Valid values are: snapshots. Should be passed as a string with delimiter ','. Default value is None. :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + expand=expand, api_version=api_version, content_type=content_type, json=_json, - expand=expand, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -556,10 +634,9 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 201]: @@ -567,63 +644,149 @@ def create( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if response.status_code == 201: - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, share_name: str, file_share: _models.FileShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.FileShare: """Updates share properties as specified in request body. Properties not mentioned in the request will not be changed. Update fails if the specified share does not already exist. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param file_share: Properties to update for the file share. + :param file_share: Properties to update for the file share. Required. :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :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: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2022_05_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - _json = self._serialize.body(file_share, 'FileShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") request = build_update_request( resource_group_name=resource_group_name, @@ -633,7 +796,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -641,25 +805,23 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def get( @@ -674,16 +836,16 @@ def get( """Gets properties of a specified share. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param expand: Optional, used to expand the properties within share's properties. Valid values are: stats. Should be passed as a string with delimiter ','. Default value is None. @@ -692,31 +854,33 @@ def get( None. :type x_ms_snapshot: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: FileShare, or the result of cls(response) + :return: FileShare or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.FileShare - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.FileShare] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, x_ms_snapshot=x_ms_snapshot, - template_url=self.get.metadata['url'], + api_version=api_version, + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -724,25 +888,23 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('FileShare', pipeline_response) + deserialized = self._deserialize("FileShare", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements @@ -757,16 +919,16 @@ def delete( # pylint: disable=inconsistent-return-statements """Deletes specified share under its account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. :type x_ms_snapshot: str @@ -775,34 +937,37 @@ def delete( # pylint: disable=inconsistent-return-statements snapshots. If the file share contains leased-snapshots, the deletion fails. For 'leased-snapshots', the file share is deleted included all of its file share snapshots (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the - file share contains any snapshots (leased or unleased), the deletion fails. + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. :type include: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, - api_version=api_version, x_ms_snapshot=x_ms_snapshot, include=include, - template_url=self.delete.metadata['url'], + api_version=api_version, + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -810,10 +975,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -823,52 +987,135 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore - - @distributed_trace + @overload def restore( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, share_name: str, deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", **kwargs: Any ) -> None: """Restore a file share within a valid retention days if share soft delete is enabled. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str - :param deleted_share: + :param deleted_share: Required. :type deleted_share: ~azure.mgmt.storage.v2022_05_01.models.DeletedShare + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2022_05_01.models.DeletedShare 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 - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] - _json = self._serialize.body(deleted_share, 'DeletedShare') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") request = build_restore_request( resource_group_name=resource_group_name, @@ -878,7 +1125,8 @@ def restore( # pylint: disable=inconsistent-return-statements api_version=api_version, content_type=content_type, json=_json, - template_url=self.restore.metadata['url'], + content=_content, + template_url=self.restore.metadata["url"], headers=_headers, params=_params, ) @@ -886,10 +1134,9 @@ def restore( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -899,10 +1146,9 @@ def restore( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - restore.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore - @distributed_trace + @overload def lease( self, resource_group_name: str, @@ -910,60 +1156,156 @@ def lease( share_name: str, x_ms_snapshot: Optional[str] = None, parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LeaseShareResponse: """The Lease Share operation establishes and manages a lock on a share for delete operations. The lock duration can be 15 to 60 seconds, or can be infinite. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param share_name: The name of the file share within the specified storage account. File share names must be between 3 and 63 characters in length and use numbers, lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter - or number. + or number. Required. :type share_name: str :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is None. :type x_ms_snapshot: str :param parameters: Lease Share request body. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse, or the result of cls(response) + :return: LeaseShareResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LeaseShareResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] - if parameters is not None: - _json = self._serialize.body(parameters, 'LeaseShareRequest') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None request = build_lease_request( resource_group_name=resource_group_name, account_name=account_name, share_name=share_name, subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, api_version=api_version, content_type=content_type, json=_json, - x_ms_snapshot=x_ms_snapshot, - template_url=self.lease.metadata['url'], + content=_content, + template_url=self.lease.metadata["url"], headers=_headers, params=_params, ) @@ -971,10 +1313,9 @@ def lease( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -982,14 +1323,13 @@ def lease( raise HttpResponseError(response=response, error_format=ARMErrorFormat) response_headers = {} - response_headers['ETag']=self._deserialize('str', response.headers.get('ETag')) + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) - deserialized = self._deserialize('LeaseShareResponse', pipeline_response) + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, response_headers) return deserialized - lease.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore - + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_operations.py index 0332fdbff4d0..de6ab44727d4 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_local_users_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,251 +27,223 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - *, - json: Optional[_models.LocalUser] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_password_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - username: str, - **kwargs: Any + resource_group_name: str, account_name: str, username: 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "username": _SERIALIZER.url("username", username, 'str', max_length=64, min_length=3), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class LocalUsersOperations: """ @@ -285,47 +264,45 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.LocalUsers]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.LocalUser"]: """List the local users associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 LocalUsers or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.LocalUsers] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either LocalUser or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.LocalUser] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUsers] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUsers] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -333,15 +310,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -358,10 +337,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -372,56 +349,50 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any - ) -> _models.LocalUser: + def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: """Get the local user of the storage account by username. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -429,10 +400,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -440,67 +410,148 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, username: str, properties: _models.LocalUser, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.LocalUser: """Create or update the properties of a local user associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str - :param properties: The local user associated with a storage account. + :param properties: The local user associated with a storage account. Required. :type properties: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: IO + :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: LocalUser, or the result of cls(response) + :return: LocalUser or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: Union[_models.LocalUser, IO], + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Is either a model type or + a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.LocalUser 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 + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUser] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] - _json = self._serialize.body(properties, 'LocalUser') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalUser") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -508,10 +559,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -519,60 +569,57 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUser', pipeline_response) + deserialized = self._deserialize("LocalUser", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> None: """Deletes the local user associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -580,10 +627,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -594,53 +640,50 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserKeys: """List SSH authorized keys and shared key of the local user. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserKeys, or the result of cls(response) + :return: LocalUserKeys or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserKeys - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserKeys] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserKeys] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_keys.metadata['url'], + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -648,10 +691,9 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -659,60 +701,57 @@ def list_keys( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserKeys', pipeline_response) + deserialized = self._deserialize("LocalUserKeys", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore @distributed_trace def regenerate_password( - self, - resource_group_name: str, - account_name: str, - username: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any ) -> _models.LocalUserRegeneratePasswordResult: """Regenerate the local user SSH password. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param username: The name of local user. The username must contain lowercase letters and - numbers only. It must be unique only within the storage account. + numbers only. It must be unique only within the storage account. Required. :type username: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: LocalUserRegeneratePasswordResult, or the result of cls(response) + :return: LocalUserRegeneratePasswordResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.LocalUserRegeneratePasswordResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] - request = build_regenerate_password_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, username=username, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.regenerate_password.metadata['url'], + template_url=self.regenerate_password.metadata["url"], headers=_headers, params=_params, ) @@ -720,10 +759,9 @@ def regenerate_password( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -731,12 +769,11 @@ def regenerate_password( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('LocalUserRegeneratePasswordResult', pipeline_response) + deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_password.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore - + regenerate_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_operations.py index 8d9e3779dabb..cfcc9660c721 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_management_policies_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar, Union - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,129 +25,130 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_get_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], - *, - json: Optional[_models.ManagementPolicy] = None, - content: Any = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], subscription_id: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) class ManagementPoliciesOperations: """ @@ -162,52 +169,53 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def get( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> _models.ManagementPolicy: """Gets the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -215,78 +223,160 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ManagementPolicy: """Sets the managementpolicy to the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName - :param properties: The ManagementPolicy set to a storage account. + :param properties: The ManagementPolicy set to a storage account. Required. :type properties: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy 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 - :return: ManagementPolicy, or the result of cls(response) + :return: ManagementPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ManagementPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] - _json = self._serialize.body(properties, 'ManagementPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -294,71 +384,71 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ManagementPolicy', pipeline_response) + deserialized = self._deserialize("ManagementPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements self, resource_group_name: str, account_name: str, - management_policy_name: Union[str, "_models.ManagementPolicyName"], + management_policy_name: Union[str, _models.ManagementPolicyName], **kwargs: Any ) -> None: """Deletes the managementpolicy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param management_policy_name: The name of the Storage Account Management Policy. It should - always be 'default'. + always be 'default'. "default" Required. :type management_policy_name: str or ~azure.mgmt.storage.v2022_05_01.models.ManagementPolicyName :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -366,10 +456,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -379,5 +468,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_operations.py index 02bc9a746798..cdd5dad2864a 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_object_replication_policies_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,161 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_create_or_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - *, - json: Optional[_models.ObjectReplicationPolicy] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - object_replication_policy_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "objectReplicationPolicyId": _SERIALIZER.url("object_replication_policy_id", object_replication_policy_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class ObjectReplicationPoliciesOperations: """ @@ -207,49 +202,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ObjectReplicationPolicies]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.ObjectReplicationPolicy"]: """List the object replication policies associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ObjectReplicationPolicies or the result of + :return: An iterator like instance of either ObjectReplicationPolicy or the result of cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicies] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicies] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +252,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +279,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -296,58 +291,54 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Get the object replication policy of the storage account by policy ID. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -355,10 +346,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -366,70 +356,156 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - @distributed_trace + @overload def create_or_update( self, resource_group_name: str, account_name: str, object_replication_policy_id: str, properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ObjectReplicationPolicy: """Create or update the object replication policy of the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :param properties: The object replication policy set to a storage account. A unique policy ID - will be created if absent. + will be created if absent. Required. :type properties: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy 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 - :return: ObjectReplicationPolicy, or the result of cls(response) + :return: ObjectReplicationPolicy or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ObjectReplicationPolicy - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ObjectReplicationPolicy] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] - _json = self._serialize.body(properties, 'ObjectReplicationPolicy') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") request = build_create_or_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create_or_update.metadata['url'], + content=_content, + template_url=self.create_or_update.metadata["url"], headers=_headers, params=_params, ) @@ -437,10 +513,9 @@ def create_or_update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -448,62 +523,59 @@ def create_or_update( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('ObjectReplicationPolicy', pipeline_response) + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create_or_update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - object_replication_policy_id: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any ) -> None: """Deletes the object replication policy associated with the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param object_replication_policy_id: For the destination account, provide the value 'default'. Configure the policy on the destination account first. For the source account, provide the value of the policy ID that is returned when you download the policy that was defined on the - destination account. The policy is downloaded as a JSON file. + destination account. The policy is downloaded as a JSON file. Required. :type object_replication_policy_id: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: None, or the result of cls(response) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -511,10 +583,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -525,5 +596,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_operations.py index fe55857344f0..db6c089863f8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,38 +27,38 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class Operations: """ @@ -72,36 +79,35 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.OperationListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.Operation"]: """Lists all of the available Storage Rest API operations. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.OperationListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -109,12 +115,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -131,10 +142,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -144,8 +153,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/providers/Microsoft.Storage/operations"} # type: ignore + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_patch.py index 0ad201a8c586..f7dd32510333 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_patch.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_patch.py @@ -10,6 +10,7 @@ __all__: List[str] = [] # Add all objects you want publicly available to users at this package level + def patch_sdk(): """Do not remove from this file. diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_endpoint_connections_operations.py index 320e7da285c7..e2c290b4dc6d 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_endpoint_connections_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,173 +27,173 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_put_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_name: str, - *, - json: Optional[_models.PrivateEndpointConnection] = None, - content: Any = None, + subscription_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( resource_group_name: str, account_name: str, - subscription_id: str, private_endpoint_connection_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "privateEndpointConnectionName": _SERIALIZER.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateEndpointConnectionsOperations: """ @@ -207,49 +214,49 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.PrivateEndpointConnectionListResult]: + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: """List all the private endpoint connections associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 PrivateEndpointConnectionListResult or the result - of cls(response) + :return: An iterator like instance of either PrivateEndpointConnection or the result of + cls(response) :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnectionListResult] - :raises: ~azure.core.exceptions.HttpResponseError + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -257,15 +264,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -282,10 +291,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -295,56 +302,52 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore @distributed_trace def get( - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> _models.PrivateEndpointConnection: """Gets the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. 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) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -352,10 +355,9 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -363,67 +365,148 @@ def get( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - @distributed_trace + @overload def put( self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.PrivateEndpointConnection: """Update the state of specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_name: str - :param properties: The private endpoint connection properties. + :param properties: The private endpoint connection properties. Required. :type properties: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection 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 - :return: PrivateEndpointConnection, or the result of cls(response) + :return: PrivateEndpointConnection or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateEndpointConnection - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateEndpointConnection] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] - _json = self._serialize.body(properties, 'PrivateEndpointConnection') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") request = build_put_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.put.metadata['url'], + content=_content, + template_url=self.put.metadata["url"], headers=_headers, params=_params, ) @@ -431,10 +514,9 @@ def put( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -442,60 +524,57 @@ def put( error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - put.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - private_endpoint_connection_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any ) -> None: """Deletes the specified private endpoint connection associated with the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param private_endpoint_connection_name: The name of the private endpoint connection associated - with the Azure resource. + with the Azure resource. Required. :type private_endpoint_connection_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, private_endpoint_connection_name=private_endpoint_connection_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -503,10 +582,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -517,5 +595,4 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_link_resources_operations.py index 1ca28aad1028..c76c1c637353 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_link_resources_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_private_link_resources_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,48 +25,52 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_list_by_storage_account_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class PrivateLinkResourcesOperations: """ @@ -81,46 +91,44 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace def list_by_storage_account( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.PrivateLinkResourceListResult: """Gets the private link resources that need to be created for a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: PrivateLinkResourceListResult, or the result of cls(response) + :return: PrivateLinkResourceListResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.PrivateLinkResourceListResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.PrivateLinkResourceListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] - request = build_list_by_storage_account_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_by_storage_account.metadata['url'], + template_url=self.list_by_storage_account.metadata["url"], headers=_headers, params=_params, ) @@ -128,22 +136,20 @@ def list_by_storage_account( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('PrivateLinkResourceListResult', pipeline_response) + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_by_storage_account.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore - + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_operations.py index e90c04972d86..7a802a705d9f 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,183 +27,188 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - *, - json: Optional[_models.StorageQueue] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - queue_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, queue_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueName": _SERIALIZER.url("queue_name", queue_name, 'str', max_length=63, min_length=3, pattern=r'^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) def build_list_request( @@ -211,36 +223,36 @@ def build_list_request( _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if maxpagesize is not None: - _params['$maxpagesize'] = _SERIALIZER.query("maxpagesize", maxpagesize, 'str') + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") if filter is not None: - _params['$filter'] = _SERIALIZER.query("filter", filter, 'str') + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueOperations: """ @@ -261,60 +273,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def create( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -322,79 +419,163 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, queue_name: str, queue: _models.StorageQueue, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageQueue: """Creates a new queue with the specified queue name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str - :param queue: Queue properties and metadata to be created with. + :param queue: Queue properties and metadata to be created with. Required. :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - _json = self._serialize.body(queue, 'StorageQueue') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -402,72 +583,66 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any - ) -> _models.StorageQueue: + def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: """Gets the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageQueue, or the result of cls(response) + :return: StorageQueue or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageQueue - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageQueue] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -475,72 +650,68 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageQueue', pipeline_response) + deserialized = self._deserialize("StorageQueue", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - queue_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any ) -> None: """Deletes the queue with the specified queue name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param queue_name: A queue name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, it should begin and end with an alphanumeric character and it cannot have two consecutive - dash(-) characters. + dash(-) characters. Required. :type queue_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, queue_name=queue_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -548,10 +719,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -561,8 +731,7 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore @distributed_trace def list( @@ -572,15 +741,15 @@ def list( maxpagesize: Optional[str] = None, filter: Optional[str] = None, **kwargs: Any - ) -> Iterable[_models.ListQueueResource]: + ) -> Iterable["_models.ListQueue"]: """Gets a list of all the queues under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param maxpagesize: Optional, a maximum number of queues that should be included in a list queue response. Default value is None. @@ -589,31 +758,35 @@ def list( filter will be listed. 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 ListQueueResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListQueueResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either ListQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, maxpagesize=maxpagesize, filter=filter, - template_url=self.list.metadata['url'], + api_version=api_version, + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -621,17 +794,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - maxpagesize=maxpagesize, - filter=filter, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -648,10 +821,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -661,8 +832,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_operations.py index 418b7ab2de5e..8f1c9a1f83b8 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_queue_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.QueueServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class QueueServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListQueueServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: """List all queue services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListQueueServices, or the result of cls(response) + :return: ListQueueServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListQueueServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListQueueServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,70 +205,153 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListQueueServices', pipeline_response) + deserialized = self._deserialize("ListQueueServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.QueueServiceProperties: """Sets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Queue service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties or IO + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: 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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - _json = self._serialize.body(parameters, 'QueueServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -287,7 +361,8 @@ def set_service_properties( queue_service_name=queue_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +370,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.QueueServiceProperties: """Gets the properties of a storage account’s Queue service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword queue_service_name: The name of the Queue Service within the specified storage account. Queue Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype queue_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: QueueServiceProperties, or the result of cls(response) + :return: QueueServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.QueueServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - queue_service_name = kwargs.pop('queue_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.QueueServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, queue_service_name=queue_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +440,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('QueueServiceProperties', pipeline_response) + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_operations.py index d88cb1250174..3e14afd1d129 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_skus_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,44 +27,43 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class SkusOperations: """ @@ -78,38 +84,36 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageSkuListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: """Lists the available SKUs supported by Microsoft.Storage for given subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageSkuListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageSkuListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageSkuListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -117,13 +121,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -140,10 +148,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -153,8 +159,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_operations.py index 8598fd015c21..fca5324144c9 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_storage_accounts_operations.py @@ -6,11 +6,18 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Callable, Dict, Iterable, Optional, TypeVar, Union, cast - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -22,127 +29,110 @@ from azure.mgmt.core.polling.arm_polling import ARMPolling from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_check_name_availability_request( - subscription_id: str, - *, - json: Optional[_models.StorageAccountCheckNameAvailabilityParameters] = None, - content: Any = None, - **kwargs: Any -) -> HttpRequest: + +def build_check_name_availability_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability") + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_create_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountCreateParameters] = None, - content: Any = None, - **kwargs: Any + +def build_create_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) def build_get_properties_request( @@ -150,153 +140,129 @@ def build_get_properties_request( account_name: str, subscription_id: str, *, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountUpdateParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_request( - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_list_by_resource_group_request( - resource_group_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_resource_group_request(resource_group_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, '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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_list_keys_request( @@ -304,357 +270,305 @@ def build_list_keys_request( account_name: str, subscription_id: str, *, - expand: Optional[str] = "kerb", + expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") if expand is not None: - _params['$expand'] = _SERIALIZER.query("expand", expand, 'str') + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_regenerate_key_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.StorageAccountRegenerateKeyParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_account_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.AccountSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_list_service_sas_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.ServiceSasParameters] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_failover_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_failover_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) -def build_hierarchical_namespace_migration_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - request_type: str, - **kwargs: Any +def build_hierarchical_namespace_migration_request( + resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - _params['requestType'] = _SERIALIZER.query("request_type", request_type, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["requestType"] = _SERIALIZER.query("request_type", request_type, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_abort_hierarchical_namespace_migration_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + +def build_abort_hierarchical_namespace_migration_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _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 - ) + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_restore_blob_ranges_request_initial( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.BlobRestoreParameters] = None, - content: Any = None, - **kwargs: Any + +def build_restore_blob_ranges_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="POST", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) def build_revoke_user_delegation_keys_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) - return HttpRequest( - method="POST", - url=_url, - params=_params, - **kwargs - ) class StorageAccountsOperations: # pylint: disable=too-many-public-methods """ @@ -675,45 +589,98 @@ def __init__(self, *args, **kwargs): 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 + @overload def check_name_availability( self, account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.CheckNameAvailabilityResult: """Checks that the storage account name is valid and is not already in use. :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCheckNameAvailabilityParameters + :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) + :return: CheckNameAvailabilityResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.CheckNameAvailabilityResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2022_05_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.CheckNameAvailabilityResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] - _json = self._serialize.body(account_name, 'StorageAccountCheckNameAvailabilityParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") request = build_check_name_availability_request( subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.check_name_availability.metadata['url'], + content=_content, + template_url=self.check_name_availability.metadata["url"], headers=_headers, params=_params, ) @@ -721,55 +688,63 @@ def check_name_availability( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - check_name_availability.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore - + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore def _create_initial( self, resource_group_name: str, account_name: str, - parameters: _models.StorageAccountCreateParameters, + parameters: Union[_models.StorageAccountCreateParameters, IO], **kwargs: Any ) -> Optional[_models.StorageAccount]: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.StorageAccount]] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] - _json = self._serialize.body(parameters, 'StorageAccountCreateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") - request = build_create_request_initial( + request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._create_initial.metadata['url'], + content=_content, + template_url=self._create_initial.metadata["url"], headers=_headers, params=_params, ) @@ -777,10 +752,9 @@ def _create_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -789,22 +763,23 @@ def _create_initial( deserialized = None if response.status_code == 200: - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _create_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - @distributed_trace + @overload def begin_create( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.StorageAccount]: """Asynchronously creates a new storage account with the specified parameters. If an account is @@ -813,14 +788,17 @@ def begin_create( update request is issued with the exact same set of properties, the request will succeed. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the created account. + :param parameters: The parameters to provide for the created account. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCreateParameters + :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 @@ -832,20 +810,98 @@ def begin_create( :return: An instance of LROPoller that returns either StorageAccount or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._create_initial( # type: ignore resource_group_name=resource_group_name, @@ -853,79 +909,74 @@ def begin_create( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Deletes a storage account in Microsoft Azure. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - 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.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -933,10 +984,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 204]: @@ -946,15 +996,14 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace def get_properties( self, resource_group_name: str, account_name: str, - expand: Optional[Union[str, "_models.StorageAccountExpand"]] = None, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, **kwargs: Any ) -> _models.StorageAccount: """Returns the properties for the specified storage account including but not limited to name, SKU @@ -962,40 +1011,43 @@ def get_properties( keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: May be used to expand the properties within account's properties. By default, data is not included when fetching properties. Currently we only support geoReplicationStats - and blobRestoreStatus. Default value is None. + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. :type expand: str or ~azure.mgmt.storage.v2022_05_01.models.StorageAccountExpand :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - request = build_get_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.get_properties.metadata['url'], + api_version=api_version, + template_url=self.get_properties.metadata["url"], headers=_headers, params=_params, ) @@ -1003,32 +1055,32 @@ def get_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccount: """The update operation can be used to update the SKU, encryption, access tier, or tags for a @@ -1041,32 +1093,117 @@ def update( changed after creation. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for the updated account. + :param parameters: The parameters to provide for the updated account. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountUpdateParameters + :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: StorageAccount, or the result of cls(response) + :return: StorageAccount or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccount] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] - _json = self._serialize.body(parameters, 'StorageAccountUpdateParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") request = build_update_request( resource_group_name=resource_group_name, @@ -1075,7 +1212,8 @@ def update( api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -1083,58 +1221,55 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccount', pipeline_response) + deserialized = self._deserialize("StorageAccount", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore @distributed_trace - def list( - self, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the subscription. Note that storage keys are not returned; use the ListKeys operation for this. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_request( subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -1142,13 +1277,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1165,10 +1304,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1178,49 +1315,45 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace - def list_by_resource_group( - self, - resource_group_name: str, - **kwargs: Any - ) -> Iterable[_models.StorageAccountListResult]: + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: """Lists all the storage accounts available under the given resource group. Note that storage keys are not returned; use the ListKeys operation for this. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. 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 StorageAccountListResult or the result of - cls(response) - :rtype: - ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccountListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + 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'], + template_url=self.list_by_resource_group.metadata["url"], headers=_headers, params=_params, ) @@ -1228,14 +1361,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - 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=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -1252,10 +1388,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -1265,57 +1399,53 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_resource_group.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore @distributed_trace def list_keys( - self, - resource_group_name: str, - account_name: str, - expand: Optional[str] = "kerb", - **kwargs: Any + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are - "kerb" or None. Default value is "kerb". + "kerb" and None. Default value is "kerb". :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - request = build_list_keys_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, expand=expand, - template_url=self.list_keys.metadata['url'], + api_version=api_version, + template_url=self.list_keys.metadata["url"], headers=_headers, params=_params, ) @@ -1323,65 +1453,138 @@ def list_keys( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore - @distributed_trace + @overload def regenerate_key( self, resource_group_name: str, account_name: str, regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.StorageAccountListKeysResult: """Regenerates one of the access keys or Kerberos keys for the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, - kerb1, kerb2. + kerb1, kerb2. Required. :type regenerate_key: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2022_05_01.models.StorageAccountRegenerateKeyParameters 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 - :return: StorageAccountListKeysResult, or the result of cls(response) + :return: StorageAccountListKeysResult or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.StorageAccountListKeysResult - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.StorageAccountListKeysResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] - _json = self._serialize.body(regenerate_key, 'StorageAccountRegenerateKeyParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") request = build_regenerate_key_request( resource_group_name=resource_group_name, @@ -1390,7 +1593,8 @@ def regenerate_key( api_version=api_version, content_type=content_type, json=_json, - template_url=self.regenerate_key.metadata['url'], + content=_content, + template_url=self.regenerate_key.metadata["url"], headers=_headers, params=_params, ) @@ -1398,63 +1602,136 @@ def regenerate_key( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('StorageAccountListKeysResult', pipeline_response) + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - regenerate_key.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore - - @distributed_trace + @overload def list_account_sas( self, resource_group_name: str, account_name: str, parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListAccountSasResponse: """List SAS credentials of a storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.AccountSasParameters 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 - :return: ListAccountSasResponse, or the result of cls(response) + :return: ListAccountSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListAccountSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListAccountSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] - _json = self._serialize.body(parameters, 'AccountSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") request = build_list_account_sas_request( resource_group_name=resource_group_name, @@ -1463,7 +1740,8 @@ def list_account_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_account_sas.metadata['url'], + content=_content, + template_url=self.list_account_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1471,63 +1749,134 @@ def list_account_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListAccountSasResponse', pipeline_response) + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_account_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore - - @distributed_trace + @overload def list_service_sas( self, resource_group_name: str, account_name: str, parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.ListServiceSasResponse: """List service SAS credentials of a specific resource. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide to list service SAS credentials. + :param parameters: The parameters to provide to list service SAS credentials. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.ServiceSasParameters 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 - :return: ListServiceSasResponse, or the result of cls(response) + :return: ListServiceSasResponse or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListServiceSasResponse - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListServiceSasResponse] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] - _json = self._serialize.body(parameters, 'ServiceSasParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") request = build_list_service_sas_request( resource_group_name=resource_group_name, @@ -1536,7 +1885,8 @@ def list_service_sas( api_version=api_version, content_type=content_type, json=_json, - template_url=self.list_service_sas.metadata['url'], + content=_content, + template_url=self.list_service_sas.metadata["url"], headers=_headers, params=_params, ) @@ -1544,50 +1894,47 @@ def list_service_sas( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListServiceSasResponse', pipeline_response) + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list_service_sas.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore - + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore def _failover_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_failover_request_initial( + request = build_failover_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._failover_initial.metadata['url'], + template_url=self._failover_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1595,10 +1942,9 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1608,26 +1954,20 @@ def _failover_initial( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - _failover_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore - + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore @distributed_trace - def begin_failover( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> LROPoller[None]: + def begin_failover(self, resource_group_name: str, account_name: str, **kwargs: Any) -> LROPoller[None]: """Failover request can be triggered for a storage account in case of availability issues. The failover occurs from the storage account's primary cluster to secondary cluster for RA-GRS accounts. The secondary cluster will become primary after failover. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1639,82 +1979,75 @@ def begin_failover( # pylint: disable=inconsistent-return-statements 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._failover_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_failover.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_hierarchical_namespace_migration_request_initial( + request = build_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, - api_version=api_version, request_type=request_type, - template_url=self._hierarchical_namespace_migration_initial.metadata['url'], + api_version=api_version, + template_url=self._hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1722,43 +2055,38 @@ def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-r request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore - + _hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore @distributed_trace - def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - request_type: str, - **kwargs: Any + def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any ) -> LROPoller[None]: """Live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param request_type: Required. Hierarchical namespace migration type can either be a hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the - hydration request will migrate the account. + hydration request will migrate the account. Required. :type request_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. @@ -1770,81 +2098,75 @@ def begin_hierarchical_namespace_migration( # pylint: disable=inconsistent-retu 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, request_type=request_type, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + begin_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - - request = build_abort_hierarchical_namespace_migration_request_initial( + request = build_abort_hierarchical_namespace_migration_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self._abort_hierarchical_namespace_migration_initial.metadata['url'], + template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1852,37 +2174,33 @@ def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsis request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) - _abort_hierarchical_namespace_migration_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore - + _abort_hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore @distributed_trace - def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + def begin_abort_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> LROPoller[None]: """Abort live Migration of storage account to enable Hns. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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. @@ -1894,85 +2212,90 @@ def begin_abort_hierarchical_namespace_migration( # pylint: disable=inconsisten 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 + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._abort_hierarchical_namespace_migration_initial( # type: ignore resource_group_name=resource_group_name, account_name=account_name, api_version=api_version, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) - def get_long_running_output(pipeline_response): + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_abort_hierarchical_namespace_migration.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + begin_abort_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore def _restore_blob_ranges_initial( self, resource_group_name: str, account_name: str, - parameters: _models.BlobRestoreParameters, + parameters: Union[_models.BlobRestoreParameters, IO], **kwargs: Any ) -> _models.BlobRestoreStatus: error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] - _json = self._serialize.body(parameters, 'BlobRestoreParameters') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") - request = build_restore_blob_ranges_request_initial( + request = build_restore_blob_ranges_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self._restore_blob_ranges_initial.metadata['url'], + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], headers=_headers, params=_params, ) @@ -1980,10 +2303,9 @@ def _restore_blob_ranges_initial( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200, 202]: @@ -1991,38 +2313,117 @@ def _restore_blob_ranges_initial( raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if response.status_code == 202: - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - _restore_blob_ranges_initial.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore - - @distributed_trace + @overload def begin_restore_blob_ranges( self, resource_group_name: str, account_name: str, parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.BlobRestoreStatus]: """Restore blobs in the specified blob ranges. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str - :param parameters: The parameters to provide for restore blob ranges. + :param parameters: The parameters to provide for restore blob ranges. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.BlobRestoreParameters 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 @@ -2034,20 +2435,17 @@ def begin_restore_blob_ranges( :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_05_01.models.BlobRestoreStatus] - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.BlobRestoreStatus] - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] - lro_delay = kwargs.pop( - 'polling_interval', - self._config.polling_interval - ) - cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] if cont_token is None: raw_result = self._restore_blob_ranges_initial( # type: ignore resource_group_name=resource_group_name, @@ -2055,79 +2453,76 @@ def begin_restore_blob_ranges( parameters=parameters, api_version=api_version, content_type=content_type, - cls=lambda x,y,z: x, + cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) - kwargs.pop('error_map', None) + kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): - deserialized = self._deserialize('BlobRestoreStatus', pipeline_response) + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - if polling is True: - polling_method = cast(PollingMethod, ARMPolling( - lro_delay, - lro_options={'final-state-via': 'location'}, - - **kwargs - )) # type: PollingMethod - elif polling is False: polling_method = cast(PollingMethod, NoPolling()) - else: polling_method = polling + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling if cont_token: return LROPoller.from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, - deserialization_callback=get_long_running_output + deserialization_callback=get_long_running_output, ) return LROPoller(self._client, raw_result, get_long_running_output, polling_method) - begin_restore_blob_ranges.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore @distributed_trace def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> None: """Revoke user delegation keys. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata['url'], + template_url=self.revoke_user_delegation_keys.metadata["url"], headers=_headers, params=_params, ) @@ -2135,10 +2530,9 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: @@ -2148,5 +2542,4 @@ def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statemen if cls: return cls(pipeline_response, None, {}) - revoke_user_delegation_keys.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore - + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_operations.py index 95bed59d76b6..67d4267043a6 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_operations.py @@ -6,11 +6,18 @@ # 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 - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,220 +27,200 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False + def build_create_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - *, - json: Optional[_models.Table] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_update_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - *, - json: Optional[_models.Table] = None, - content: Any = None, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PATCH", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) def build_get_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_delete_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - table_name: str, - **kwargs: Any + resource_group_name: str, account_name: str, table_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableName": _SERIALIZER.url("table_name", table_name, 'str', max_length=63, min_length=3, pattern=r'^[A-Za-z][A-Za-z0-9]{2,62}$'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') - - return HttpRequest( - method="DELETE", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) - - -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableOperations: """ @@ -254,62 +241,145 @@ def __init__(self, *args, **kwargs): 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 + @overload def create( self, resource_group_name: str, account_name: str, table_name: str, parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table 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 - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - if parameters is not None: - _json = self._serialize.body(parameters, 'Table') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None request = build_create_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.create.metadata['url'], + content=_content, + template_url=self.create.metadata["url"], headers=_headers, params=_params, ) @@ -317,81 +387,163 @@ def create( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - create.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - - @distributed_trace + @overload def update( self, resource_group_name: str, account_name: str, table_name: str, parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.Table: """Creates a new table with the specified table name, under the specified account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :param parameters: The parameters to provide to create a table. Default value is None. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.Table 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 - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - if parameters is not None: - _json = self._serialize.body(parameters, 'Table') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters else: - _json = None + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None request = build_update_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, content_type=content_type, json=_json, - template_url=self.update.metadata['url'], + content=_content, + template_url=self.update.metadata["url"], headers=_headers, params=_params, ) @@ -399,71 +551,65 @@ def update( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def get( - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any - ) -> _models.Table: + def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: """Gets the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: Table, or the result of cls(response) + :return: Table or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.Table - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.Table] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] - request = build_get_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.get.metadata['url'], + template_url=self.get.metadata["url"], headers=_headers, params=_params, ) @@ -471,71 +617,67 @@ def get( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('Table', pipeline_response) + deserialized = self._deserialize("Table", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace def delete( # pylint: disable=inconsistent-return-statements - self, - resource_group_name: str, - account_name: str, - table_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any ) -> None: """Deletes the table with the specified table name, under the specified account if it exists. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param table_name: A table name must be unique within a storage account and must be between 3 and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin - with a numeric character. + with a numeric character. Required. :type table_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) + :return: None or the result of cls(response) :rtype: None - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[None] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] - request = build_delete_request( resource_group_name=resource_group_name, account_name=account_name, - subscription_id=self._config.subscription_id, table_name=table_name, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.delete.metadata['url'], + template_url=self.delete.metadata["url"], headers=_headers, params=_params, ) @@ -543,10 +685,9 @@ def delete( # pylint: disable=inconsistent-return-statements request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [204]: @@ -556,49 +697,47 @@ def delete( # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) - delete.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore - + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> Iterable[_models.ListTableResource]: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: """Gets a list of all the tables under the specified storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. 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 ListTableResource or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.ListTableResource] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Table or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableResource] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -606,15 +745,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_request( - resource_group_name=resource_group_name, - account_name=account_name, - subscription_id=self._config.subscription_id, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -631,10 +772,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -644,8 +783,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_operations.py index 73092bc90db8..82cf6cfa5853 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_table_services_operations.py @@ -6,11 +6,17 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import sys +from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse from azure.core.rest import HttpRequest @@ -19,134 +25,123 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) def build_set_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - *, - json: Optional[_models.TableServiceProperties] = None, - content: Any = None, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers if content_type is not None: - _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest( - method="PUT", - url=_url, - params=_params, - headers=_headers, - json=json, - content=content, - **kwargs - ) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) def build_get_service_properties_request( - resource_group_name: str, - account_name: str, - subscription_id: str, - **kwargs: Any + 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long path_format_arguments = { - "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), - "accountName": _SERIALIZER.url("account_name", account_name, 'str', max_length=24, min_length=3), - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, 'str'), + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class TableServicesOperations: """ @@ -167,46 +162,42 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any - ) -> _models.ListTableServices: + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: """List all table services for the storage account. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: ListTableServices, or the result of cls(response) + :return: ListTableServices or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.ListTableServices - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.ListTableServices] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] - request = build_list_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.metadata['url'], + template_url=self.list.metadata["url"], headers=_headers, params=_params, ) @@ -214,70 +205,153 @@ def list( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('ListTableServices', pipeline_response) + deserialized = self._deserialize("ListTableServices", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore - - @distributed_trace + @overload def set_service_properties( self, resource_group_name: str, account_name: str, parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", **kwargs: Any ) -> _models.TableServiceProperties: """Sets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :param parameters: The properties of a storage account’s Table service, only properties for - Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. :type parameters: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties or IO + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: 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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - _json = self._serialize.body(parameters, 'TableServiceProperties') + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") request = build_set_service_properties_request( resource_group_name=resource_group_name, @@ -287,7 +361,8 @@ def set_service_properties( table_service_name=table_service_name, content_type=content_type, json=_json, - template_url=self.set_service_properties.metadata['url'], + content=_content, + template_url=self.set_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -295,72 +370,69 @@ def set_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - set_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore @distributed_trace def get_service_properties( - self, - resource_group_name: str, - account_name: str, - **kwargs: Any + self, resource_group_name: str, account_name: str, **kwargs: Any ) -> _models.TableServiceProperties: """Gets the properties of a storage account’s Table service, including properties for Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. :param resource_group_name: The name of the resource group within the user's subscription. The - name is case insensitive. + name is case insensitive. Required. :type resource_group_name: str :param account_name: The name of the storage account within the specified resource group. Storage account names must be between 3 and 24 characters in length and use numbers and - lower-case letters only. + lower-case letters only. Required. :type account_name: str :keyword table_service_name: The name of the Table Service within the specified storage account. Table Service Name must be 'default'. Default value is "default". Note that overriding this default value may result in unsupported behavior. :paramtype table_service_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: TableServiceProperties, or the result of cls(response) + :return: TableServiceProperties or the result of cls(response) :rtype: ~azure.mgmt.storage.v2022_05_01.models.TableServiceProperties - :raises: ~azure.core.exceptions.HttpResponseError + :raises ~azure.core.exceptions.HttpResponseError: """ error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - table_service_name = kwargs.pop('table_service_name', "default") # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.TableServiceProperties] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] - request = build_get_service_properties_request( resource_group_name=resource_group_name, account_name=account_name, subscription_id=self._config.subscription_id, api_version=api_version, table_service_name=table_service_name, - template_url=self.get_service_properties.metadata['url'], + template_url=self.get_service_properties.metadata["url"], headers=_headers, params=_params, ) @@ -368,22 +440,20 @@ def get_service_properties( request.url = self._client.format_url(request.url) # type: ignore pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access - request, - stream=False, - **kwargs + request, stream=False, **kwargs ) + response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response, error_format=ARMErrorFormat) - deserialized = self._deserialize('TableServiceProperties', pipeline_response) + deserialized = self._deserialize("TableServiceProperties", pipeline_response) if cls: return cls(pipeline_response, deserialized, {}) return deserialized - get_service_properties.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore - + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_operations.py index e33a12d40885..26a603a1494c 100644 --- a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_operations.py +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_05_01/operations/_usages_operations.py @@ -6,11 +6,18 @@ # 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, Optional, TypeVar - -from msrest import Serializer - -from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse from azure.core.pipeline.transport import HttpResponse @@ -20,46 +27,46 @@ from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from ..._serialization import Serializer from .._vendor import _convert_request, _format_url_section -T = TypeVar('T') + +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 +T = TypeVar("T") ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] _SERIALIZER = Serializer() _SERIALIZER.client_side_validation = False -def build_list_by_location_request( - subscription_id: str, - location: str, - **kwargs: Any -) -> HttpRequest: + +def build_list_by_location_request(location: 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 = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - accept = _headers.pop('Accept', "application/json") + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + accept = _headers.pop("Accept", "application/json") # Construct URL - _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages") # pylint: disable=line-too-long + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long path_format_arguments = { - "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), - "location": _SERIALIZER.url("location", location, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), } _url = _format_url_section(_url, **path_format_arguments) # Construct parameters - _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) - return HttpRequest( - method="GET", - url=_url, - params=_params, - headers=_headers, - **kwargs - ) class UsagesOperations: """ @@ -80,41 +87,40 @@ def __init__(self, *args, **kwargs): self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def list_by_location( - self, - location: str, - **kwargs: Any - ) -> Iterable[_models.UsageListResult]: + def list_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: """Gets the current usage count and the limit for the resources of the location under the subscription. - :param location: The location of the Azure Storage resource. + :param location: The location of the Azure Storage resource. Required. :type location: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either UsageListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.UsageListResult] - :raises: ~azure.core.exceptions.HttpResponseError + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_05_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-05-01")) # type: str - cls = kwargs.pop('cls', None) # type: ClsType[_models.UsageListResult] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-05-01")) # type: Literal["2022-05-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] error_map = { - 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, } - error_map.update(kwargs.pop('error_map', {}) or {}) + error_map.update(kwargs.pop("error_map", {}) or {}) + def prepare_request(next_link=None): if not next_link: - + request = build_list_by_location_request( - subscription_id=self._config.subscription_id, location=location, + subscription_id=self._config.subscription_id, api_version=api_version, - template_url=self.list_by_location.metadata['url'], + template_url=self.list_by_location.metadata["url"], headers=_headers, params=_params, ) @@ -122,14 +128,17 @@ def prepare_request(next_link=None): request.url = self._client.format_url(request.url) # type: ignore else: - - request = build_list_by_location_request( - subscription_id=self._config.subscription_id, - location=location, - api_version=api_version, - template_url=next_link, - headers=_headers, - params=_params, + # 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) # type: ignore @@ -146,10 +155,8 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access - request, - stream=False, - **kwargs + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs ) response = pipeline_response.http_response @@ -159,8 +166,6 @@ def get_next(next_link=None): return pipeline_response + return ItemPaged(get_next, extract_data) - return ItemPaged( - get_next, extract_data - ) - list_by_location.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/__init__.py new file mode 100644 index 000000000000..2ded28c1cc6a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/__init__.py @@ -0,0 +1,26 @@ +# 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 ._storage_management_client import StorageManagementClient +from ._version import VERSION + +__version__ = VERSION + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StorageManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_configuration.py new file mode 100644 index 000000000000..1e0856dfb134 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_configuration.py @@ -0,0 +1,75 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +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 + from azure.core.credentials import TokenCredential + + +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for StorageManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-09-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(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-09-01") # type: Literal["2022-09-01"] + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_metadata.json b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_metadata.json new file mode 100644 index 000000000000..1bf1fcca3c54 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_metadata.json @@ -0,0 +1,121 @@ +{ + "chosen_version": "2022-09-01", + "total_api_version_list": ["2022-09-01"], + "client": { + "name": "StorageManagementClient", + "filename": "_storage_management_client", + "description": "The Azure Storage Management API.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"ARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \".._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}, \"regular\": {\"azurecore\": {\"azure.mgmt.core\": [\"AsyncARMPipelineClient\"], \"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"]}, \"local\": {\"._configuration\": [\"StorageManagementClientConfiguration\"], \"..._serialization\": [\"Deserializer\", \"Serializer\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential: \"TokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure. Required.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription. Required.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "operations": "Operations", + "skus": "SkusOperations", + "storage_accounts": "StorageAccountsOperations", + "deleted_accounts": "DeletedAccountsOperations", + "usages": "UsagesOperations", + "management_policies": "ManagementPoliciesOperations", + "blob_inventory_policies": "BlobInventoryPoliciesOperations", + "private_endpoint_connections": "PrivateEndpointConnectionsOperations", + "private_link_resources": "PrivateLinkResourcesOperations", + "object_replication_policies": "ObjectReplicationPoliciesOperations", + "local_users": "LocalUsersOperations", + "encryption_scopes": "EncryptionScopesOperations", + "blob_services": "BlobServicesOperations", + "blob_containers": "BlobContainersOperations", + "file_services": "FileServicesOperations", + "file_shares": "FileSharesOperations", + "queue_services": "QueueServicesOperations", + "queue": "QueueOperations", + "table_services": "TableServicesOperations", + "table": "TableOperations" + } +} diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_storage_management_client.py new file mode 100644 index 000000000000..803388972df9 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_storage_management_client.py @@ -0,0 +1,194 @@ +# 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 copy import deepcopy +from typing import Any, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient + +from . import models +from .._serialization import Deserializer, Serializer +from ._configuration import StorageManagementClientConfiguration +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + LocalUsersOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The Azure Storage Management API. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.storage.v2022_09_01.operations.Operations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.storage.v2022_09_01.operations.SkusOperations + :ivar storage_accounts: StorageAccountsOperations operations + :vartype storage_accounts: azure.mgmt.storage.v2022_09_01.operations.StorageAccountsOperations + :ivar deleted_accounts: DeletedAccountsOperations operations + :vartype deleted_accounts: azure.mgmt.storage.v2022_09_01.operations.DeletedAccountsOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.storage.v2022_09_01.operations.UsagesOperations + :ivar management_policies: ManagementPoliciesOperations operations + :vartype management_policies: + azure.mgmt.storage.v2022_09_01.operations.ManagementPoliciesOperations + :ivar blob_inventory_policies: BlobInventoryPoliciesOperations operations + :vartype blob_inventory_policies: + azure.mgmt.storage.v2022_09_01.operations.BlobInventoryPoliciesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.storage.v2022_09_01.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.storage.v2022_09_01.operations.PrivateLinkResourcesOperations + :ivar object_replication_policies: ObjectReplicationPoliciesOperations operations + :vartype object_replication_policies: + azure.mgmt.storage.v2022_09_01.operations.ObjectReplicationPoliciesOperations + :ivar local_users: LocalUsersOperations operations + :vartype local_users: azure.mgmt.storage.v2022_09_01.operations.LocalUsersOperations + :ivar encryption_scopes: EncryptionScopesOperations operations + :vartype encryption_scopes: + azure.mgmt.storage.v2022_09_01.operations.EncryptionScopesOperations + :ivar blob_services: BlobServicesOperations operations + :vartype blob_services: azure.mgmt.storage.v2022_09_01.operations.BlobServicesOperations + :ivar blob_containers: BlobContainersOperations operations + :vartype blob_containers: azure.mgmt.storage.v2022_09_01.operations.BlobContainersOperations + :ivar file_services: FileServicesOperations operations + :vartype file_services: azure.mgmt.storage.v2022_09_01.operations.FileServicesOperations + :ivar file_shares: FileSharesOperations operations + :vartype file_shares: azure.mgmt.storage.v2022_09_01.operations.FileSharesOperations + :ivar queue_services: QueueServicesOperations operations + :vartype queue_services: azure.mgmt.storage.v2022_09_01.operations.QueueServicesOperations + :ivar queue: QueueOperations operations + :vartype queue: azure.mgmt.storage.v2022_09_01.operations.QueueOperations + :ivar table_services: TableServicesOperations operations + :vartype table_services: azure.mgmt.storage.v2022_09_01.operations.TableServicesOperations + :ivar table: TableOperations operations + :vartype table: azure.mgmt.storage.v2022_09_01.operations.TableOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> StorageManagementClient + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_vendor.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_vendor.py new file mode 100644 index 000000000000..9aad73fc743e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from 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 + + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [c for c in formatted_components if "{}".format(key.args[0]) not in c] + template = "/".join(components) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_version.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_version.py new file mode 100644 index 000000000000..bb46423cd61e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/_version.py @@ -0,0 +1,9 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +VERSION = "21.0.0" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/__init__.py new file mode 100644 index 000000000000..1bb98744d937 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/__init__.py @@ -0,0 +1,23 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._storage_management_client import StorageManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "StorageManagementClient", +] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_configuration.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_configuration.py new file mode 100644 index 000000000000..e1fd4b6e6086 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_configuration.py @@ -0,0 +1,72 @@ +# 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, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +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 + from azure.core.credentials_async import AsyncTokenCredential + + +class StorageManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes + """Configuration for StorageManagementClient. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :keyword api_version: Api Version. Default value is "2022-09-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(StorageManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop("api_version", "2022-09-01") # type: Literal["2022-09-01"] + + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = api_version + self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"]) + kwargs.setdefault("sdk_moniker", "mgmt-storage/{}".format(VERSION)) + self._configure(**kwargs) + + def _configure(self, **kwargs: Any) -> None: + self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get("http_logging_policy") or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get("retry_policy") or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get("redirect_policy") or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get("authentication_policy") + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy( + self.credential, *self.credential_scopes, **kwargs + ) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_storage_management_client.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_storage_management_client.py new file mode 100644 index 000000000000..88d504284e5d --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/_storage_management_client.py @@ -0,0 +1,194 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient + +from .. import models +from ..._serialization import Deserializer, Serializer +from ._configuration import StorageManagementClientConfiguration +from .operations import ( + BlobContainersOperations, + BlobInventoryPoliciesOperations, + BlobServicesOperations, + DeletedAccountsOperations, + EncryptionScopesOperations, + FileServicesOperations, + FileSharesOperations, + LocalUsersOperations, + ManagementPoliciesOperations, + ObjectReplicationPoliciesOperations, + Operations, + PrivateEndpointConnectionsOperations, + PrivateLinkResourcesOperations, + QueueOperations, + QueueServicesOperations, + SkusOperations, + StorageAccountsOperations, + TableOperations, + TableServicesOperations, + UsagesOperations, +) + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class StorageManagementClient: # pylint: disable=client-accepts-api-version-keyword,too-many-instance-attributes + """The Azure Storage Management API. + + :ivar operations: Operations operations + :vartype operations: azure.mgmt.storage.v2022_09_01.aio.operations.Operations + :ivar skus: SkusOperations operations + :vartype skus: azure.mgmt.storage.v2022_09_01.aio.operations.SkusOperations + :ivar storage_accounts: StorageAccountsOperations operations + :vartype storage_accounts: + azure.mgmt.storage.v2022_09_01.aio.operations.StorageAccountsOperations + :ivar deleted_accounts: DeletedAccountsOperations operations + :vartype deleted_accounts: + azure.mgmt.storage.v2022_09_01.aio.operations.DeletedAccountsOperations + :ivar usages: UsagesOperations operations + :vartype usages: azure.mgmt.storage.v2022_09_01.aio.operations.UsagesOperations + :ivar management_policies: ManagementPoliciesOperations operations + :vartype management_policies: + azure.mgmt.storage.v2022_09_01.aio.operations.ManagementPoliciesOperations + :ivar blob_inventory_policies: BlobInventoryPoliciesOperations operations + :vartype blob_inventory_policies: + azure.mgmt.storage.v2022_09_01.aio.operations.BlobInventoryPoliciesOperations + :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations + :vartype private_endpoint_connections: + azure.mgmt.storage.v2022_09_01.aio.operations.PrivateEndpointConnectionsOperations + :ivar private_link_resources: PrivateLinkResourcesOperations operations + :vartype private_link_resources: + azure.mgmt.storage.v2022_09_01.aio.operations.PrivateLinkResourcesOperations + :ivar object_replication_policies: ObjectReplicationPoliciesOperations operations + :vartype object_replication_policies: + azure.mgmt.storage.v2022_09_01.aio.operations.ObjectReplicationPoliciesOperations + :ivar local_users: LocalUsersOperations operations + :vartype local_users: azure.mgmt.storage.v2022_09_01.aio.operations.LocalUsersOperations + :ivar encryption_scopes: EncryptionScopesOperations operations + :vartype encryption_scopes: + azure.mgmt.storage.v2022_09_01.aio.operations.EncryptionScopesOperations + :ivar blob_services: BlobServicesOperations operations + :vartype blob_services: azure.mgmt.storage.v2022_09_01.aio.operations.BlobServicesOperations + :ivar blob_containers: BlobContainersOperations operations + :vartype blob_containers: + azure.mgmt.storage.v2022_09_01.aio.operations.BlobContainersOperations + :ivar file_services: FileServicesOperations operations + :vartype file_services: azure.mgmt.storage.v2022_09_01.aio.operations.FileServicesOperations + :ivar file_shares: FileSharesOperations operations + :vartype file_shares: azure.mgmt.storage.v2022_09_01.aio.operations.FileSharesOperations + :ivar queue_services: QueueServicesOperations operations + :vartype queue_services: azure.mgmt.storage.v2022_09_01.aio.operations.QueueServicesOperations + :ivar queue: QueueOperations operations + :vartype queue: azure.mgmt.storage.v2022_09_01.aio.operations.QueueOperations + :ivar table_services: TableServicesOperations operations + :vartype table_services: azure.mgmt.storage.v2022_09_01.aio.operations.TableServicesOperations + :ivar table: TableOperations operations + :vartype table: azure.mgmt.storage.v2022_09_01.aio.operations.TableOperations + :param credential: Credential needed for the client to connect to Azure. Required. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. Required. + :type subscription_id: str + :param base_url: Service URL. Default value is "https://management.azure.com". + :type base_url: str + :keyword api_version: Api Version. Default value is "2022-09-01". Note that overriding this + default value may result in unsupported behavior. + :paramtype api_version: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = StorageManagementClientConfiguration( + credential=credential, subscription_id=subscription_id, **kwargs + ) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.skus = SkusOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage_accounts = StorageAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.deleted_accounts = DeletedAccountsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.usages = UsagesOperations(self._client, self._config, self._serialize, self._deserialize) + self.management_policies = ManagementPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_inventory_policies = BlobInventoryPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_endpoint_connections = PrivateEndpointConnectionsOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.object_replication_policies = ObjectReplicationPoliciesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.local_users = LocalUsersOperations(self._client, self._config, self._serialize, self._deserialize) + self.encryption_scopes = EncryptionScopesOperations( + self._client, self._config, self._serialize, self._deserialize + ) + self.blob_services = BlobServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.blob_containers = BlobContainersOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_services = FileServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.file_shares = FileSharesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue_services = QueueServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.queue = QueueOperations(self._client, self._config, self._serialize, self._deserialize) + self.table_services = TableServicesOperations(self._client, self._config, self._serialize, self._deserialize) + self.table = TableOperations(self._client, self._config, self._serialize, self._deserialize) + + def _send_request(self, request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "StorageManagementClient": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/__init__.py new file mode 100644 index 000000000000..b58975e023a9 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/__init__.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. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._skus_operations import SkusOperations +from ._storage_accounts_operations import StorageAccountsOperations +from ._deleted_accounts_operations import DeletedAccountsOperations +from ._usages_operations import UsagesOperations +from ._management_policies_operations import ManagementPoliciesOperations +from ._blob_inventory_policies_operations import BlobInventoryPoliciesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._object_replication_policies_operations import ObjectReplicationPoliciesOperations +from ._local_users_operations import LocalUsersOperations +from ._encryption_scopes_operations import EncryptionScopesOperations +from ._blob_services_operations import BlobServicesOperations +from ._blob_containers_operations import BlobContainersOperations +from ._file_services_operations import FileServicesOperations +from ._file_shares_operations import FileSharesOperations +from ._queue_services_operations import QueueServicesOperations +from ._queue_operations import QueueOperations +from ._table_services_operations import TableServicesOperations +from ._table_operations import TableOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "LocalUsersOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_containers_operations.py new file mode 100644 index 000000000000..9f30e49c81ac --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_containers_operations.py @@ -0,0 +1,1942 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._blob_containers_operations import ( + build_clear_legal_hold_request, + build_create_or_update_immutability_policy_request, + build_create_request, + build_delete_immutability_policy_request, + build_delete_request, + build_extend_immutability_policy_request, + build_get_immutability_policy_request, + build_get_request, + build_lease_request, + build_list_request, + build_lock_immutability_policy_request, + build_object_level_worm_request, + build_set_legal_hold_request, + build_update_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`blob_containers` 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( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ListContainerItem"]: + """Lists all containers and does not support a prefix like data plane. Also SRP today does not + return continuation token. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of containers that can be included in + the list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only container names starting with the filter will be + listed. Default value is None. + :type filter: str + :param include: Optional, used to include the properties for soft deleted blob containers. + "deleted" Default value is None. + :type include: str or ~azure.mgmt.storage.v2022_09_01.models.ListContainersInclude + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] + + 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_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + include=include, + 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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ListContainerItems", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> _models.BlobContainer: + """Gets properties of a specified container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> None: + """Deletes specified container under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + request = build_set_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.set_legal_hold.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LegalHold", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + request = build_clear_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.clear_legal_hold.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LegalHold", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy or IO + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: 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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None + + request = build_create_or_update_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + @distributed_trace_async + async def get_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Gets the existing immutability policy along with the corresponding ETag in response headers and + body. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 {}) + + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + request = build_get_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + @distributed_trace_async + async def delete_immutability_policy( + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Aborts an unlocked immutability policy. The response of delete has + immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this + operation. Deleting a locked immutability policy is not allowed, the only way is to delete the + container after deleting all expired blobs inside the policy locked container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 {}) + + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + request = build_delete_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + @distributed_trace_async + async def lock_immutability_policy( + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is + ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + request = build_lock_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None + + request = build_extend_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None + + request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.lease.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore + + async def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> None: + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_object_level_worm_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._object_level_worm_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + + @distributed_trace_async + async def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """This operation migrates a blob container from container level WORM to object level immutability + enabled container. Prerequisites require a container level immutability policy either in locked + or unlocked state, Account level versioning must be enabled and there should be no Legal hold + on the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._object_level_worm_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + 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) + + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_inventory_policies_operations.py new file mode 100644 index 000000000000..d1b541eee718 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_inventory_policies_operations.py @@ -0,0 +1,457 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._blob_inventory_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`blob_inventory_policies` 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_async + async def get( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy 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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + **kwargs: Any + ) -> None: + """Deletes the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName + :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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobInventoryPolicy"]: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 BlobInventoryPolicy or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_services_operations.py new file mode 100644 index 000000000000..f2f8d1c3a165 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_blob_services_operations.py @@ -0,0 +1,390 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._blob_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`blob_services` 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( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.BlobServiceProperties"]: + """List blob services of storage account. It returns a collection of one object named default. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("BlobServiceItems", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties or IO + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: 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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self.set_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore + + @distributed_trace_async + async def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.BlobServiceProperties: + """Gets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + template_url=self.get_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_deleted_accounts_operations.py new file mode 100644 index 000000000000..a072074db5e7 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_deleted_accounts_operations.py @@ -0,0 +1,199 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._deleted_accounts_operations import build_get_request, build_list_request + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`deleted_accounts` 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(self, **kwargs: Any) -> AsyncIterable["_models.DeletedAccount"]: + """Lists deleted accounts under the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeletedAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + + @distributed_trace_async + async def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: + """Get properties of specified deleted account resource. + + :param deleted_account_name: Name of the deleted storage account. Required. + :type deleted_account_name: str + :param location: The location of the deleted storage account. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeletedAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.DeletedAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] + + request = build_get_request( + deleted_account_name=deleted_account_name, + location=location, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeletedAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_encryption_scopes_operations.py new file mode 100644 index 000000000000..c12567d7e006 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_encryption_scopes_operations.py @@ -0,0 +1,588 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._encryption_scopes_operations import ( + build_get_request, + build_list_request, + build_patch_request, + build_put_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`encryption_scopes` 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") + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") + + request = build_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") + + request = build_patch_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.patch.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any + ) -> _models.EncryptionScope: + """Returns the properties for the specified encryption scope. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[int] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListEncryptionScopesInclude]] = None, + **kwargs: Any + ) -> AsyncIterable["_models.EncryptionScope"]: + """Lists all the encryption scopes available under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, specifies the maximum number of encryption scopes that will be + included in the list response. Default value is None. + :type maxpagesize: int + :param filter: Optional. When specified, only encryption scope names starting with the filter + will be listed. Default value is None. + :type filter: str + :param include: Optional, when specified, will list encryption scopes with the specific state. + Defaults to All. Known values are: "All", "Enabled", and "Disabled". Default value is None. + :type include: str or ~azure.mgmt.storage.v2022_09_01.models.ListEncryptionScopesInclude + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] + + 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_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + include=include, + 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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_services_operations.py new file mode 100644 index 000000000000..68f78b6cdad8 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_services_operations.py @@ -0,0 +1,355 @@ +# pylint: disable=too-many-lines +# 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, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._file_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`file_services` 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_async + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: + """List all file services in storage accounts. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceItems or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceItems + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] + + request = build_list_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceItems", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties or IO + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: 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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self.set_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore + + @distributed_trace_async + async def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.FileServiceProperties: + """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + template_url=self.get_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_shares_operations.py new file mode 100644 index 000000000000..c61b717d418e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_file_shares_operations.py @@ -0,0 +1,1042 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._file_shares_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_lease_request, + build_list_request, + build_restore_request, + build_update_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`file_shares` 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( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.FileShareItem"]: + """Lists all shares. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of shares that can be included in the + list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only share names starting with the filter will be + listed. Default value is None. + :type filter: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] + + 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_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + expand=expand, + 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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("FileShareItems", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FileShare", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + account_name: str, + share_name: str, + expand: Optional[str] = None, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Gets properties of a specified share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: stats. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. + :type x_ms_snapshot: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + expand=expand, + x_ms_snapshot=x_ms_snapshot, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + include: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes specified share under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. + :type x_ms_snapshot: str + :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default + value is snapshots. For 'snapshots', the file share is deleted including all of its file share + snapshots. If the file share contains leased-snapshots, the deletion fails. For + 'leased-snapshots', the file share is deleted included all of its file share snapshots + (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. + :type include: 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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, + include=include, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: ~azure.mgmt.storage.v2022_09_01.models.DeletedShare + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2022_09_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") + + request = build_restore_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.restore.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None + + request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.lease.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_local_users_operations.py new file mode 100644 index 000000000000..e7711a8b6ad8 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_local_users_operations.py @@ -0,0 +1,581 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._local_users_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_keys_request, + build_list_request, + build_regenerate_password_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class LocalUsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`local_users` 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(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.LocalUser"]: + """List the local users associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 LocalUser or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.LocalUser] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUsers] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("LocalUsers", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: + """Get the local user of the storage account by username. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUser", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: _models.LocalUser, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.LocalUser + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: IO + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: Union[_models.LocalUser, IO], + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Is either a model type or + a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.LocalUser 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 + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalUser") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUser", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> None: + """Deletes the local user associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: 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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + @distributed_trace_async + async def list_keys( + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> _models.LocalUserKeys: + """List SSH authorized keys and shared key of the local user. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUserKeys or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUserKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserKeys] + + request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUserKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore + + @distributed_trace_async + async def regenerate_password( + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> _models.LocalUserRegeneratePasswordResult: + """Regenerate the local user SSH password. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUserRegeneratePasswordResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUserRegeneratePasswordResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] + + request = build_regenerate_password_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.regenerate_password.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_management_policies_operations.py new file mode 100644 index 000000000000..689b92d93bde --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_management_policies_operations.py @@ -0,0 +1,361 @@ +# pylint: disable=too-many-lines +# 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, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._management_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`management_policies` 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_async + async def get( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Gets the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ManagementPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ManagementPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + **kwargs: Any + ) -> None: + """Deletes the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName + :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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_object_replication_policies_operations.py new file mode 100644 index 000000000000..2b05ee780616 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_object_replication_policies_operations.py @@ -0,0 +1,460 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._object_replication_policies_operations import ( + build_create_or_update_request, + build_delete_request, + build_get_request, + build_list_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`object_replication_policies` 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( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.ObjectReplicationPolicy"]: + """List the object replication policies associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 ObjectReplicationPolicy or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Get the object replication policy of the storage account by policy ID. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy 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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any + ) -> None: + """Deletes the object replication policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: 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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_operations.py new file mode 100644 index 000000000000..fed6a643b8f1 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_operations.py @@ -0,0 +1,137 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`operations` 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(self, **kwargs: Any) -> AsyncIterable["_models.Operation"]: + """Lists all of the available Storage Rest API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..83c90a3ac585 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,447 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import ( + build_delete_request, + build_get_request, + build_list_request, + build_put_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`private_endpoint_connections` 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( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncIterable["_models.PrivateEndpointConnection"]: + """List all the private endpoint connections associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. 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.storage.v2022_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection 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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") + + request = build_put_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, + content_type=content_type, + json=_json, + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + """Deletes the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..5daedd5acde2 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_private_link_resources_operations.py @@ -0,0 +1,119 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_list_by_storage_account_request + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`private_link_resources` 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_async + async def list_by_storage_account( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources that need to be created for a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + + request = build_list_by_storage_account_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_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_operations.py new file mode 100644 index 000000000000..72729c69d516 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_operations.py @@ -0,0 +1,631 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._queue_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`queue` 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") + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + @distributed_trace_async + async def get( + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any + ) -> _models.StorageQueue: + """Gets the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any + ) -> None: + """Deletes the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterable["_models.ListQueue"]: + """Gets a list of all the queues under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, a maximum number of queues that should be included in a list + queue response. Default value is None. + :type maxpagesize: str + :param filter: Optional, When specified, only the queues with a name starting with the given + filter will be listed. 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 ListQueue or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] + + 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_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + 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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ListQueueResource", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_services_operations.py new file mode 100644 index 000000000000..b2c544107b51 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_queue_services_operations.py @@ -0,0 +1,356 @@ +# pylint: disable=too-many-lines +# 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, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._queue_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`queue_services` 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_async + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: + """List all queue services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListQueueServices or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListQueueServices + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] + + request = build_list_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListQueueServices", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties or IO + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: 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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self.set_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore + + @distributed_trace_async + async def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.QueueServiceProperties: + """Gets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + template_url=self.get_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_skus_operations.py new file mode 100644 index 000000000000..9efe729c5d0e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_skus_operations.py @@ -0,0 +1,138 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._skus_operations import build_list_request + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`skus` 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(self, **kwargs: Any) -> AsyncIterable["_models.SkuInformation"]: + """Lists the available SKUs supported by Microsoft.Storage for given subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageSkuListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_storage_accounts_operations.py new file mode 100644 index 000000000000..6db8c798252b --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_storage_accounts_operations.py @@ -0,0 +1,2058 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._storage_accounts_operations import ( + build_abort_hierarchical_namespace_migration_request, + build_check_name_availability_request, + build_create_request, + build_delete_request, + build_failover_request, + build_get_properties_request, + build_hierarchical_namespace_migration_request, + build_list_account_sas_request, + build_list_by_resource_group_request, + build_list_keys_request, + build_list_request, + build_list_service_sas_request, + build_regenerate_key_request, + build_restore_blob_ranges_request, + build_revoke_user_delegation_keys_request, + build_update_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`storage_accounts` 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") + + @overload + async def check_name_availability( + self, + account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2022_09_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2022_09_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") + + request = build_check_name_availability_request( + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore + + async def _create_initial( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCreateParameters 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. + :return: An instance of AsyncLROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("StorageAccount", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(AsyncPollingMethod, AsyncARMPolling(lro_delay, **kwargs)) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + """Deletes a storage account in Microsoft Azure. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace_async + async def get_properties( + self, + resource_group_name: str, + account_name: str, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, + **kwargs: Any + ) -> _models.StorageAccount: + """Returns the properties for the specified storage account including but not limited to name, SKU + name, location, and account status. The ListKeys operation should be used to retrieve storage + keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param expand: May be used to expand the properties within account's properties. By default, + data is not included when fetching properties. Currently we only support geoReplicationStats + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. + :type expand: str or ~azure.mgmt.storage.v2022_09_01.models.StorageAccountExpand + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + + request = build_get_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.get_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncIterable["_models.StorageAccount"]: + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, resource_group_name: str, **kwargs: Any + ) -> AsyncIterable["_models.StorageAccount"]: + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. 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 StorageAccount or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace_async + async def list_keys( + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage + account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" and None. Default value is "kerb". + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] + + request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") + + request = build_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") + + request = build_list_account_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.list_account_sas.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") + + request = build_list_service_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.list_service_sas.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore + + async def _failover_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any + ) -> None: + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_failover_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + failover_type=failover_type, + api_version=api_version, + template_url=self._failover_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + + @distributed_trace_async + async def begin_failover( + self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any + ) -> AsyncLROPoller[None]: + """A failover request can be triggered for a storage account in the event a primary endpoint + becomes unavailable for any reason. The failover occurs from the storage account's primary + cluster to the secondary cluster for RA-GRS accounts. The secondary cluster will become primary + after failover and the account is converted to LRS. In the case of a Planned Failover, the + primary and secondary clusters are swapped after failover and the account remains + geo-replicated. Failover should continue to be used in the event of availability issues as + Planned failover is only available while the primary and secondary endpoints are available. The + primary use case of a Planned Failover is disaster recovery testing drills. This type of + failover is invoked by setting FailoverType parameter to 'Planned'. Learn more about the + failover options here- + https://learn.microsoft.com/en-us/azure/storage/common/storage-disaster-recovery-guidance. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param failover_type: The parameter is set to 'Planned' to indicate whether a Planned failover + is requested. Known values are "Planned" and None. Default value is "Planned". + :type failover_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 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._failover_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + failover_type=failover_type, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + 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) + + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + + async def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any + ) -> None: + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_hierarchical_namespace_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + request_type=request_type, + api_version=api_version, + template_url=self._hierarchical_namespace_migration_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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) + + if cls: + return cls(pipeline_response, None, {}) + + _hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + + @distributed_trace_async + async def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param request_type: Required. Hierarchical namespace migration type can either be a + hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request + 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the + hydration request will migrate the account. Required. + :type request_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 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + request_type=request_type, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + 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) + + begin_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + + async def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_abort_hierarchical_namespace_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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) + + if cls: + return cls(pipeline_response, None, {}) + + _abort_hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + + @distributed_trace_async + async def begin_abort_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> AsyncLROPoller[None]: + """Abort live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._abort_hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + 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) + + begin_abort_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + + async def _restore_blob_ranges_initial( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> _models.BlobRestoreStatus: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") + + request = build_restore_blob_ranges_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_09_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_09_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> AsyncLROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobRestoreParameters 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. + :return: An instance of AsyncLROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.storage.v2022_09_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, AsyncPollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = await self._restore_blob_ranges_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + AsyncPollingMethod, AsyncARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: AsyncPollingMethod + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + 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) + + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + + @distributed_trace_async + async def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + """Revoke user delegation keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_operations.py new file mode 100644 index 000000000000..b4bf2f4a6d70 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_operations.py @@ -0,0 +1,611 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, IO, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._table_operations import ( + build_create_request, + build_delete_request, + build_get_request, + build_list_request, + build_update_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`table` 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") + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table 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 + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table 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 + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + @distributed_trace_async + async def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: + """Gets the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + @distributed_trace_async + async def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> None: + """Deletes the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_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) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> AsyncIterable["_models.Table"]: + """Gets a list of all the tables under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 Table or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ListTableResource", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_services_operations.py new file mode 100644 index 000000000000..f1bbf769c6ef --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_table_services_operations.py @@ -0,0 +1,356 @@ +# pylint: disable=too-many-lines +# 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, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._table_services_operations import ( + build_get_service_properties_request, + build_list_request, + build_set_service_properties_request, +) + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`table_services` 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_async + async def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: + """List all table services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListTableServices or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListTableServices + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] + + request = build_list_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListTableServices", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties or IO + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: 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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self.set_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TableServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore + + @distributed_trace_async + async def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.TableServiceProperties: + """Gets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + template_url=self.get_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TableServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_usages_operations.py new file mode 100644 index 000000000000..079390ff9019 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/aio/operations/_usages_operations.py @@ -0,0 +1,141 @@ +# pylint: disable=too-many-lines +# 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, Callable, Dict, Optional, TypeVar +import urllib.parse + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._usages_operations import build_list_by_location_request + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.aio.StorageManagementClient`'s + :attr:`usages` 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_by_location(self, location: str, **kwargs: Any) -> AsyncIterable["_models.Usage"]: + """Gets the current usage count and the limit for the resources of the location under the + subscription. + + :param location: The location of the Azure Storage resource. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.storage.v2022_09_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] + + 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_by_location_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("UsageListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/__init__.py new file mode 100644 index 000000000000..1b37ad97eb1e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/__init__.py @@ -0,0 +1,443 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from ._models_py3 import AccessPolicy +from ._models_py3 import AccountImmutabilityPolicyProperties +from ._models_py3 import AccountSasParameters +from ._models_py3 import ActiveDirectoryProperties +from ._models_py3 import AzureEntityResource +from ._models_py3 import AzureFilesIdentityBasedAuthentication +from ._models_py3 import BlobContainer +from ._models_py3 import BlobInventoryPolicy +from ._models_py3 import BlobInventoryPolicyDefinition +from ._models_py3 import BlobInventoryPolicyFilter +from ._models_py3 import BlobInventoryPolicyRule +from ._models_py3 import BlobInventoryPolicySchema +from ._models_py3 import BlobRestoreParameters +from ._models_py3 import BlobRestoreRange +from ._models_py3 import BlobRestoreStatus +from ._models_py3 import BlobServiceItems +from ._models_py3 import BlobServiceProperties +from ._models_py3 import ChangeFeed +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import CloudErrorBody +from ._models_py3 import CorsRule +from ._models_py3 import CorsRules +from ._models_py3 import CustomDomain +from ._models_py3 import DateAfterCreation +from ._models_py3 import DateAfterModification +from ._models_py3 import DeleteRetentionPolicy +from ._models_py3 import DeletedAccount +from ._models_py3 import DeletedAccountListResult +from ._models_py3 import DeletedShare +from ._models_py3 import Dimension +from ._models_py3 import Encryption +from ._models_py3 import EncryptionIdentity +from ._models_py3 import EncryptionScope +from ._models_py3 import EncryptionScopeKeyVaultProperties +from ._models_py3 import EncryptionScopeListResult +from ._models_py3 import EncryptionService +from ._models_py3 import EncryptionServices +from ._models_py3 import Endpoints +from ._models_py3 import ErrorResponse +from ._models_py3 import ErrorResponseBody +from ._models_py3 import ExtendedLocation +from ._models_py3 import FileServiceItems +from ._models_py3 import FileServiceProperties +from ._models_py3 import FileShare +from ._models_py3 import FileShareItem +from ._models_py3 import FileShareItems +from ._models_py3 import GeoReplicationStats +from ._models_py3 import IPRule +from ._models_py3 import Identity +from ._models_py3 import ImmutabilityPolicy +from ._models_py3 import ImmutabilityPolicyProperties +from ._models_py3 import ImmutableStorageAccount +from ._models_py3 import ImmutableStorageWithVersioning +from ._models_py3 import KeyCreationTime +from ._models_py3 import KeyPolicy +from ._models_py3 import KeyVaultProperties +from ._models_py3 import LastAccessTimeTrackingPolicy +from ._models_py3 import LeaseContainerRequest +from ._models_py3 import LeaseContainerResponse +from ._models_py3 import LeaseShareRequest +from ._models_py3 import LeaseShareResponse +from ._models_py3 import LegalHold +from ._models_py3 import LegalHoldProperties +from ._models_py3 import ListAccountSasResponse +from ._models_py3 import ListBlobInventoryPolicy +from ._models_py3 import ListContainerItem +from ._models_py3 import ListContainerItems +from ._models_py3 import ListQueue +from ._models_py3 import ListQueueResource +from ._models_py3 import ListQueueServices +from ._models_py3 import ListServiceSasResponse +from ._models_py3 import ListTableResource +from ._models_py3 import ListTableServices +from ._models_py3 import LocalUser +from ._models_py3 import LocalUserKeys +from ._models_py3 import LocalUserRegeneratePasswordResult +from ._models_py3 import LocalUsers +from ._models_py3 import ManagementPolicy +from ._models_py3 import ManagementPolicyAction +from ._models_py3 import ManagementPolicyBaseBlob +from ._models_py3 import ManagementPolicyDefinition +from ._models_py3 import ManagementPolicyFilter +from ._models_py3 import ManagementPolicyRule +from ._models_py3 import ManagementPolicySchema +from ._models_py3 import ManagementPolicySnapShot +from ._models_py3 import ManagementPolicyVersion +from ._models_py3 import MetricSpecification +from ._models_py3 import Multichannel +from ._models_py3 import NetworkRuleSet +from ._models_py3 import ObjectReplicationPolicies +from ._models_py3 import ObjectReplicationPolicy +from ._models_py3 import ObjectReplicationPolicyFilter +from ._models_py3 import ObjectReplicationPolicyRule +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import PermissionScope +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionListResult +from ._models_py3 import PrivateLinkResource +from ._models_py3 import PrivateLinkResourceListResult +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import ProtectedAppendWritesHistory +from ._models_py3 import ProtocolSettings +from ._models_py3 import ProxyResource +from ._models_py3 import QueueServiceProperties +from ._models_py3 import Resource +from ._models_py3 import ResourceAccessRule +from ._models_py3 import RestorePolicyProperties +from ._models_py3 import Restriction +from ._models_py3 import RoutingPreference +from ._models_py3 import SKUCapability +from ._models_py3 import SasPolicy +from ._models_py3 import ServiceSasParameters +from ._models_py3 import ServiceSpecification +from ._models_py3 import SignedIdentifier +from ._models_py3 import Sku +from ._models_py3 import SkuInformation +from ._models_py3 import SmbSetting +from ._models_py3 import SshPublicKey +from ._models_py3 import StorageAccount +from ._models_py3 import StorageAccountCheckNameAvailabilityParameters +from ._models_py3 import StorageAccountCreateParameters +from ._models_py3 import StorageAccountInternetEndpoints +from ._models_py3 import StorageAccountKey +from ._models_py3 import StorageAccountListKeysResult +from ._models_py3 import StorageAccountListResult +from ._models_py3 import StorageAccountMicrosoftEndpoints +from ._models_py3 import StorageAccountRegenerateKeyParameters +from ._models_py3 import StorageAccountSkuConversionStatus +from ._models_py3 import StorageAccountUpdateParameters +from ._models_py3 import StorageQueue +from ._models_py3 import StorageSkuListResult +from ._models_py3 import SystemData +from ._models_py3 import Table +from ._models_py3 import TableAccessPolicy +from ._models_py3 import TableServiceProperties +from ._models_py3 import TableSignedIdentifier +from ._models_py3 import TagFilter +from ._models_py3 import TagProperty +from ._models_py3 import TrackedResource +from ._models_py3 import UpdateHistoryProperty +from ._models_py3 import Usage +from ._models_py3 import UsageListResult +from ._models_py3 import UsageName +from ._models_py3 import UserAssignedIdentity +from ._models_py3 import VirtualNetworkRule + +from ._storage_management_client_enums import AccessTier +from ._storage_management_client_enums import AccountImmutabilityPolicyState +from ._storage_management_client_enums import AccountStatus +from ._storage_management_client_enums import AccountType +from ._storage_management_client_enums import AllowedCopyScope +from ._storage_management_client_enums import AllowedMethods +from ._storage_management_client_enums import BlobInventoryPolicyName +from ._storage_management_client_enums import BlobRestoreProgressStatus +from ._storage_management_client_enums import Bypass +from ._storage_management_client_enums import CreatedByType +from ._storage_management_client_enums import DefaultAction +from ._storage_management_client_enums import DefaultSharePermission +from ._storage_management_client_enums import DirectoryServiceOptions +from ._storage_management_client_enums import DnsEndpointType +from ._storage_management_client_enums import EnabledProtocols +from ._storage_management_client_enums import EncryptionScopeSource +from ._storage_management_client_enums import EncryptionScopeState +from ._storage_management_client_enums import ExpirationAction +from ._storage_management_client_enums import ExtendedLocationTypes +from ._storage_management_client_enums import Format +from ._storage_management_client_enums import GeoReplicationStatus +from ._storage_management_client_enums import HttpProtocol +from ._storage_management_client_enums import IdentityType +from ._storage_management_client_enums import ImmutabilityPolicyState +from ._storage_management_client_enums import ImmutabilityPolicyUpdateType +from ._storage_management_client_enums import InventoryRuleType +from ._storage_management_client_enums import KeyPermission +from ._storage_management_client_enums import KeySource +from ._storage_management_client_enums import KeyType +from ._storage_management_client_enums import Kind +from ._storage_management_client_enums import LargeFileSharesState +from ._storage_management_client_enums import LeaseContainerRequestEnum +from ._storage_management_client_enums import LeaseDuration +from ._storage_management_client_enums import LeaseShareAction +from ._storage_management_client_enums import LeaseState +from ._storage_management_client_enums import LeaseStatus +from ._storage_management_client_enums import ListContainersInclude +from ._storage_management_client_enums import ListEncryptionScopesInclude +from ._storage_management_client_enums import ManagementPolicyName +from ._storage_management_client_enums import MigrationState +from ._storage_management_client_enums import MinimumTlsVersion +from ._storage_management_client_enums import Name +from ._storage_management_client_enums import ObjectType +from ._storage_management_client_enums import Permissions +from ._storage_management_client_enums import PrivateEndpointConnectionProvisioningState +from ._storage_management_client_enums import PrivateEndpointServiceConnectionStatus +from ._storage_management_client_enums import ProvisioningState +from ._storage_management_client_enums import PublicAccess +from ._storage_management_client_enums import PublicNetworkAccess +from ._storage_management_client_enums import Reason +from ._storage_management_client_enums import ReasonCode +from ._storage_management_client_enums import RootSquashType +from ._storage_management_client_enums import RoutingChoice +from ._storage_management_client_enums import RuleType +from ._storage_management_client_enums import Schedule +from ._storage_management_client_enums import Services +from ._storage_management_client_enums import ShareAccessTier +from ._storage_management_client_enums import SignedResource +from ._storage_management_client_enums import SignedResourceTypes +from ._storage_management_client_enums import SkuConversionStatus +from ._storage_management_client_enums import SkuName +from ._storage_management_client_enums import SkuTier +from ._storage_management_client_enums import State +from ._storage_management_client_enums import StorageAccountExpand +from ._storage_management_client_enums import UsageUnit +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "AccessPolicy", + "AccountImmutabilityPolicyProperties", + "AccountSasParameters", + "ActiveDirectoryProperties", + "AzureEntityResource", + "AzureFilesIdentityBasedAuthentication", + "BlobContainer", + "BlobInventoryPolicy", + "BlobInventoryPolicyDefinition", + "BlobInventoryPolicyFilter", + "BlobInventoryPolicyRule", + "BlobInventoryPolicySchema", + "BlobRestoreParameters", + "BlobRestoreRange", + "BlobRestoreStatus", + "BlobServiceItems", + "BlobServiceProperties", + "ChangeFeed", + "CheckNameAvailabilityResult", + "CloudErrorBody", + "CorsRule", + "CorsRules", + "CustomDomain", + "DateAfterCreation", + "DateAfterModification", + "DeleteRetentionPolicy", + "DeletedAccount", + "DeletedAccountListResult", + "DeletedShare", + "Dimension", + "Encryption", + "EncryptionIdentity", + "EncryptionScope", + "EncryptionScopeKeyVaultProperties", + "EncryptionScopeListResult", + "EncryptionService", + "EncryptionServices", + "Endpoints", + "ErrorResponse", + "ErrorResponseBody", + "ExtendedLocation", + "FileServiceItems", + "FileServiceProperties", + "FileShare", + "FileShareItem", + "FileShareItems", + "GeoReplicationStats", + "IPRule", + "Identity", + "ImmutabilityPolicy", + "ImmutabilityPolicyProperties", + "ImmutableStorageAccount", + "ImmutableStorageWithVersioning", + "KeyCreationTime", + "KeyPolicy", + "KeyVaultProperties", + "LastAccessTimeTrackingPolicy", + "LeaseContainerRequest", + "LeaseContainerResponse", + "LeaseShareRequest", + "LeaseShareResponse", + "LegalHold", + "LegalHoldProperties", + "ListAccountSasResponse", + "ListBlobInventoryPolicy", + "ListContainerItem", + "ListContainerItems", + "ListQueue", + "ListQueueResource", + "ListQueueServices", + "ListServiceSasResponse", + "ListTableResource", + "ListTableServices", + "LocalUser", + "LocalUserKeys", + "LocalUserRegeneratePasswordResult", + "LocalUsers", + "ManagementPolicy", + "ManagementPolicyAction", + "ManagementPolicyBaseBlob", + "ManagementPolicyDefinition", + "ManagementPolicyFilter", + "ManagementPolicyRule", + "ManagementPolicySchema", + "ManagementPolicySnapShot", + "ManagementPolicyVersion", + "MetricSpecification", + "Multichannel", + "NetworkRuleSet", + "ObjectReplicationPolicies", + "ObjectReplicationPolicy", + "ObjectReplicationPolicyFilter", + "ObjectReplicationPolicyRule", + "Operation", + "OperationDisplay", + "OperationListResult", + "PermissionScope", + "PrivateEndpoint", + "PrivateEndpointConnection", + "PrivateEndpointConnectionListResult", + "PrivateLinkResource", + "PrivateLinkResourceListResult", + "PrivateLinkServiceConnectionState", + "ProtectedAppendWritesHistory", + "ProtocolSettings", + "ProxyResource", + "QueueServiceProperties", + "Resource", + "ResourceAccessRule", + "RestorePolicyProperties", + "Restriction", + "RoutingPreference", + "SKUCapability", + "SasPolicy", + "ServiceSasParameters", + "ServiceSpecification", + "SignedIdentifier", + "Sku", + "SkuInformation", + "SmbSetting", + "SshPublicKey", + "StorageAccount", + "StorageAccountCheckNameAvailabilityParameters", + "StorageAccountCreateParameters", + "StorageAccountInternetEndpoints", + "StorageAccountKey", + "StorageAccountListKeysResult", + "StorageAccountListResult", + "StorageAccountMicrosoftEndpoints", + "StorageAccountRegenerateKeyParameters", + "StorageAccountSkuConversionStatus", + "StorageAccountUpdateParameters", + "StorageQueue", + "StorageSkuListResult", + "SystemData", + "Table", + "TableAccessPolicy", + "TableServiceProperties", + "TableSignedIdentifier", + "TagFilter", + "TagProperty", + "TrackedResource", + "UpdateHistoryProperty", + "Usage", + "UsageListResult", + "UsageName", + "UserAssignedIdentity", + "VirtualNetworkRule", + "AccessTier", + "AccountImmutabilityPolicyState", + "AccountStatus", + "AccountType", + "AllowedCopyScope", + "AllowedMethods", + "BlobInventoryPolicyName", + "BlobRestoreProgressStatus", + "Bypass", + "CreatedByType", + "DefaultAction", + "DefaultSharePermission", + "DirectoryServiceOptions", + "DnsEndpointType", + "EnabledProtocols", + "EncryptionScopeSource", + "EncryptionScopeState", + "ExpirationAction", + "ExtendedLocationTypes", + "Format", + "GeoReplicationStatus", + "HttpProtocol", + "IdentityType", + "ImmutabilityPolicyState", + "ImmutabilityPolicyUpdateType", + "InventoryRuleType", + "KeyPermission", + "KeySource", + "KeyType", + "Kind", + "LargeFileSharesState", + "LeaseContainerRequestEnum", + "LeaseDuration", + "LeaseShareAction", + "LeaseState", + "LeaseStatus", + "ListContainersInclude", + "ListEncryptionScopesInclude", + "ManagementPolicyName", + "MigrationState", + "MinimumTlsVersion", + "Name", + "ObjectType", + "Permissions", + "PrivateEndpointConnectionProvisioningState", + "PrivateEndpointServiceConnectionStatus", + "ProvisioningState", + "PublicAccess", + "PublicNetworkAccess", + "Reason", + "ReasonCode", + "RootSquashType", + "RoutingChoice", + "RuleType", + "Schedule", + "Services", + "ShareAccessTier", + "SignedResource", + "SignedResourceTypes", + "SkuConversionStatus", + "SkuName", + "SkuTier", + "State", + "StorageAccountExpand", + "UsageUnit", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_models_py3.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_models_py3.py new file mode 100644 index 000000000000..aefd6d305502 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_models_py3.py @@ -0,0 +1,8064 @@ +# coding=utf-8 +# pylint: disable=too-many-lines +# -------------------------------------------------------------------------- +# 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 datetime +import sys +from typing import Dict, List, Optional, TYPE_CHECKING, Union + +from ... import _serialization + +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 + from .. import models as _models + + +class AccessPolicy(_serialization.Model): + """AccessPolicy. + + :ivar start_time: Start time of the access policy. + :vartype start_time: ~datetime.datetime + :ivar expiry_time: Expiry time of the access policy. + :vartype expiry_time: ~datetime.datetime + :ivar permission: List of abbreviated permissions. + :vartype permission: str + """ + + _attribute_map = { + "start_time": {"key": "startTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "permission": {"key": "permission", "type": "str"}, + } + + def __init__( + self, + *, + start_time: Optional[datetime.datetime] = None, + expiry_time: Optional[datetime.datetime] = None, + permission: Optional[str] = None, + **kwargs + ): + """ + :keyword start_time: Start time of the access policy. + :paramtype start_time: ~datetime.datetime + :keyword expiry_time: Expiry time of the access policy. + :paramtype expiry_time: ~datetime.datetime + :keyword permission: List of abbreviated permissions. + :paramtype permission: str + """ + super().__init__(**kwargs) + self.start_time = start_time + self.expiry_time = expiry_time + self.permission = permission + + +class AccountImmutabilityPolicyProperties(_serialization.Model): + """This defines account-level immutability policy properties. + + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar state: The ImmutabilityPolicy state defines the mode of the policy. Disabled state + disables the policy, Unlocked state allows increase and decrease of immutability retention time + and also allows toggling allowProtectedAppendWrites property, Locked state only allows the + increase of the immutability retention time. A policy can only be created in a Disabled or + Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", + "Locked", and "Disabled". + :vartype state: str or ~azure.mgmt.storage.v2022_09_01.models.AccountImmutabilityPolicyState + :ivar allow_protected_append_writes: This property can only be changed for disabled and + unlocked time-based retention policies. When enabled, new blocks can be written to an append + blob while maintaining immutability protection and compliance. Only new blocks can be added and + any existing blocks cannot be modified or deleted. + :vartype allow_protected_append_writes: bool + """ + + _validation = { + "immutability_period_since_creation_in_days": {"maximum": 146000, "minimum": 1}, + } + + _attribute_map = { + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "state": {"key": "state", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, + } + + def __init__( + self, + *, + immutability_period_since_creation_in_days: Optional[int] = None, + state: Optional[Union[str, "_models.AccountImmutabilityPolicyState"]] = None, + allow_protected_append_writes: Optional[bool] = None, + **kwargs + ): + """ + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. + :paramtype immutability_period_since_creation_in_days: int + :keyword state: The ImmutabilityPolicy state defines the mode of the policy. Disabled state + disables the policy, Unlocked state allows increase and decrease of immutability retention time + and also allows toggling allowProtectedAppendWrites property, Locked state only allows the + increase of the immutability retention time. A policy can only be created in a Disabled or + Unlocked state and can be toggled between the two states. Only a policy in an Unlocked state + can transition to a Locked state which cannot be reverted. Known values are: "Unlocked", + "Locked", and "Disabled". + :paramtype state: str or ~azure.mgmt.storage.v2022_09_01.models.AccountImmutabilityPolicyState + :keyword allow_protected_append_writes: This property can only be changed for disabled and + unlocked time-based retention policies. When enabled, new blocks can be written to an append + blob while maintaining immutability protection and compliance. Only new blocks can be added and + any existing blocks cannot be modified or deleted. + :paramtype allow_protected_append_writes: bool + """ + super().__init__(**kwargs) + self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days + self.state = state + self.allow_protected_append_writes = allow_protected_append_writes + + +class AccountSasParameters(_serialization.Model): + """The parameters to list SAS credentials of a storage account. + + All required parameters must be populated in order to send to Azure. + + :ivar services: The signed services accessible with the account SAS. Possible values include: + Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", and "f". + :vartype services: str or ~azure.mgmt.storage.v2022_09_01.models.Services + :ivar resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". + :vartype resource_types: str or ~azure.mgmt.storage.v2022_09_01.models.SignedResourceTypes + :ivar permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". + :vartype permissions: str or ~azure.mgmt.storage.v2022_09_01.models.Permissions + :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :vartype ip_address_or_range: str + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http" and "https". + :vartype protocols: str or ~azure.mgmt.storage.v2022_09_01.models.HttpProtocol + :ivar shared_access_start_time: The time at which the SAS becomes valid. + :vartype shared_access_start_time: ~datetime.datetime + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + Required. + :vartype shared_access_expiry_time: ~datetime.datetime + :ivar key_to_sign: The key to sign the account SAS token with. + :vartype key_to_sign: str + """ + + _validation = { + "services": {"required": True}, + "resource_types": {"required": True}, + "permissions": {"required": True}, + "shared_access_expiry_time": {"required": True}, + } + + _attribute_map = { + "services": {"key": "signedServices", "type": "str"}, + "resource_types": {"key": "signedResourceTypes", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + } + + def __init__( + self, + *, + services: Union[str, "_models.Services"], + resource_types: Union[str, "_models.SignedResourceTypes"], + permissions: Union[str, "_models.Permissions"], + shared_access_expiry_time: datetime.datetime, + ip_address_or_range: Optional[str] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, + shared_access_start_time: Optional[datetime.datetime] = None, + key_to_sign: Optional[str] = None, + **kwargs + ): + """ + :keyword services: The signed services accessible with the account SAS. Possible values + include: Blob (b), Queue (q), Table (t), File (f). Required. Known values are: "b", "q", "t", + and "f". + :paramtype services: str or ~azure.mgmt.storage.v2022_09_01.models.Services + :keyword resource_types: The signed resource types that are accessible with the account SAS. + Service (s): Access to service-level APIs; Container (c): Access to container-level APIs; + Object (o): Access to object-level APIs for blobs, queue messages, table entities, and files. + Required. Known values are: "s", "c", and "o". + :paramtype resource_types: str or ~azure.mgmt.storage.v2022_09_01.models.SignedResourceTypes + :keyword permissions: The signed permissions for the account SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + Required. Known values are: "r", "d", "w", "l", "a", "c", "u", and "p". + :paramtype permissions: str or ~azure.mgmt.storage.v2022_09_01.models.Permissions + :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :paramtype ip_address_or_range: str + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http" and "https". + :paramtype protocols: str or ~azure.mgmt.storage.v2022_09_01.models.HttpProtocol + :keyword shared_access_start_time: The time at which the SAS becomes valid. + :paramtype shared_access_start_time: ~datetime.datetime + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. Required. + :paramtype shared_access_expiry_time: ~datetime.datetime + :keyword key_to_sign: The key to sign the account SAS token with. + :paramtype key_to_sign: str + """ + super().__init__(**kwargs) + self.services = services + self.resource_types = resource_types + self.permissions = permissions + self.ip_address_or_range = ip_address_or_range + self.protocols = protocols + self.shared_access_start_time = shared_access_start_time + self.shared_access_expiry_time = shared_access_expiry_time + self.key_to_sign = key_to_sign + + +class ActiveDirectoryProperties(_serialization.Model): + """Settings properties for Active Directory (AD). + + All required parameters must be populated in order to send to Azure. + + :ivar domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. + :vartype domain_name: str + :ivar net_bios_domain_name: Specifies the NetBIOS domain name. + :vartype net_bios_domain_name: str + :ivar forest_name: Specifies the Active Directory forest to get. + :vartype forest_name: str + :ivar domain_guid: Specifies the domain GUID. Required. + :vartype domain_guid: str + :ivar domain_sid: Specifies the security identifier (SID). + :vartype domain_sid: str + :ivar azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + :vartype azure_storage_sid: str + :ivar sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. + :vartype sam_account_name: str + :ivar account_type: Specifies the Active Directory account type for Azure Storage. Known values + are: "User" and "Computer". + :vartype account_type: str or ~azure.mgmt.storage.v2022_09_01.models.AccountType + """ + + _validation = { + "domain_name": {"required": True}, + "domain_guid": {"required": True}, + } + + _attribute_map = { + "domain_name": {"key": "domainName", "type": "str"}, + "net_bios_domain_name": {"key": "netBiosDomainName", "type": "str"}, + "forest_name": {"key": "forestName", "type": "str"}, + "domain_guid": {"key": "domainGuid", "type": "str"}, + "domain_sid": {"key": "domainSid", "type": "str"}, + "azure_storage_sid": {"key": "azureStorageSid", "type": "str"}, + "sam_account_name": {"key": "samAccountName", "type": "str"}, + "account_type": {"key": "accountType", "type": "str"}, + } + + def __init__( + self, + *, + domain_name: str, + domain_guid: str, + net_bios_domain_name: Optional[str] = None, + forest_name: Optional[str] = None, + domain_sid: Optional[str] = None, + azure_storage_sid: Optional[str] = None, + sam_account_name: Optional[str] = None, + account_type: Optional[Union[str, "_models.AccountType"]] = None, + **kwargs + ): + """ + :keyword domain_name: Specifies the primary domain that the AD DNS server is authoritative for. + Required. + :paramtype domain_name: str + :keyword net_bios_domain_name: Specifies the NetBIOS domain name. + :paramtype net_bios_domain_name: str + :keyword forest_name: Specifies the Active Directory forest to get. + :paramtype forest_name: str + :keyword domain_guid: Specifies the domain GUID. Required. + :paramtype domain_guid: str + :keyword domain_sid: Specifies the security identifier (SID). + :paramtype domain_sid: str + :keyword azure_storage_sid: Specifies the security identifier (SID) for Azure Storage. + :paramtype azure_storage_sid: str + :keyword sam_account_name: Specifies the Active Directory SAMAccountName for Azure Storage. + :paramtype sam_account_name: str + :keyword account_type: Specifies the Active Directory account type for Azure Storage. Known + values are: "User" and "Computer". + :paramtype account_type: str or ~azure.mgmt.storage.v2022_09_01.models.AccountType + """ + super().__init__(**kwargs) + self.domain_name = domain_name + self.net_bios_domain_name = net_bios_domain_name + self.forest_name = forest_name + self.domain_guid = domain_guid + self.domain_sid = domain_sid + self.azure_storage_sid = azure_storage_sid + self.sam_account_name = sam_account_name + self.account_type = account_type + + +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. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class AzureEntityResource(Resource): + """The resource model definition for an Azure Resource Manager resource with an etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.etag = None + + +class AzureFilesIdentityBasedAuthentication(_serialization.Model): + """Settings for Azure Files identity based authentication. + + All required parameters must be populated in order to send to Azure. + + :ivar directory_service_options: Indicates the directory service used. Note that this enum may + be extended in the future. Required. Known values are: "None", "AADDS", "AD", and "AADKERB". + :vartype directory_service_options: str or + ~azure.mgmt.storage.v2022_09_01.models.DirectoryServiceOptions + :ivar active_directory_properties: Required if directoryServiceOptions are AD, optional if they + are AADKERB. + :vartype active_directory_properties: + ~azure.mgmt.storage.v2022_09_01.models.ActiveDirectoryProperties + :ivar default_share_permission: Default share permission for users using Kerberos + authentication if RBAC role is not assigned. Known values are: "None", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and + "StorageFileDataSmbShareElevatedContributor". + :vartype default_share_permission: str or + ~azure.mgmt.storage.v2022_09_01.models.DefaultSharePermission + """ + + _validation = { + "directory_service_options": {"required": True}, + } + + _attribute_map = { + "directory_service_options": {"key": "directoryServiceOptions", "type": "str"}, + "active_directory_properties": {"key": "activeDirectoryProperties", "type": "ActiveDirectoryProperties"}, + "default_share_permission": {"key": "defaultSharePermission", "type": "str"}, + } + + def __init__( + self, + *, + directory_service_options: Union[str, "_models.DirectoryServiceOptions"], + active_directory_properties: Optional["_models.ActiveDirectoryProperties"] = None, + default_share_permission: Optional[Union[str, "_models.DefaultSharePermission"]] = None, + **kwargs + ): + """ + :keyword directory_service_options: Indicates the directory service used. Note that this enum + may be extended in the future. Required. Known values are: "None", "AADDS", "AD", and + "AADKERB". + :paramtype directory_service_options: str or + ~azure.mgmt.storage.v2022_09_01.models.DirectoryServiceOptions + :keyword active_directory_properties: Required if directoryServiceOptions are AD, optional if + they are AADKERB. + :paramtype active_directory_properties: + ~azure.mgmt.storage.v2022_09_01.models.ActiveDirectoryProperties + :keyword default_share_permission: Default share permission for users using Kerberos + authentication if RBAC role is not assigned. Known values are: "None", + "StorageFileDataSmbShareReader", "StorageFileDataSmbShareContributor", and + "StorageFileDataSmbShareElevatedContributor". + :paramtype default_share_permission: str or + ~azure.mgmt.storage.v2022_09_01.models.DefaultSharePermission + """ + super().__init__(**kwargs) + self.directory_service_options = directory_service_options + self.active_directory_properties = active_directory_properties + self.default_share_permission = default_share_permission + + +class BlobContainer(AzureEntityResource): # pylint: disable=too-many-instance-attributes + """Properties of the blob container, including Id, resource name, resource type, Etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar version: The version of the deleted blob container. + :vartype version: str + :ivar deleted: Indicates whether the blob container was deleted. + :vartype deleted: bool + :ivar deleted_time: Blob container deletion time. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for soft deleted blob container. + :vartype remaining_retention_days: int + :ivar default_encryption_scope: Default the container to use specified encryption scope for all + writes. + :vartype default_encryption_scope: str + :ivar deny_encryption_scope_override: Block override of encryption scope from the container + default. + :vartype deny_encryption_scope_override: bool + :ivar public_access: Specifies whether data in the container may be accessed publicly and the + level of access. Known values are: "Container", "Blob", and "None". + :vartype public_access: str or ~azure.mgmt.storage.v2022_09_01.models.PublicAccess + :ivar last_modified_time: Returns the date and time the container was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseStatus + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", and "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseDuration + :ivar metadata: A name-value pair to associate with the container as metadata. + :vartype metadata: dict[str, str] + :ivar immutability_policy: The ImmutabilityPolicy property of the container. + :vartype immutability_policy: + ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicyProperties + :ivar legal_hold: The LegalHold property of the container. + :vartype legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHoldProperties + :ivar has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar has_immutability_policy: The hasImmutabilityPolicy public property is set to true by SRP + if ImmutabilityPolicy has been created for this container. The hasImmutabilityPolicy public + property is set to false by SRP if ImmutabilityPolicy has not been created for this container. + :vartype has_immutability_policy: bool + :ivar immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_09_01.models.ImmutableStorageWithVersioning + :ivar enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :vartype enable_nfs_v3_root_squash: bool + :ivar enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :vartype enable_nfs_v3_all_squash: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, + } + + def __init__( + self, + *, + default_encryption_scope: Optional[str] = None, + deny_encryption_scope_override: Optional[bool] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, + metadata: Optional[Dict[str, str]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, + enable_nfs_v3_root_squash: Optional[bool] = None, + enable_nfs_v3_all_squash: Optional[bool] = None, + **kwargs + ): + """ + :keyword default_encryption_scope: Default the container to use specified encryption scope for + all writes. + :paramtype default_encryption_scope: str + :keyword deny_encryption_scope_override: Block override of encryption scope from the container + default. + :paramtype deny_encryption_scope_override: bool + :keyword public_access: Specifies whether data in the container may be accessed publicly and + the level of access. Known values are: "Container", "Blob", and "None". + :paramtype public_access: str or ~azure.mgmt.storage.v2022_09_01.models.PublicAccess + :keyword metadata: A name-value pair to associate with the container as metadata. + :paramtype metadata: dict[str, str] + :keyword immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_09_01.models.ImmutableStorageWithVersioning + :keyword enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :paramtype enable_nfs_v3_root_squash: bool + :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :paramtype enable_nfs_v3_all_squash: bool + """ + super().__init__(**kwargs) + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.default_encryption_scope = default_encryption_scope + self.deny_encryption_scope_override = deny_encryption_scope_override + self.public_access = public_access + self.last_modified_time = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.metadata = metadata + self.immutability_policy = None + self.legal_hold = None + self.has_legal_hold = None + self.has_immutability_policy = None + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.enable_nfs_v3_root_squash = enable_nfs_v3_root_squash + self.enable_nfs_v3_all_squash = enable_nfs_v3_all_squash + + +class BlobInventoryPolicy(Resource): + """The storage account blob inventory policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.storage.v2022_09_01.models.SystemData + :ivar last_modified_time: Returns the last modified date and time of the blob inventory policy. + :vartype last_modified_time: ~datetime.datetime + :ivar policy: The storage account blob inventory policy object. It is composed of policy rules. + :vartype policy: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicySchema + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "last_modified_time": {"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"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "BlobInventoryPolicySchema"}, + } + + def __init__(self, *, policy: Optional["_models.BlobInventoryPolicySchema"] = None, **kwargs): + """ + :keyword policy: The storage account blob inventory policy object. It is composed of policy + rules. + :paramtype policy: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicySchema + """ + super().__init__(**kwargs) + self.system_data = None + self.last_modified_time = None + self.policy = policy + + +class BlobInventoryPolicyDefinition(_serialization.Model): + """An object that defines the blob inventory rule. + + All required parameters must be populated in order to send to Azure. + + :ivar filters: An object that defines the filter set. + :vartype filters: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyFilter + :ivar format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". + :vartype format: str or ~azure.mgmt.storage.v2022_09_01.models.Format + :ivar schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". + :vartype schedule: str or ~azure.mgmt.storage.v2022_09_01.models.Schedule + :ivar object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". + :vartype object_type: str or ~azure.mgmt.storage.v2022_09_01.models.ObjectType + :ivar schema_fields: This is a required field. This field specifies the fields and properties + of the object to be included in the inventory. The Schema field value 'Name' is always + required. The valid values for this field for the 'Blob' definition.objectType include 'Name, + Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, + AccessTierChangeTime, AccessTierInferred, Tags, Expiry-Time, hdi_isfolder, Owner, Group, + Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime, Tags, Etag, + ContentType, ContentEncoding, ContentLanguage, ContentCRC64, CacheControl, ContentDisposition, + LeaseStatus, LeaseState, LeaseDuration, ServerEncrypted, Deleted, DeletionId, DeletedTime, + RemainingRetentionDays, ImmutabilityPolicyUntilDate, ImmutabilityPolicyMode, LegalHold, CopyId, + CopyStatus, CopySource, CopyProgress, CopyCompletionTime, CopyStatusDescription, + CustomerProvidedKeySha256, RehydratePriority, ArchiveStatus, XmsBlobSequenceNumber, + EncryptionScope, IncrementalCopy, TagCount'. For Blob object type schema field value + 'DeletedTime' is applicable only for Hns enabled accounts. The valid values for 'Container' + definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, + LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold, Etag, DefaultEncryptionScope, + DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, + DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, + Group, Permissions, Acl, DeletionId' are valid only for Hns enabled accounts.Schema field + values 'Tags, TagCount' are only valid for Non-Hns accounts. Required. + :vartype schema_fields: list[str] + """ + + _validation = { + "format": {"required": True}, + "schedule": {"required": True}, + "object_type": {"required": True}, + "schema_fields": {"required": True}, + } + + _attribute_map = { + "filters": {"key": "filters", "type": "BlobInventoryPolicyFilter"}, + "format": {"key": "format", "type": "str"}, + "schedule": {"key": "schedule", "type": "str"}, + "object_type": {"key": "objectType", "type": "str"}, + "schema_fields": {"key": "schemaFields", "type": "[str]"}, + } + + def __init__( + self, + *, + format: Union[str, "_models.Format"], + schedule: Union[str, "_models.Schedule"], + object_type: Union[str, "_models.ObjectType"], + schema_fields: List[str], + filters: Optional["_models.BlobInventoryPolicyFilter"] = None, + **kwargs + ): + """ + :keyword filters: An object that defines the filter set. + :paramtype filters: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyFilter + :keyword format: This is a required field, it specifies the format for the inventory files. + Required. Known values are: "Csv" and "Parquet". + :paramtype format: str or ~azure.mgmt.storage.v2022_09_01.models.Format + :keyword schedule: This is a required field. This field is used to schedule an inventory + formation. Required. Known values are: "Daily" and "Weekly". + :paramtype schedule: str or ~azure.mgmt.storage.v2022_09_01.models.Schedule + :keyword object_type: This is a required field. This field specifies the scope of the inventory + created either at the blob or container level. Required. Known values are: "Blob" and + "Container". + :paramtype object_type: str or ~azure.mgmt.storage.v2022_09_01.models.ObjectType + :keyword schema_fields: This is a required field. This field specifies the fields and + properties of the object to be included in the inventory. The Schema field value 'Name' is + always required. The valid values for this field for the 'Blob' definition.objectType include + 'Name, Creation-Time, Last-Modified, Content-Length, Content-MD5, BlobType, AccessTier, + AccessTierChangeTime, AccessTierInferred, Tags, Expiry-Time, hdi_isfolder, Owner, Group, + Permissions, Acl, Snapshot, VersionId, IsCurrentVersion, Metadata, LastAccessTime, Tags, Etag, + ContentType, ContentEncoding, ContentLanguage, ContentCRC64, CacheControl, ContentDisposition, + LeaseStatus, LeaseState, LeaseDuration, ServerEncrypted, Deleted, DeletionId, DeletedTime, + RemainingRetentionDays, ImmutabilityPolicyUntilDate, ImmutabilityPolicyMode, LegalHold, CopyId, + CopyStatus, CopySource, CopyProgress, CopyCompletionTime, CopyStatusDescription, + CustomerProvidedKeySha256, RehydratePriority, ArchiveStatus, XmsBlobSequenceNumber, + EncryptionScope, IncrementalCopy, TagCount'. For Blob object type schema field value + 'DeletedTime' is applicable only for Hns enabled accounts. The valid values for 'Container' + definition.objectType include 'Name, Last-Modified, Metadata, LeaseStatus, LeaseState, + LeaseDuration, PublicAccess, HasImmutabilityPolicy, HasLegalHold, Etag, DefaultEncryptionScope, + DenyEncryptionScopeOverride, ImmutableStorageWithVersioningEnabled, Deleted, Version, + DeletedTime, RemainingRetentionDays'. Schema field values 'Expiry-Time, hdi_isfolder, Owner, + Group, Permissions, Acl, DeletionId' are valid only for Hns enabled accounts.Schema field + values 'Tags, TagCount' are only valid for Non-Hns accounts. Required. + :paramtype schema_fields: list[str] + """ + super().__init__(**kwargs) + self.filters = filters + self.format = format + self.schedule = schedule + self.object_type = object_type + self.schema_fields = schema_fields + + +class BlobInventoryPolicyFilter(_serialization.Model): + """An object that defines the blob inventory rule filter conditions. For 'Blob' definition.objectType all filter properties are applicable, 'blobTypes' is required and others are optional. For 'Container' definition.objectType only prefixMatch is applicable and is optional. + + :ivar prefix_match: An array of strings with maximum 10 blob prefixes to be included in the + inventory. + :vartype prefix_match: list[str] + :ivar exclude_prefix: An array of strings with maximum 10 blob prefixes to be excluded from the + inventory. + :vartype exclude_prefix: list[str] + :ivar blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. This field is required when + definition.objectType property is set to 'Blob'. + :vartype blob_types: list[str] + :ivar include_blob_versions: Includes blob versions in blob inventory when value is set to + true. The definition.schemaFields values 'VersionId and IsCurrentVersion' are required if this + property is set to true, else they must be excluded. + :vartype include_blob_versions: bool + :ivar include_snapshots: Includes blob snapshots in blob inventory when value is set to true. + The definition.schemaFields value 'Snapshot' is required if this property is set to true, else + it must be excluded. + :vartype include_snapshots: bool + :ivar include_deleted: For 'Container' definition.objectType the definition.schemaFields must + include 'Deleted, Version, DeletedTime and RemainingRetentionDays'. For 'Blob' + definition.objectType and HNS enabled storage accounts the definition.schemaFields must include + 'DeletionId, Deleted, DeletedTime and RemainingRetentionDays' and for Hns disabled accounts the + definition.schemaFields must include 'Deleted and RemainingRetentionDays', else it must be + excluded. + :vartype include_deleted: bool + """ + + _attribute_map = { + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "exclude_prefix": {"key": "excludePrefix", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "include_blob_versions": {"key": "includeBlobVersions", "type": "bool"}, + "include_snapshots": {"key": "includeSnapshots", "type": "bool"}, + "include_deleted": {"key": "includeDeleted", "type": "bool"}, + } + + def __init__( + self, + *, + prefix_match: Optional[List[str]] = None, + exclude_prefix: Optional[List[str]] = None, + blob_types: Optional[List[str]] = None, + include_blob_versions: Optional[bool] = None, + include_snapshots: Optional[bool] = None, + include_deleted: Optional[bool] = None, + **kwargs + ): + """ + :keyword prefix_match: An array of strings with maximum 10 blob prefixes to be included in the + inventory. + :paramtype prefix_match: list[str] + :keyword exclude_prefix: An array of strings with maximum 10 blob prefixes to be excluded from + the inventory. + :paramtype exclude_prefix: list[str] + :keyword blob_types: An array of predefined enum values. Valid values include blockBlob, + appendBlob, pageBlob. Hns accounts does not support pageBlobs. This field is required when + definition.objectType property is set to 'Blob'. + :paramtype blob_types: list[str] + :keyword include_blob_versions: Includes blob versions in blob inventory when value is set to + true. The definition.schemaFields values 'VersionId and IsCurrentVersion' are required if this + property is set to true, else they must be excluded. + :paramtype include_blob_versions: bool + :keyword include_snapshots: Includes blob snapshots in blob inventory when value is set to + true. The definition.schemaFields value 'Snapshot' is required if this property is set to true, + else it must be excluded. + :paramtype include_snapshots: bool + :keyword include_deleted: For 'Container' definition.objectType the definition.schemaFields + must include 'Deleted, Version, DeletedTime and RemainingRetentionDays'. For 'Blob' + definition.objectType and HNS enabled storage accounts the definition.schemaFields must include + 'DeletionId, Deleted, DeletedTime and RemainingRetentionDays' and for Hns disabled accounts the + definition.schemaFields must include 'Deleted and RemainingRetentionDays', else it must be + excluded. + :paramtype include_deleted: bool + """ + super().__init__(**kwargs) + self.prefix_match = prefix_match + self.exclude_prefix = exclude_prefix + self.blob_types = blob_types + self.include_blob_versions = include_blob_versions + self.include_snapshots = include_snapshots + self.include_deleted = include_deleted + + +class BlobInventoryPolicyRule(_serialization.Model): + """An object that wraps the blob inventory rule. Each rule is uniquely defined by name. + + All required parameters must be populated in order to send to Azure. + + :ivar enabled: Rule is enabled when set to true. Required. + :vartype enabled: bool + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. + :vartype name: str + :ivar destination: Container name where blob inventory files are stored. Must be pre-created. + Required. + :vartype destination: str + :ivar definition: An object that defines the blob inventory policy rule. Required. + :vartype definition: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyDefinition + """ + + _validation = { + "enabled": {"required": True}, + "name": {"required": True}, + "destination": {"required": True}, + "definition": {"required": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "destination": {"key": "destination", "type": "str"}, + "definition": {"key": "definition", "type": "BlobInventoryPolicyDefinition"}, + } + + def __init__( + self, + *, + enabled: bool, + name: str, + destination: str, + definition: "_models.BlobInventoryPolicyDefinition", + **kwargs + ): + """ + :keyword enabled: Rule is enabled when set to true. Required. + :paramtype enabled: bool + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. + :paramtype name: str + :keyword destination: Container name where blob inventory files are stored. Must be + pre-created. Required. + :paramtype destination: str + :keyword definition: An object that defines the blob inventory policy rule. Required. + :paramtype definition: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyDefinition + """ + super().__init__(**kwargs) + self.enabled = enabled + self.name = name + self.destination = destination + self.definition = definition + + +class BlobInventoryPolicySchema(_serialization.Model): + """The storage account blob inventory policy rules. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar enabled: Policy is enabled if set to true. Required. + :vartype enabled: bool + :ivar destination: Deprecated Property from API version 2021-04-01 onwards, the required + destination container name must be specified at the rule level 'policy.rule.destination'. + :vartype destination: str + :ivar type: The valid value is Inventory. Required. "Inventory" + :vartype type: str or ~azure.mgmt.storage.v2022_09_01.models.InventoryRuleType + :ivar rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. + :vartype rules: list[~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyRule] + """ + + _validation = { + "enabled": {"required": True}, + "destination": {"readonly": True}, + "type": {"required": True}, + "rules": {"required": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "destination": {"key": "destination", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "rules": {"key": "rules", "type": "[BlobInventoryPolicyRule]"}, + } + + def __init__( + self, + *, + enabled: bool, + type: Union[str, "_models.InventoryRuleType"], + rules: List["_models.BlobInventoryPolicyRule"], + **kwargs + ): + """ + :keyword enabled: Policy is enabled if set to true. Required. + :paramtype enabled: bool + :keyword type: The valid value is Inventory. Required. "Inventory" + :paramtype type: str or ~azure.mgmt.storage.v2022_09_01.models.InventoryRuleType + :keyword rules: The storage account blob inventory policy rules. The rule is applied when it is + enabled. Required. + :paramtype rules: list[~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyRule] + """ + super().__init__(**kwargs) + self.enabled = enabled + self.destination = None + self.type = type + self.rules = rules + + +class BlobRestoreParameters(_serialization.Model): + """Blob restore parameters. + + All required parameters must be populated in order to send to Azure. + + :ivar time_to_restore: Restore blob to the specified time. Required. + :vartype time_to_restore: ~datetime.datetime + :ivar blob_ranges: Blob ranges to restore. Required. + :vartype blob_ranges: list[~azure.mgmt.storage.v2022_09_01.models.BlobRestoreRange] + """ + + _validation = { + "time_to_restore": {"required": True}, + "blob_ranges": {"required": True}, + } + + _attribute_map = { + "time_to_restore": {"key": "timeToRestore", "type": "iso-8601"}, + "blob_ranges": {"key": "blobRanges", "type": "[BlobRestoreRange]"}, + } + + def __init__(self, *, time_to_restore: datetime.datetime, blob_ranges: List["_models.BlobRestoreRange"], **kwargs): + """ + :keyword time_to_restore: Restore blob to the specified time. Required. + :paramtype time_to_restore: ~datetime.datetime + :keyword blob_ranges: Blob ranges to restore. Required. + :paramtype blob_ranges: list[~azure.mgmt.storage.v2022_09_01.models.BlobRestoreRange] + """ + super().__init__(**kwargs) + self.time_to_restore = time_to_restore + self.blob_ranges = blob_ranges + + +class BlobRestoreRange(_serialization.Model): + """Blob range. + + All required parameters must be populated in order to send to Azure. + + :ivar start_range: Blob start range. This is inclusive. Empty means account start. Required. + :vartype start_range: str + :ivar end_range: Blob end range. This is exclusive. Empty means account end. Required. + :vartype end_range: str + """ + + _validation = { + "start_range": {"required": True}, + "end_range": {"required": True}, + } + + _attribute_map = { + "start_range": {"key": "startRange", "type": "str"}, + "end_range": {"key": "endRange", "type": "str"}, + } + + def __init__(self, *, start_range: str, end_range: str, **kwargs): + """ + :keyword start_range: Blob start range. This is inclusive. Empty means account start. Required. + :paramtype start_range: str + :keyword end_range: Blob end range. This is exclusive. Empty means account end. Required. + :paramtype end_range: str + """ + super().__init__(**kwargs) + self.start_range = start_range + self.end_range = end_range + + +class BlobRestoreStatus(_serialization.Model): + """Blob restore status. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The status of blob restore progress. Possible values are: - InProgress: Indicates + that blob restore is ongoing. - Complete: Indicates that blob restore has been completed + successfully. - Failed: Indicates that blob restore is failed. Known values are: "InProgress", + "Complete", and "Failed". + :vartype status: str or ~azure.mgmt.storage.v2022_09_01.models.BlobRestoreProgressStatus + :ivar failure_reason: Failure reason when blob restore is failed. + :vartype failure_reason: str + :ivar restore_id: Id for tracking blob restore request. + :vartype restore_id: str + :ivar parameters: Blob restore request parameters. + :vartype parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobRestoreParameters + """ + + _validation = { + "status": {"readonly": True}, + "failure_reason": {"readonly": True}, + "restore_id": {"readonly": True}, + "parameters": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "failure_reason": {"key": "failureReason", "type": "str"}, + "restore_id": {"key": "restoreId", "type": "str"}, + "parameters": {"key": "parameters", "type": "BlobRestoreParameters"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.status = None + self.failure_reason = None + self.restore_id = None + self.parameters = None + + +class BlobServiceItems(_serialization.Model): + """BlobServiceItems. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blob services returned. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[BlobServiceProperties]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + + +class BlobServiceProperties(Resource): # pylint: disable=too-many-instance-attributes + """The properties of a storage account’s Blob service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar sku: Sku name and tier. + :vartype sku: ~azure.mgmt.storage.v2022_09_01.models.Sku + :ivar cors: Specifies CORS rules for the Blob service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Blob service. + :vartype cors: ~azure.mgmt.storage.v2022_09_01.models.CorsRules + :ivar default_service_version: DefaultServiceVersion indicates the default version to use for + requests to the Blob service if an incoming request’s version is not specified. Possible values + include version 2008-10-27 and all more recent versions. + :vartype default_service_version: str + :ivar delete_retention_policy: The blob service properties for blob soft delete. + :vartype delete_retention_policy: ~azure.mgmt.storage.v2022_09_01.models.DeleteRetentionPolicy + :ivar is_versioning_enabled: Versioning is enabled if set to true. + :vartype is_versioning_enabled: bool + :ivar automatic_snapshot_policy_enabled: Deprecated in favor of isVersioningEnabled property. + :vartype automatic_snapshot_policy_enabled: bool + :ivar change_feed: The blob service properties for change feed events. + :vartype change_feed: ~azure.mgmt.storage.v2022_09_01.models.ChangeFeed + :ivar restore_policy: The blob service properties for blob restore policy. + :vartype restore_policy: ~azure.mgmt.storage.v2022_09_01.models.RestorePolicyProperties + :ivar container_delete_retention_policy: The blob service properties for container soft delete. + :vartype container_delete_retention_policy: + ~azure.mgmt.storage.v2022_09_01.models.DeleteRetentionPolicy + :ivar last_access_time_tracking_policy: The blob service property to configure last access time + based tracking policy. + :vartype last_access_time_tracking_policy: + ~azure.mgmt.storage.v2022_09_01.models.LastAccessTimeTrackingPolicy + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "default_service_version": {"key": "properties.defaultServiceVersion", "type": "str"}, + "delete_retention_policy": {"key": "properties.deleteRetentionPolicy", "type": "DeleteRetentionPolicy"}, + "is_versioning_enabled": {"key": "properties.isVersioningEnabled", "type": "bool"}, + "automatic_snapshot_policy_enabled": {"key": "properties.automaticSnapshotPolicyEnabled", "type": "bool"}, + "change_feed": {"key": "properties.changeFeed", "type": "ChangeFeed"}, + "restore_policy": {"key": "properties.restorePolicy", "type": "RestorePolicyProperties"}, + "container_delete_retention_policy": { + "key": "properties.containerDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "last_access_time_tracking_policy": { + "key": "properties.lastAccessTimeTrackingPolicy", + "type": "LastAccessTimeTrackingPolicy", + }, + } + + def __init__( + self, + *, + cors: Optional["_models.CorsRules"] = None, + default_service_version: Optional[str] = None, + delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + is_versioning_enabled: Optional[bool] = None, + automatic_snapshot_policy_enabled: Optional[bool] = None, + change_feed: Optional["_models.ChangeFeed"] = None, + restore_policy: Optional["_models.RestorePolicyProperties"] = None, + container_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + last_access_time_tracking_policy: Optional["_models.LastAccessTimeTrackingPolicy"] = None, + **kwargs + ): + """ + :keyword cors: Specifies CORS rules for the Blob service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Blob service. + :paramtype cors: ~azure.mgmt.storage.v2022_09_01.models.CorsRules + :keyword default_service_version: DefaultServiceVersion indicates the default version to use + for requests to the Blob service if an incoming request’s version is not specified. Possible + values include version 2008-10-27 and all more recent versions. + :paramtype default_service_version: str + :keyword delete_retention_policy: The blob service properties for blob soft delete. + :paramtype delete_retention_policy: + ~azure.mgmt.storage.v2022_09_01.models.DeleteRetentionPolicy + :keyword is_versioning_enabled: Versioning is enabled if set to true. + :paramtype is_versioning_enabled: bool + :keyword automatic_snapshot_policy_enabled: Deprecated in favor of isVersioningEnabled + property. + :paramtype automatic_snapshot_policy_enabled: bool + :keyword change_feed: The blob service properties for change feed events. + :paramtype change_feed: ~azure.mgmt.storage.v2022_09_01.models.ChangeFeed + :keyword restore_policy: The blob service properties for blob restore policy. + :paramtype restore_policy: ~azure.mgmt.storage.v2022_09_01.models.RestorePolicyProperties + :keyword container_delete_retention_policy: The blob service properties for container soft + delete. + :paramtype container_delete_retention_policy: + ~azure.mgmt.storage.v2022_09_01.models.DeleteRetentionPolicy + :keyword last_access_time_tracking_policy: The blob service property to configure last access + time based tracking policy. + :paramtype last_access_time_tracking_policy: + ~azure.mgmt.storage.v2022_09_01.models.LastAccessTimeTrackingPolicy + """ + super().__init__(**kwargs) + self.sku = None + self.cors = cors + self.default_service_version = default_service_version + self.delete_retention_policy = delete_retention_policy + self.is_versioning_enabled = is_versioning_enabled + self.automatic_snapshot_policy_enabled = automatic_snapshot_policy_enabled + self.change_feed = change_feed + self.restore_policy = restore_policy + self.container_delete_retention_policy = container_delete_retention_policy + self.last_access_time_tracking_policy = last_access_time_tracking_policy + + +class ChangeFeed(_serialization.Model): + """The blob service properties for change feed events. + + :ivar enabled: Indicates whether change feed event logging is enabled for the Blob service. + :vartype enabled: bool + :ivar retention_in_days: Indicates the duration of changeFeed retention in days. Minimum value + is 1 day and maximum value is 146000 days (400 years). A null value indicates an infinite + retention of the change feed. + :vartype retention_in_days: int + """ + + _validation = { + "retention_in_days": {"maximum": 146000, "minimum": 1}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "retention_in_days": {"key": "retentionInDays", "type": "int"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, retention_in_days: Optional[int] = None, **kwargs): + """ + :keyword enabled: Indicates whether change feed event logging is enabled for the Blob service. + :paramtype enabled: bool + :keyword retention_in_days: Indicates the duration of changeFeed retention in days. Minimum + value is 1 day and maximum value is 146000 days (400 years). A null value indicates an infinite + retention of the change feed. + :paramtype retention_in_days: int + """ + super().__init__(**kwargs) + self.enabled = enabled + self.retention_in_days = retention_in_days + + +class CheckNameAvailabilityResult(_serialization.Model): + """The CheckNameAvailability operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: Gets a boolean value that indicates whether the name is available for you + to use. If true, the name is available. If false, the name has already been taken or is invalid + and cannot be used. + :vartype name_available: bool + :ivar reason: Gets the reason that a storage account name could not be used. The Reason element + is only returned if NameAvailable is false. Known values are: "AccountNameInvalid" and + "AlreadyExists". + :vartype reason: str or ~azure.mgmt.storage.v2022_09_01.models.Reason + :ivar message: Gets an error message explaining the Reason value in more detail. + :vartype message: str + """ + + _validation = { + "name_available": {"readonly": True}, + "reason": {"readonly": True}, + "message": {"readonly": True}, + } + + _attribute_map = { + "name_available": {"key": "nameAvailable", "type": "bool"}, + "reason": {"key": "reason", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name_available = None + self.reason = None + self.message = None + + +class CloudErrorBody(_serialization.Model): + """An error response from the Storage service. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in + error. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.storage.v2022_09_01.models.CloudErrorBody] + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + "target": {"key": "target", "type": "str"}, + "details": {"key": "details", "type": "[CloudErrorBody]"}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["_models.CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.storage.v2022_09_01.models.CloudErrorBody] + """ + super().__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class CorsRule(_serialization.Model): + """Specifies a CORS rule for the Blob service. + + All required parameters must be populated in order to send to Azure. + + :ivar allowed_origins: Required if CorsRule element is present. A list of origin domains that + will be allowed via CORS, or "*" to allow all domains. Required. + :vartype allowed_origins: list[str] + :ivar allowed_methods: Required if CorsRule element is present. A list of HTTP methods that are + allowed to be executed by the origin. Required. + :vartype allowed_methods: list[str or ~azure.mgmt.storage.v2022_09_01.models.AllowedMethods] + :ivar max_age_in_seconds: Required if CorsRule element is present. The number of seconds that + the client/browser should cache a preflight response. Required. + :vartype max_age_in_seconds: int + :ivar exposed_headers: Required if CorsRule element is present. A list of response headers to + expose to CORS clients. Required. + :vartype exposed_headers: list[str] + :ivar allowed_headers: Required if CorsRule element is present. A list of headers allowed to be + part of the cross-origin request. Required. + :vartype allowed_headers: list[str] + """ + + _validation = { + "allowed_origins": {"required": True}, + "allowed_methods": {"required": True}, + "max_age_in_seconds": {"required": True}, + "exposed_headers": {"required": True}, + "allowed_headers": {"required": True}, + } + + _attribute_map = { + "allowed_origins": {"key": "allowedOrigins", "type": "[str]"}, + "allowed_methods": {"key": "allowedMethods", "type": "[str]"}, + "max_age_in_seconds": {"key": "maxAgeInSeconds", "type": "int"}, + "exposed_headers": {"key": "exposedHeaders", "type": "[str]"}, + "allowed_headers": {"key": "allowedHeaders", "type": "[str]"}, + } + + def __init__( + self, + *, + allowed_origins: List[str], + allowed_methods: List[Union[str, "_models.AllowedMethods"]], + max_age_in_seconds: int, + exposed_headers: List[str], + allowed_headers: List[str], + **kwargs + ): + """ + :keyword allowed_origins: Required if CorsRule element is present. A list of origin domains + that will be allowed via CORS, or "*" to allow all domains. Required. + :paramtype allowed_origins: list[str] + :keyword allowed_methods: Required if CorsRule element is present. A list of HTTP methods that + are allowed to be executed by the origin. Required. + :paramtype allowed_methods: list[str or ~azure.mgmt.storage.v2022_09_01.models.AllowedMethods] + :keyword max_age_in_seconds: Required if CorsRule element is present. The number of seconds + that the client/browser should cache a preflight response. Required. + :paramtype max_age_in_seconds: int + :keyword exposed_headers: Required if CorsRule element is present. A list of response headers + to expose to CORS clients. Required. + :paramtype exposed_headers: list[str] + :keyword allowed_headers: Required if CorsRule element is present. A list of headers allowed to + be part of the cross-origin request. Required. + :paramtype allowed_headers: list[str] + """ + super().__init__(**kwargs) + self.allowed_origins = allowed_origins + self.allowed_methods = allowed_methods + self.max_age_in_seconds = max_age_in_seconds + self.exposed_headers = exposed_headers + self.allowed_headers = allowed_headers + + +class CorsRules(_serialization.Model): + """Sets the CORS rules. You can include up to five CorsRule elements in the request. + + :ivar cors_rules: The List of CORS rules. You can include up to five CorsRule elements in the + request. + :vartype cors_rules: list[~azure.mgmt.storage.v2022_09_01.models.CorsRule] + """ + + _attribute_map = { + "cors_rules": {"key": "corsRules", "type": "[CorsRule]"}, + } + + def __init__(self, *, cors_rules: Optional[List["_models.CorsRule"]] = None, **kwargs): + """ + :keyword cors_rules: The List of CORS rules. You can include up to five CorsRule elements in + the request. + :paramtype cors_rules: list[~azure.mgmt.storage.v2022_09_01.models.CorsRule] + """ + super().__init__(**kwargs) + self.cors_rules = cors_rules + + +class CustomDomain(_serialization.Model): + """The custom domain assigned to this storage account. This can be set via Update. + + All required parameters must be populated in order to send to Azure. + + :ivar name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. + :vartype name: str + :ivar use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default + value is false. This should only be set on updates. + :vartype use_sub_domain_name: bool + """ + + _validation = { + "name": {"required": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "use_sub_domain_name": {"key": "useSubDomainName", "type": "bool"}, + } + + def __init__(self, *, name: str, use_sub_domain_name: Optional[bool] = None, **kwargs): + """ + :keyword name: Gets or sets the custom domain name assigned to the storage account. Name is the + CNAME source. Required. + :paramtype name: str + :keyword use_sub_domain_name: Indicates whether indirect CName validation is enabled. Default + value is false. This should only be set on updates. + :paramtype use_sub_domain_name: bool + """ + super().__init__(**kwargs) + self.name = name + self.use_sub_domain_name = use_sub_domain_name + + +class DateAfterCreation(_serialization.Model): + """Object to define snapshot and version action conditions. + + All required parameters must be populated in order to send to Azure. + + :ivar days_after_creation_greater_than: Value indicating the age in days after creation. + Required. + :vartype days_after_creation_greater_than: float + :ivar days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterCreationGreaterThan to be set for snapshots and blob version based actions. The blob + will be archived if both the conditions are satisfied. + :vartype days_after_last_tier_change_greater_than: float + """ + + _validation = { + "days_after_creation_greater_than": {"required": True, "minimum": 0, "multiple": 1}, + "days_after_last_tier_change_greater_than": {"minimum": 0, "multiple": 1}, + } + + _attribute_map = { + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, + "days_after_last_tier_change_greater_than": {"key": "daysAfterLastTierChangeGreaterThan", "type": "float"}, + } + + def __init__( + self, + *, + days_after_creation_greater_than: float, + days_after_last_tier_change_greater_than: Optional[float] = None, + **kwargs + ): + """ + :keyword days_after_creation_greater_than: Value indicating the age in days after creation. + Required. + :paramtype days_after_creation_greater_than: float + :keyword days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterCreationGreaterThan to be set for snapshots and blob version based actions. The blob + will be archived if both the conditions are satisfied. + :paramtype days_after_last_tier_change_greater_than: float + """ + super().__init__(**kwargs) + self.days_after_creation_greater_than = days_after_creation_greater_than + self.days_after_last_tier_change_greater_than = days_after_last_tier_change_greater_than + + +class DateAfterModification(_serialization.Model): + """Object to define the base blob action conditions. Properties daysAfterModificationGreaterThan, daysAfterLastAccessTimeGreaterThan and daysAfterCreationGreaterThan are mutually exclusive. The daysAfterLastTierChangeGreaterThan property is only applicable for tierToArchive actions which requires daysAfterModificationGreaterThan to be set, also it cannot be used in conjunction with daysAfterLastAccessTimeGreaterThan or daysAfterCreationGreaterThan. + + :ivar days_after_modification_greater_than: Value indicating the age in days after last + modification. + :vartype days_after_modification_greater_than: float + :ivar days_after_last_access_time_greater_than: Value indicating the age in days after last + blob access. This property can only be used in conjunction with last access time tracking + policy. + :vartype days_after_last_access_time_greater_than: float + :ivar days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterModificationGreaterThan to be set for baseBlobs based actions. The blob will be + archived if both the conditions are satisfied. + :vartype days_after_last_tier_change_greater_than: float + :ivar days_after_creation_greater_than: Value indicating the age in days after blob creation. + :vartype days_after_creation_greater_than: float + """ + + _validation = { + "days_after_modification_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_access_time_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_last_tier_change_greater_than": {"minimum": 0, "multiple": 1}, + "days_after_creation_greater_than": {"minimum": 0, "multiple": 1}, + } + + _attribute_map = { + "days_after_modification_greater_than": {"key": "daysAfterModificationGreaterThan", "type": "float"}, + "days_after_last_access_time_greater_than": {"key": "daysAfterLastAccessTimeGreaterThan", "type": "float"}, + "days_after_last_tier_change_greater_than": {"key": "daysAfterLastTierChangeGreaterThan", "type": "float"}, + "days_after_creation_greater_than": {"key": "daysAfterCreationGreaterThan", "type": "float"}, + } + + def __init__( + self, + *, + days_after_modification_greater_than: Optional[float] = None, + days_after_last_access_time_greater_than: Optional[float] = None, + days_after_last_tier_change_greater_than: Optional[float] = None, + days_after_creation_greater_than: Optional[float] = None, + **kwargs + ): + """ + :keyword days_after_modification_greater_than: Value indicating the age in days after last + modification. + :paramtype days_after_modification_greater_than: float + :keyword days_after_last_access_time_greater_than: Value indicating the age in days after last + blob access. This property can only be used in conjunction with last access time tracking + policy. + :paramtype days_after_last_access_time_greater_than: float + :keyword days_after_last_tier_change_greater_than: Value indicating the age in days after last + blob tier change time. This property is only applicable for tierToArchive actions and requires + daysAfterModificationGreaterThan to be set for baseBlobs based actions. The blob will be + archived if both the conditions are satisfied. + :paramtype days_after_last_tier_change_greater_than: float + :keyword days_after_creation_greater_than: Value indicating the age in days after blob + creation. + :paramtype days_after_creation_greater_than: float + """ + super().__init__(**kwargs) + self.days_after_modification_greater_than = days_after_modification_greater_than + self.days_after_last_access_time_greater_than = days_after_last_access_time_greater_than + self.days_after_last_tier_change_greater_than = days_after_last_tier_change_greater_than + self.days_after_creation_greater_than = days_after_creation_greater_than + + +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. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + + +class DeletedAccount(ProxyResource): + """Deleted storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar storage_account_resource_id: Full resource id of the original storage account. + :vartype storage_account_resource_id: str + :ivar location: Location of the deleted account. + :vartype location: str + :ivar restore_reference: Can be used to attempt recovering this deleted account via + PutStorageAccount API. + :vartype restore_reference: str + :ivar creation_time: Creation time of the deleted account. + :vartype creation_time: str + :ivar deletion_time: Deletion time of the deleted account. + :vartype deletion_time: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "storage_account_resource_id": {"readonly": True}, + "location": {"readonly": True}, + "restore_reference": {"readonly": True}, + "creation_time": {"readonly": True}, + "deletion_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "storage_account_resource_id": {"key": "properties.storageAccountResourceId", "type": "str"}, + "location": {"key": "properties.location", "type": "str"}, + "restore_reference": {"key": "properties.restoreReference", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "str"}, + "deletion_time": {"key": "properties.deletionTime", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.storage_account_resource_id = None + self.location = None + self.restore_reference = None + self.creation_time = None + self.deletion_time = None + + +class DeletedAccountListResult(_serialization.Model): + """The response from the List Deleted Accounts operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets the list of deleted accounts and their properties. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.DeletedAccount] + :ivar next_link: Request URL that can be used to query next page of deleted accounts. Returned + when total number of requested deleted accounts exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[DeletedAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class DeletedShare(_serialization.Model): + """The deleted share to be restored. + + All required parameters must be populated in order to send to Azure. + + :ivar deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. + :vartype deleted_share_name: str + :ivar deleted_share_version: Required. Identify the version of the deleted share that will be + restored. Required. + :vartype deleted_share_version: str + """ + + _validation = { + "deleted_share_name": {"required": True}, + "deleted_share_version": {"required": True}, + } + + _attribute_map = { + "deleted_share_name": {"key": "deletedShareName", "type": "str"}, + "deleted_share_version": {"key": "deletedShareVersion", "type": "str"}, + } + + def __init__(self, *, deleted_share_name: str, deleted_share_version: str, **kwargs): + """ + :keyword deleted_share_name: Required. Identify the name of the deleted share that will be + restored. Required. + :paramtype deleted_share_name: str + :keyword deleted_share_version: Required. Identify the version of the deleted share that will + be restored. Required. + :paramtype deleted_share_version: str + """ + super().__init__(**kwargs) + self.deleted_share_name = deleted_share_name + self.deleted_share_version = deleted_share_version + + +class DeleteRetentionPolicy(_serialization.Model): + """The service properties for soft delete. + + :ivar enabled: Indicates whether DeleteRetentionPolicy is enabled. + :vartype enabled: bool + :ivar days: Indicates the number of days that the deleted item should be retained. The minimum + specified value can be 1 and the maximum value can be 365. + :vartype days: int + :ivar allow_permanent_delete: This property when set to true allows deletion of the soft + deleted blob versions and snapshots. This property cannot be used blob restore policy. This + property only applies to blob service and does not apply to containers or file share. + :vartype allow_permanent_delete: bool + """ + + _validation = { + "days": {"maximum": 365, "minimum": 1}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "allow_permanent_delete": {"key": "allowPermanentDelete", "type": "bool"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + days: Optional[int] = None, + allow_permanent_delete: Optional[bool] = None, + **kwargs + ): + """ + :keyword enabled: Indicates whether DeleteRetentionPolicy is enabled. + :paramtype enabled: bool + :keyword days: Indicates the number of days that the deleted item should be retained. The + minimum specified value can be 1 and the maximum value can be 365. + :paramtype days: int + :keyword allow_permanent_delete: This property when set to true allows deletion of the soft + deleted blob versions and snapshots. This property cannot be used blob restore policy. This + property only applies to blob service and does not apply to containers or file share. + :paramtype allow_permanent_delete: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + self.days = days + self.allow_permanent_delete = allow_permanent_delete + + +class Dimension(_serialization.Model): + """Dimension of blobs, possibly be blob type or access tier. + + :ivar name: Display name of dimension. + :vartype name: str + :ivar display_name: Display name of dimension. + :vartype display_name: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + } + + def __init__(self, *, name: Optional[str] = None, display_name: Optional[str] = None, **kwargs): + """ + :keyword name: Display name of dimension. + :paramtype name: str + :keyword display_name: Display name of dimension. + :paramtype display_name: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + + +class Encryption(_serialization.Model): + """The encryption settings on the storage account. + + :ivar services: List of services which support encryption. + :vartype services: ~azure.mgmt.storage.v2022_09_01.models.EncryptionServices + :ivar key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". + :vartype key_source: str or ~azure.mgmt.storage.v2022_09_01.models.KeySource + :ivar require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :vartype require_infrastructure_encryption: bool + :ivar key_vault_properties: Properties provided by key vault. + :vartype key_vault_properties: ~azure.mgmt.storage.v2022_09_01.models.KeyVaultProperties + :ivar encryption_identity: The identity to be used with service-side encryption at rest. + :vartype encryption_identity: ~azure.mgmt.storage.v2022_09_01.models.EncryptionIdentity + """ + + _attribute_map = { + "services": {"key": "services", "type": "EncryptionServices"}, + "key_source": {"key": "keySource", "type": "str"}, + "require_infrastructure_encryption": {"key": "requireInfrastructureEncryption", "type": "bool"}, + "key_vault_properties": {"key": "keyvaultproperties", "type": "KeyVaultProperties"}, + "encryption_identity": {"key": "identity", "type": "EncryptionIdentity"}, + } + + def __init__( + self, + *, + services: Optional["_models.EncryptionServices"] = None, + key_source: Union[str, "_models.KeySource"] = "Microsoft.Storage", + require_infrastructure_encryption: Optional[bool] = None, + key_vault_properties: Optional["_models.KeyVaultProperties"] = None, + encryption_identity: Optional["_models.EncryptionIdentity"] = None, + **kwargs + ): + """ + :keyword services: List of services which support encryption. + :paramtype services: ~azure.mgmt.storage.v2022_09_01.models.EncryptionServices + :keyword key_source: The encryption keySource (provider). Possible values (case-insensitive): + Microsoft.Storage, Microsoft.Keyvault. Known values are: "Microsoft.Storage" and + "Microsoft.Keyvault". + :paramtype key_source: str or ~azure.mgmt.storage.v2022_09_01.models.KeySource + :keyword require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :paramtype require_infrastructure_encryption: bool + :keyword key_vault_properties: Properties provided by key vault. + :paramtype key_vault_properties: ~azure.mgmt.storage.v2022_09_01.models.KeyVaultProperties + :keyword encryption_identity: The identity to be used with service-side encryption at rest. + :paramtype encryption_identity: ~azure.mgmt.storage.v2022_09_01.models.EncryptionIdentity + """ + super().__init__(**kwargs) + self.services = services + self.key_source = key_source + self.require_infrastructure_encryption = require_infrastructure_encryption + self.key_vault_properties = key_vault_properties + self.encryption_identity = encryption_identity + + +class EncryptionIdentity(_serialization.Model): + """Encryption identity for the storage account. + + :ivar encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to be + associated with server-side encryption on the storage account. + :vartype encryption_user_assigned_identity: str + :ivar encryption_federated_identity_client_id: ClientId of the multi-tenant application to be + used in conjunction with the user-assigned identity for cross-tenant customer-managed-keys + server-side encryption on the storage account. + :vartype encryption_federated_identity_client_id: str + """ + + _attribute_map = { + "encryption_user_assigned_identity": {"key": "userAssignedIdentity", "type": "str"}, + "encryption_federated_identity_client_id": {"key": "federatedIdentityClientId", "type": "str"}, + } + + def __init__( + self, + *, + encryption_user_assigned_identity: Optional[str] = None, + encryption_federated_identity_client_id: Optional[str] = None, + **kwargs + ): + """ + :keyword encryption_user_assigned_identity: Resource identifier of the UserAssigned identity to + be associated with server-side encryption on the storage account. + :paramtype encryption_user_assigned_identity: str + :keyword encryption_federated_identity_client_id: ClientId of the multi-tenant application to + be used in conjunction with the user-assigned identity for cross-tenant customer-managed-keys + server-side encryption on the storage account. + :paramtype encryption_federated_identity_client_id: str + """ + super().__init__(**kwargs) + self.encryption_user_assigned_identity = encryption_user_assigned_identity + self.encryption_federated_identity_client_id = encryption_federated_identity_client_id + + +class EncryptionScope(Resource): + """The Encryption Scope resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar source: The provider for the encryption scope. Possible values (case-insensitive): + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and + "Microsoft.KeyVault". + :vartype source: str or ~azure.mgmt.storage.v2022_09_01.models.EncryptionScopeSource + :ivar state: The state of the encryption scope. Possible values (case-insensitive): Enabled, + Disabled. Known values are: "Enabled" and "Disabled". + :vartype state: str or ~azure.mgmt.storage.v2022_09_01.models.EncryptionScopeState + :ivar creation_time: Gets the creation date and time of the encryption scope in UTC. + :vartype creation_time: ~datetime.datetime + :ivar last_modified_time: Gets the last modification date and time of the encryption scope in + UTC. + :vartype last_modified_time: ~datetime.datetime + :ivar key_vault_properties: The key vault properties for the encryption scope. This is a + required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. + :vartype key_vault_properties: + ~azure.mgmt.storage.v2022_09_01.models.EncryptionScopeKeyVaultProperties + :ivar require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :vartype require_infrastructure_encryption: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "creation_time": {"readonly": True}, + "last_modified_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "source": {"key": "properties.source", "type": "str"}, + "state": {"key": "properties.state", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "key_vault_properties": {"key": "properties.keyVaultProperties", "type": "EncryptionScopeKeyVaultProperties"}, + "require_infrastructure_encryption": {"key": "properties.requireInfrastructureEncryption", "type": "bool"}, + } + + def __init__( + self, + *, + source: Optional[Union[str, "_models.EncryptionScopeSource"]] = None, + state: Optional[Union[str, "_models.EncryptionScopeState"]] = None, + key_vault_properties: Optional["_models.EncryptionScopeKeyVaultProperties"] = None, + require_infrastructure_encryption: Optional[bool] = None, + **kwargs + ): + """ + :keyword source: The provider for the encryption scope. Possible values (case-insensitive): + Microsoft.Storage, Microsoft.KeyVault. Known values are: "Microsoft.Storage" and + "Microsoft.KeyVault". + :paramtype source: str or ~azure.mgmt.storage.v2022_09_01.models.EncryptionScopeSource + :keyword state: The state of the encryption scope. Possible values (case-insensitive): + Enabled, Disabled. Known values are: "Enabled" and "Disabled". + :paramtype state: str or ~azure.mgmt.storage.v2022_09_01.models.EncryptionScopeState + :keyword key_vault_properties: The key vault properties for the encryption scope. This is a + required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. + :paramtype key_vault_properties: + ~azure.mgmt.storage.v2022_09_01.models.EncryptionScopeKeyVaultProperties + :keyword require_infrastructure_encryption: A boolean indicating whether or not the service + applies a secondary layer of encryption with platform managed keys for data at rest. + :paramtype require_infrastructure_encryption: bool + """ + super().__init__(**kwargs) + self.source = source + self.state = state + self.creation_time = None + self.last_modified_time = None + self.key_vault_properties = key_vault_properties + self.require_infrastructure_encryption = require_infrastructure_encryption + + +class EncryptionScopeKeyVaultProperties(_serialization.Model): + """The key vault properties for the encryption scope. This is a required field if encryption scope 'source' attribute is set to 'Microsoft.KeyVault'. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key_uri: The object identifier for a key vault key object. When applied, the encryption + scope will use the key referenced by the identifier to enable customer-managed key support on + this encryption scope. + :vartype key_uri: str + :ivar current_versioned_key_identifier: The object identifier of the current versioned Key + Vault Key in use. + :vartype current_versioned_key_identifier: str + :ivar last_key_rotation_timestamp: Timestamp of last rotation of the Key Vault Key. + :vartype last_key_rotation_timestamp: ~datetime.datetime + """ + + _validation = { + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, + } + + _attribute_map = { + "key_uri": {"key": "keyUri", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, + } + + def __init__(self, *, key_uri: Optional[str] = None, **kwargs): + """ + :keyword key_uri: The object identifier for a key vault key object. When applied, the + encryption scope will use the key referenced by the identifier to enable customer-managed key + support on this encryption scope. + :paramtype key_uri: str + """ + super().__init__(**kwargs) + self.key_uri = key_uri + self.current_versioned_key_identifier = None + self.last_key_rotation_timestamp = None + + +class EncryptionScopeListResult(_serialization.Model): + """List of encryption scopes requested, and if paging is required, a URL to the next page of encryption scopes. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of encryption scopes requested. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.EncryptionScope] + :ivar next_link: Request URL that can be used to query next page of encryption scopes. Returned + when total number of requested encryption scopes exceeds the maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[EncryptionScope]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class EncryptionService(_serialization.Model): + """A service that allows server-side encryption to be used. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar enabled: A boolean indicating whether or not the service encrypts the data as it is + stored. Encryption at rest is enabled by default today and cannot be disabled. + :vartype enabled: bool + :ivar last_enabled_time: Gets a rough estimate of the date/time when the encryption was last + enabled by the user. Data is encrypted at rest by default today and cannot be disabled. + :vartype last_enabled_time: ~datetime.datetime + :ivar key_type: Encryption key type to be used for the encryption service. 'Account' key type + implies that an account-scoped encryption key will be used. 'Service' key type implies that a + default service key is used. Known values are: "Service" and "Account". + :vartype key_type: str or ~azure.mgmt.storage.v2022_09_01.models.KeyType + """ + + _validation = { + "last_enabled_time": {"readonly": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "key_type": {"key": "keyType", "type": "str"}, + } + + def __init__( + self, *, enabled: Optional[bool] = None, key_type: Optional[Union[str, "_models.KeyType"]] = None, **kwargs + ): + """ + :keyword enabled: A boolean indicating whether or not the service encrypts the data as it is + stored. Encryption at rest is enabled by default today and cannot be disabled. + :paramtype enabled: bool + :keyword key_type: Encryption key type to be used for the encryption service. 'Account' key + type implies that an account-scoped encryption key will be used. 'Service' key type implies + that a default service key is used. Known values are: "Service" and "Account". + :paramtype key_type: str or ~azure.mgmt.storage.v2022_09_01.models.KeyType + """ + super().__init__(**kwargs) + self.enabled = enabled + self.last_enabled_time = None + self.key_type = key_type + + +class EncryptionServices(_serialization.Model): + """A list of services that support encryption. + + :ivar blob: The encryption function of the blob storage service. + :vartype blob: ~azure.mgmt.storage.v2022_09_01.models.EncryptionService + :ivar file: The encryption function of the file storage service. + :vartype file: ~azure.mgmt.storage.v2022_09_01.models.EncryptionService + :ivar table: The encryption function of the table storage service. + :vartype table: ~azure.mgmt.storage.v2022_09_01.models.EncryptionService + :ivar queue: The encryption function of the queue storage service. + :vartype queue: ~azure.mgmt.storage.v2022_09_01.models.EncryptionService + """ + + _attribute_map = { + "blob": {"key": "blob", "type": "EncryptionService"}, + "file": {"key": "file", "type": "EncryptionService"}, + "table": {"key": "table", "type": "EncryptionService"}, + "queue": {"key": "queue", "type": "EncryptionService"}, + } + + def __init__( + self, + *, + blob: Optional["_models.EncryptionService"] = None, + file: Optional["_models.EncryptionService"] = None, + table: Optional["_models.EncryptionService"] = None, + queue: Optional["_models.EncryptionService"] = None, + **kwargs + ): + """ + :keyword blob: The encryption function of the blob storage service. + :paramtype blob: ~azure.mgmt.storage.v2022_09_01.models.EncryptionService + :keyword file: The encryption function of the file storage service. + :paramtype file: ~azure.mgmt.storage.v2022_09_01.models.EncryptionService + :keyword table: The encryption function of the table storage service. + :paramtype table: ~azure.mgmt.storage.v2022_09_01.models.EncryptionService + :keyword queue: The encryption function of the queue storage service. + :paramtype queue: ~azure.mgmt.storage.v2022_09_01.models.EncryptionService + """ + super().__init__(**kwargs) + self.blob = blob + self.file = file + self.table = table + self.queue = queue + + +class Endpoints(_serialization.Model): + """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar blob: Gets the blob endpoint. + :vartype blob: str + :ivar queue: Gets the queue endpoint. + :vartype queue: str + :ivar table: Gets the table endpoint. + :vartype table: str + :ivar file: Gets the file endpoint. + :vartype file: str + :ivar web: Gets the web endpoint. + :vartype web: str + :ivar dfs: Gets the dfs endpoint. + :vartype dfs: str + :ivar microsoft_endpoints: Gets the microsoft routing storage endpoints. + :vartype microsoft_endpoints: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountMicrosoftEndpoints + :ivar internet_endpoints: Gets the internet routing storage endpoints. + :vartype internet_endpoints: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountInternetEndpoints + """ + + _validation = { + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, + } + + _attribute_map = { + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + "microsoft_endpoints": {"key": "microsoftEndpoints", "type": "StorageAccountMicrosoftEndpoints"}, + "internet_endpoints": {"key": "internetEndpoints", "type": "StorageAccountInternetEndpoints"}, + } + + def __init__( + self, + *, + microsoft_endpoints: Optional["_models.StorageAccountMicrosoftEndpoints"] = None, + internet_endpoints: Optional["_models.StorageAccountInternetEndpoints"] = None, + **kwargs + ): + """ + :keyword microsoft_endpoints: Gets the microsoft routing storage endpoints. + :paramtype microsoft_endpoints: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountMicrosoftEndpoints + :keyword internet_endpoints: Gets the internet routing storage endpoints. + :paramtype internet_endpoints: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountInternetEndpoints + """ + super().__init__(**kwargs) + self.blob = None + self.queue = None + self.table = None + self.file = None + self.web = None + self.dfs = None + self.microsoft_endpoints = microsoft_endpoints + self.internet_endpoints = internet_endpoints + + +class ErrorResponse(_serialization.Model): + """An error response from the storage resource provider. + + :ivar error: Azure Storage Resource Provider error response body. + :vartype error: ~azure.mgmt.storage.v2022_09_01.models.ErrorResponseBody + """ + + _attribute_map = { + "error": {"key": "error", "type": "ErrorResponseBody"}, + } + + def __init__(self, *, error: Optional["_models.ErrorResponseBody"] = None, **kwargs): + """ + :keyword error: Azure Storage Resource Provider error response body. + :paramtype error: ~azure.mgmt.storage.v2022_09_01.models.ErrorResponseBody + """ + super().__init__(**kwargs) + self.error = error + + +class ErrorResponseBody(_serialization.Model): + """Error response body contract. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + """ + + _attribute_map = { + "code": {"key": "code", "type": "str"}, + "message": {"key": "message", "type": "str"}, + } + + def __init__(self, *, code: Optional[str] = None, message: Optional[str] = None, **kwargs): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + """ + super().__init__(**kwargs) + self.code = code + self.message = message + + +class ExtendedLocation(_serialization.Model): + """The complex type of the extended location. + + :ivar name: The name of the extended location. + :vartype name: str + :ivar type: The type of the extended location. "EdgeZone" + :vartype type: str or ~azure.mgmt.storage.v2022_09_01.models.ExtendedLocationTypes + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[Union[str, "_models.ExtendedLocationTypes"]] = None, + **kwargs + ): + """ + :keyword name: The name of the extended location. + :paramtype name: str + :keyword type: The type of the extended location. "EdgeZone" + :paramtype type: str or ~azure.mgmt.storage.v2022_09_01.models.ExtendedLocationTypes + """ + super().__init__(**kwargs) + self.name = name + self.type = type + + +class FileServiceItems(_serialization.Model): + """FileServiceItems. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of file services returned. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[FileServiceProperties]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + + +class FileServiceProperties(Resource): + """The properties of File services in storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar sku: Sku name and tier. + :vartype sku: ~azure.mgmt.storage.v2022_09_01.models.Sku + :ivar cors: Specifies CORS rules for the File service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the File service. + :vartype cors: ~azure.mgmt.storage.v2022_09_01.models.CorsRules + :ivar share_delete_retention_policy: The file service properties for share soft delete. + :vartype share_delete_retention_policy: + ~azure.mgmt.storage.v2022_09_01.models.DeleteRetentionPolicy + :ivar protocol_settings: Protocol settings for file service. + :vartype protocol_settings: ~azure.mgmt.storage.v2022_09_01.models.ProtocolSettings + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "sku": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + "share_delete_retention_policy": { + "key": "properties.shareDeleteRetentionPolicy", + "type": "DeleteRetentionPolicy", + }, + "protocol_settings": {"key": "properties.protocolSettings", "type": "ProtocolSettings"}, + } + + def __init__( + self, + *, + cors: Optional["_models.CorsRules"] = None, + share_delete_retention_policy: Optional["_models.DeleteRetentionPolicy"] = None, + protocol_settings: Optional["_models.ProtocolSettings"] = None, + **kwargs + ): + """ + :keyword cors: Specifies CORS rules for the File service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the File service. + :paramtype cors: ~azure.mgmt.storage.v2022_09_01.models.CorsRules + :keyword share_delete_retention_policy: The file service properties for share soft delete. + :paramtype share_delete_retention_policy: + ~azure.mgmt.storage.v2022_09_01.models.DeleteRetentionPolicy + :keyword protocol_settings: Protocol settings for file service. + :paramtype protocol_settings: ~azure.mgmt.storage.v2022_09_01.models.ProtocolSettings + """ + super().__init__(**kwargs) + self.sku = None + self.cors = cors + self.share_delete_retention_policy = share_delete_retention_policy + self.protocol_settings = protocol_settings + + +class FileShare(AzureEntityResource): # pylint: disable=too-many-instance-attributes + """Properties of the file share, including Id, resource name, resource type, Etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar last_modified_time: Returns the date and time the share was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar metadata: A name-value pair to associate with the share as metadata. + :vartype metadata: dict[str, str] + :ivar share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :vartype share_quota: int + :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only + be specified when creating a share. Known values are: "SMB" and "NFS". + :vartype enabled_protocols: str or ~azure.mgmt.storage.v2022_09_01.models.EnabledProtocols + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", and "AllSquash". + :vartype root_squash: str or ~azure.mgmt.storage.v2022_09_01.models.RootSquashType + :ivar version: The version of the share. + :vartype version: str + :ivar deleted: Indicates whether the share was deleted. + :vartype deleted: bool + :ivar deleted_time: The deleted time if the share was deleted. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. + :vartype remaining_retention_days: int + :ivar access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2022_09_01.models.ShareAccessTier + :ivar access_tier_change_time: Indicates the last modification time for share access tier. + :vartype access_tier_change_time: ~datetime.datetime + :ivar access_tier_status: Indicates if there is a pending transition for access tier. + :vartype access_tier_status: str + :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this + value may not include all recently created or recently resized files. + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseStatus + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", + "Expired", "Breaking", and "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, + only when the share is leased. Known values are: "Infinite" and "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseDuration + :ivar signed_identifiers: List of stored access policies specified on the share. + :vartype signed_identifiers: list[~azure.mgmt.storage.v2022_09_01.models.SignedIdentifier] + :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares + with expand param "snapshots". + :vartype snapshot_time: ~datetime.datetime + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + metadata: Optional[Dict[str, str]] = None, + share_quota: Optional[int] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, + **kwargs + ): + """ + :keyword metadata: A name-value pair to associate with the share as metadata. + :paramtype metadata: dict[str, str] + :keyword share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :paramtype share_quota: int + :keyword enabled_protocols: The authentication protocol that is used for the file share. Can + only be specified when creating a share. Known values are: "SMB" and "NFS". + :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2022_09_01.models.EnabledProtocols + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", and "AllSquash". + :paramtype root_squash: str or ~azure.mgmt.storage.v2022_09_01.models.RootSquashType + :keyword access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". + :paramtype access_tier: str or ~azure.mgmt.storage.v2022_09_01.models.ShareAccessTier + :keyword signed_identifiers: List of stored access policies specified on the share. + :paramtype signed_identifiers: list[~azure.mgmt.storage.v2022_09_01.models.SignedIdentifier] + """ + super().__init__(**kwargs) + self.last_modified_time = None + self.metadata = metadata + self.share_quota = share_quota + self.enabled_protocols = enabled_protocols + self.root_squash = root_squash + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.access_tier = access_tier + self.access_tier_change_time = None + self.access_tier_status = None + self.share_usage_bytes = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.signed_identifiers = signed_identifiers + self.snapshot_time = None + + +class FileShareItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes + """The file share properties be listed out. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar last_modified_time: Returns the date and time the share was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar metadata: A name-value pair to associate with the share as metadata. + :vartype metadata: dict[str, str] + :ivar share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :vartype share_quota: int + :ivar enabled_protocols: The authentication protocol that is used for the file share. Can only + be specified when creating a share. Known values are: "SMB" and "NFS". + :vartype enabled_protocols: str or ~azure.mgmt.storage.v2022_09_01.models.EnabledProtocols + :ivar root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", and "AllSquash". + :vartype root_squash: str or ~azure.mgmt.storage.v2022_09_01.models.RootSquashType + :ivar version: The version of the share. + :vartype version: str + :ivar deleted: Indicates whether the share was deleted. + :vartype deleted: bool + :ivar deleted_time: The deleted time if the share was deleted. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for share that was soft deleted. + :vartype remaining_retention_days: int + :ivar access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2022_09_01.models.ShareAccessTier + :ivar access_tier_change_time: Indicates the last modification time for share access tier. + :vartype access_tier_change_time: ~datetime.datetime + :ivar access_tier_status: Indicates if there is a pending transition for access tier. + :vartype access_tier_status: str + :ivar share_usage_bytes: The approximate size of the data stored on the share. Note that this + value may not include all recently created or recently resized files. + :vartype share_usage_bytes: int + :ivar lease_status: The lease status of the share. Known values are: "Locked" and "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseStatus + :ivar lease_state: Lease state of the share. Known values are: "Available", "Leased", + "Expired", "Breaking", and "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a share is of infinite or fixed duration, + only when the share is leased. Known values are: "Infinite" and "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseDuration + :ivar signed_identifiers: List of stored access policies specified on the share. + :vartype signed_identifiers: list[~azure.mgmt.storage.v2022_09_01.models.SignedIdentifier] + :ivar snapshot_time: Creation time of share snapshot returned in the response of list shares + with expand param "snapshots". + :vartype snapshot_time: ~datetime.datetime + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "share_quota": {"maximum": 102400, "minimum": 1}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "access_tier_change_time": {"readonly": True}, + "access_tier_status": {"readonly": True}, + "share_usage_bytes": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "snapshot_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "share_quota": {"key": "properties.shareQuota", "type": "int"}, + "enabled_protocols": {"key": "properties.enabledProtocols", "type": "str"}, + "root_squash": {"key": "properties.rootSquash", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "access_tier_change_time": {"key": "properties.accessTierChangeTime", "type": "iso-8601"}, + "access_tier_status": {"key": "properties.accessTierStatus", "type": "str"}, + "share_usage_bytes": {"key": "properties.shareUsageBytes", "type": "int"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[SignedIdentifier]"}, + "snapshot_time": {"key": "properties.snapshotTime", "type": "iso-8601"}, + } + + def __init__( + self, + *, + metadata: Optional[Dict[str, str]] = None, + share_quota: Optional[int] = None, + enabled_protocols: Optional[Union[str, "_models.EnabledProtocols"]] = None, + root_squash: Optional[Union[str, "_models.RootSquashType"]] = None, + access_tier: Optional[Union[str, "_models.ShareAccessTier"]] = None, + signed_identifiers: Optional[List["_models.SignedIdentifier"]] = None, + **kwargs + ): + """ + :keyword metadata: A name-value pair to associate with the share as metadata. + :paramtype metadata: dict[str, str] + :keyword share_quota: The maximum size of the share, in gigabytes. Must be greater than 0, and + less than or equal to 5TB (5120). For Large File Shares, the maximum size is 102400. + :paramtype share_quota: int + :keyword enabled_protocols: The authentication protocol that is used for the file share. Can + only be specified when creating a share. Known values are: "SMB" and "NFS". + :paramtype enabled_protocols: str or ~azure.mgmt.storage.v2022_09_01.models.EnabledProtocols + :keyword root_squash: The property is for NFS share only. The default is NoRootSquash. Known + values are: "NoRootSquash", "RootSquash", and "AllSquash". + :paramtype root_squash: str or ~azure.mgmt.storage.v2022_09_01.models.RootSquashType + :keyword access_tier: Access tier for specific share. GpV2 account can choose between + TransactionOptimized (default), Hot, and Cool. FileStorage account can choose Premium. Known + values are: "TransactionOptimized", "Hot", "Cool", and "Premium". + :paramtype access_tier: str or ~azure.mgmt.storage.v2022_09_01.models.ShareAccessTier + :keyword signed_identifiers: List of stored access policies specified on the share. + :paramtype signed_identifiers: list[~azure.mgmt.storage.v2022_09_01.models.SignedIdentifier] + """ + super().__init__(**kwargs) + self.last_modified_time = None + self.metadata = metadata + self.share_quota = share_quota + self.enabled_protocols = enabled_protocols + self.root_squash = root_squash + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.access_tier = access_tier + self.access_tier_change_time = None + self.access_tier_status = None + self.share_usage_bytes = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.signed_identifiers = signed_identifiers + self.snapshot_time = None + + +class FileShareItems(_serialization.Model): + """Response schema. Contains list of shares returned, and if paging is requested or required, a URL to next page of shares. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of file shares returned. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.FileShareItem] + :ivar next_link: Request URL that can be used to query next page of shares. Returned when total + number of requested shares exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[FileShareItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class GeoReplicationStats(_serialization.Model): + """Statistics related to replication for storage account's Blob, Table, Queue and File services. It is only available when geo-redundant replication is enabled for the storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar status: The status of the secondary location. Possible values are: - Live: Indicates that + the secondary location is active and operational. - Bootstrap: Indicates initial + synchronization from the primary location to the secondary location is in progress.This + typically occurs when replication is first enabled. - Unavailable: Indicates that the secondary + location is temporarily unavailable. Known values are: "Live", "Bootstrap", and "Unavailable". + :vartype status: str or ~azure.mgmt.storage.v2022_09_01.models.GeoReplicationStatus + :ivar last_sync_time: All primary writes preceding this UTC date/time value are guaranteed to + be available for read operations. Primary writes following this point in time may or may not be + available for reads. Element may be default value if value of LastSyncTime is not available, + this can happen if secondary is offline or we are in bootstrap. + :vartype last_sync_time: ~datetime.datetime + :ivar can_failover: A boolean flag which indicates whether or not account failover is supported + for the account. + :vartype can_failover: bool + """ + + _validation = { + "status": {"readonly": True}, + "last_sync_time": {"readonly": True}, + "can_failover": {"readonly": True}, + } + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "last_sync_time": {"key": "lastSyncTime", "type": "iso-8601"}, + "can_failover": {"key": "canFailover", "type": "bool"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.status = None + self.last_sync_time = None + self.can_failover = None + + +class Identity(_serialization.Model): + """Identity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar principal_id: The principal ID of resource identity. + :vartype principal_id: str + :ivar tenant_id: The tenant ID of resource. + :vartype tenant_id: str + :ivar type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". + :vartype type: str or ~azure.mgmt.storage.v2022_09_01.models.IdentityType + :ivar user_assigned_identities: Gets or sets a list of key value pairs that describe the set of + User Assigned identities that will be used with this storage account. The key is the ARM + resource identifier of the identity. Only 1 User Assigned identity is permitted here. + :vartype user_assigned_identities: dict[str, + ~azure.mgmt.storage.v2022_09_01.models.UserAssignedIdentity] + """ + + _validation = { + "principal_id": {"readonly": True}, + "tenant_id": {"readonly": True}, + "type": {"required": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "user_assigned_identities": {"key": "userAssignedIdentities", "type": "{UserAssignedIdentity}"}, + } + + def __init__( + self, + *, + type: Union[str, "_models.IdentityType"], + user_assigned_identities: Optional[Dict[str, "_models.UserAssignedIdentity"]] = None, + **kwargs + ): + """ + :keyword type: The identity type. Required. Known values are: "None", "SystemAssigned", + "UserAssigned", and "SystemAssigned,UserAssigned". + :paramtype type: str or ~azure.mgmt.storage.v2022_09_01.models.IdentityType + :keyword user_assigned_identities: Gets or sets a list of key value pairs that describe the set + of User Assigned identities that will be used with this storage account. The key is the ARM + resource identifier of the identity. Only 1 User Assigned identity is permitted here. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.storage.v2022_09_01.models.UserAssignedIdentity] + """ + super().__init__(**kwargs) + self.principal_id = None + self.tenant_id = None + self.type = type + self.user_assigned_identities = user_assigned_identities + + +class ImmutabilityPolicy(AzureEntityResource): + """The ImmutabilityPolicy property of a blob container, including Id, resource name, resource type, Etag. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked + and Unlocked. Known values are: "Locked" and "Unlocked". + :vartype state: str or ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicyState + :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based + retention policies. When enabled, new blocks can be written to an append blob while maintaining + immutability protection and compliance. Only new blocks can be added and any existing blocks + cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy + API. + :vartype allow_protected_append_writes: bool + :ivar allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, + } + + def __init__( + self, + *, + immutability_period_since_creation_in_days: Optional[int] = None, + allow_protected_append_writes: Optional[bool] = None, + allow_protected_append_writes_all: Optional[bool] = None, + **kwargs + ): + """ + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. + :paramtype immutability_period_since_creation_in_days: int + :keyword allow_protected_append_writes: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to an append blob while + maintaining immutability protection and compliance. Only new blocks can be added and any + existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. + :paramtype allow_protected_append_writes: bool + :keyword allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :paramtype allow_protected_append_writes_all: bool + """ + super().__init__(**kwargs) + self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days + self.state = None + self.allow_protected_append_writes = allow_protected_append_writes + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class ImmutabilityPolicyProperties(_serialization.Model): + """The properties of an ImmutabilityPolicy of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar etag: ImmutabilityPolicy Etag. + :vartype etag: str + :ivar update_history: The ImmutabilityPolicy update history of the blob container. + :vartype update_history: list[~azure.mgmt.storage.v2022_09_01.models.UpdateHistoryProperty] + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar state: The ImmutabilityPolicy state of a blob container, possible values include: Locked + and Unlocked. Known values are: "Locked" and "Unlocked". + :vartype state: str or ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicyState + :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based + retention policies. When enabled, new blocks can be written to an append blob while maintaining + immutability protection and compliance. Only new blocks can be added and any existing blocks + cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy + API. + :vartype allow_protected_append_writes: bool + :ivar allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + "etag": {"readonly": True}, + "update_history": {"readonly": True}, + "state": {"readonly": True}, + } + + _attribute_map = { + "etag": {"key": "etag", "type": "str"}, + "update_history": {"key": "updateHistory", "type": "[UpdateHistoryProperty]"}, + "immutability_period_since_creation_in_days": { + "key": "properties.immutabilityPeriodSinceCreationInDays", + "type": "int", + }, + "state": {"key": "properties.state", "type": "str"}, + "allow_protected_append_writes": {"key": "properties.allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "properties.allowProtectedAppendWritesAll", "type": "bool"}, + } + + def __init__( + self, + *, + immutability_period_since_creation_in_days: Optional[int] = None, + allow_protected_append_writes: Optional[bool] = None, + allow_protected_append_writes_all: Optional[bool] = None, + **kwargs + ): + """ + :keyword immutability_period_since_creation_in_days: The immutability period for the blobs in + the container since the policy creation, in days. + :paramtype immutability_period_since_creation_in_days: int + :keyword allow_protected_append_writes: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to an append blob while + maintaining immutability protection and compliance. Only new blocks can be added and any + existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. + :paramtype allow_protected_append_writes: bool + :keyword allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :paramtype allow_protected_append_writes_all: bool + """ + super().__init__(**kwargs) + self.etag = None + self.update_history = None + self.immutability_period_since_creation_in_days = immutability_period_since_creation_in_days + self.state = None + self.allow_protected_append_writes = allow_protected_append_writes + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class ImmutableStorageAccount(_serialization.Model): + """This property enables and defines account-level immutability. Enabling the feature auto-enables Blob Versioning. + + :ivar enabled: A boolean flag which enables account-level immutability. All the containers + under such an account have object-level immutability enabled by default. + :vartype enabled: bool + :ivar immutability_policy: Specifies the default account-level immutability policy which is + inherited and applied to objects that do not possess an explicit immutability policy at the + object level. The object-level immutability policy has higher precedence than the + container-level immutability policy, which has a higher precedence than the account-level + immutability policy. + :vartype immutability_policy: + ~azure.mgmt.storage.v2022_09_01.models.AccountImmutabilityPolicyProperties + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "immutability_policy": {"key": "immutabilityPolicy", "type": "AccountImmutabilityPolicyProperties"}, + } + + def __init__( + self, + *, + enabled: Optional[bool] = None, + immutability_policy: Optional["_models.AccountImmutabilityPolicyProperties"] = None, + **kwargs + ): + """ + :keyword enabled: A boolean flag which enables account-level immutability. All the containers + under such an account have object-level immutability enabled by default. + :paramtype enabled: bool + :keyword immutability_policy: Specifies the default account-level immutability policy which is + inherited and applied to objects that do not possess an explicit immutability policy at the + object level. The object-level immutability policy has higher precedence than the + container-level immutability policy, which has a higher precedence than the account-level + immutability policy. + :paramtype immutability_policy: + ~azure.mgmt.storage.v2022_09_01.models.AccountImmutabilityPolicyProperties + """ + super().__init__(**kwargs) + self.enabled = enabled + self.immutability_policy = immutability_policy + + +class ImmutableStorageWithVersioning(_serialization.Model): + """Object level immutability properties of the container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar enabled: This is an immutable property, when set to true it enables object level + immutability at the container level. + :vartype enabled: bool + :ivar time_stamp: Returns the date and time the object level immutability was enabled. + :vartype time_stamp: ~datetime.datetime + :ivar migration_state: This property denotes the container level immutability to object level + immutability migration state. Known values are: "InProgress" and "Completed". + :vartype migration_state: str or ~azure.mgmt.storage.v2022_09_01.models.MigrationState + """ + + _validation = { + "time_stamp": {"readonly": True}, + "migration_state": {"readonly": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "time_stamp": {"key": "timeStamp", "type": "iso-8601"}, + "migration_state": {"key": "migrationState", "type": "str"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): + """ + :keyword enabled: This is an immutable property, when set to true it enables object level + immutability at the container level. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + self.time_stamp = None + self.migration_state = None + + +class IPRule(_serialization.Model): + """IP rule with specific IP or IP range in CIDR format. + + All required parameters must be populated in order to send to Azure. + + :ivar ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. + :vartype ip_address_or_range: str + :ivar action: The action of IP ACL rule. Default value is "Allow". + :vartype action: str + """ + + _validation = { + "ip_address_or_range": {"required": True}, + } + + _attribute_map = { + "ip_address_or_range": {"key": "value", "type": "str"}, + "action": {"key": "action", "type": "str"}, + } + + def __init__(self, *, ip_address_or_range: str, action: Optional[Literal["Allow"]] = None, **kwargs): + """ + :keyword ip_address_or_range: Specifies the IP or IP range in CIDR format. Only IPV4 address is + allowed. Required. + :paramtype ip_address_or_range: str + :keyword action: The action of IP ACL rule. Default value is "Allow". + :paramtype action: str + """ + super().__init__(**kwargs) + self.ip_address_or_range = ip_address_or_range + self.action = action + + +class KeyCreationTime(_serialization.Model): + """Storage account keys creation time. + + :ivar key1: + :vartype key1: ~datetime.datetime + :ivar key2: + :vartype key2: ~datetime.datetime + """ + + _attribute_map = { + "key1": {"key": "key1", "type": "iso-8601"}, + "key2": {"key": "key2", "type": "iso-8601"}, + } + + def __init__(self, *, key1: Optional[datetime.datetime] = None, key2: Optional[datetime.datetime] = None, **kwargs): + """ + :keyword key1: + :paramtype key1: ~datetime.datetime + :keyword key2: + :paramtype key2: ~datetime.datetime + """ + super().__init__(**kwargs) + self.key1 = key1 + self.key2 = key2 + + +class KeyPolicy(_serialization.Model): + """KeyPolicy assigned to the storage account. + + All required parameters must be populated in order to send to Azure. + + :ivar key_expiration_period_in_days: The key expiration period in days. Required. + :vartype key_expiration_period_in_days: int + """ + + _validation = { + "key_expiration_period_in_days": {"required": True}, + } + + _attribute_map = { + "key_expiration_period_in_days": {"key": "keyExpirationPeriodInDays", "type": "int"}, + } + + def __init__(self, *, key_expiration_period_in_days: int, **kwargs): + """ + :keyword key_expiration_period_in_days: The key expiration period in days. Required. + :paramtype key_expiration_period_in_days: int + """ + super().__init__(**kwargs) + self.key_expiration_period_in_days = key_expiration_period_in_days + + +class KeyVaultProperties(_serialization.Model): + """Properties of key vault. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key_name: The name of KeyVault key. + :vartype key_name: str + :ivar key_version: The version of KeyVault key. + :vartype key_version: str + :ivar key_vault_uri: The Uri of KeyVault. + :vartype key_vault_uri: str + :ivar current_versioned_key_identifier: The object identifier of the current versioned Key + Vault Key in use. + :vartype current_versioned_key_identifier: str + :ivar last_key_rotation_timestamp: Timestamp of last rotation of the Key Vault Key. + :vartype last_key_rotation_timestamp: ~datetime.datetime + :ivar current_versioned_key_expiration_timestamp: This is a read only property that represents + the expiration time of the current version of the customer managed key used for encryption. + :vartype current_versioned_key_expiration_timestamp: ~datetime.datetime + """ + + _validation = { + "current_versioned_key_identifier": {"readonly": True}, + "last_key_rotation_timestamp": {"readonly": True}, + "current_versioned_key_expiration_timestamp": {"readonly": True}, + } + + _attribute_map = { + "key_name": {"key": "keyname", "type": "str"}, + "key_version": {"key": "keyversion", "type": "str"}, + "key_vault_uri": {"key": "keyvaulturi", "type": "str"}, + "current_versioned_key_identifier": {"key": "currentVersionedKeyIdentifier", "type": "str"}, + "last_key_rotation_timestamp": {"key": "lastKeyRotationTimestamp", "type": "iso-8601"}, + "current_versioned_key_expiration_timestamp": { + "key": "currentVersionedKeyExpirationTimestamp", + "type": "iso-8601", + }, + } + + def __init__( + self, + *, + key_name: Optional[str] = None, + key_version: Optional[str] = None, + key_vault_uri: Optional[str] = None, + **kwargs + ): + """ + :keyword key_name: The name of KeyVault key. + :paramtype key_name: str + :keyword key_version: The version of KeyVault key. + :paramtype key_version: str + :keyword key_vault_uri: The Uri of KeyVault. + :paramtype key_vault_uri: str + """ + super().__init__(**kwargs) + self.key_name = key_name + self.key_version = key_version + self.key_vault_uri = key_vault_uri + self.current_versioned_key_identifier = None + self.last_key_rotation_timestamp = None + self.current_versioned_key_expiration_timestamp = None + + +class LastAccessTimeTrackingPolicy(_serialization.Model): + """The blob service properties for Last access time based tracking policy. + + All required parameters must be populated in order to send to Azure. + + :ivar enable: When set to true last access time based tracking is enabled. Required. + :vartype enable: bool + :ivar name: Name of the policy. The valid value is AccessTimeTracking. This field is currently + read only. "AccessTimeTracking" + :vartype name: str or ~azure.mgmt.storage.v2022_09_01.models.Name + :ivar tracking_granularity_in_days: The field specifies blob object tracking granularity in + days, typically how often the blob object should be tracked.This field is currently read only + with value as 1. + :vartype tracking_granularity_in_days: int + :ivar blob_type: An array of predefined supported blob types. Only blockBlob is the supported + value. This field is currently read only. + :vartype blob_type: list[str] + """ + + _validation = { + "enable": {"required": True}, + } + + _attribute_map = { + "enable": {"key": "enable", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "tracking_granularity_in_days": {"key": "trackingGranularityInDays", "type": "int"}, + "blob_type": {"key": "blobType", "type": "[str]"}, + } + + def __init__( + self, + *, + enable: bool, + name: Optional[Union[str, "_models.Name"]] = None, + tracking_granularity_in_days: Optional[int] = None, + blob_type: Optional[List[str]] = None, + **kwargs + ): + """ + :keyword enable: When set to true last access time based tracking is enabled. Required. + :paramtype enable: bool + :keyword name: Name of the policy. The valid value is AccessTimeTracking. This field is + currently read only. "AccessTimeTracking" + :paramtype name: str or ~azure.mgmt.storage.v2022_09_01.models.Name + :keyword tracking_granularity_in_days: The field specifies blob object tracking granularity in + days, typically how often the blob object should be tracked.This field is currently read only + with value as 1. + :paramtype tracking_granularity_in_days: int + :keyword blob_type: An array of predefined supported blob types. Only blockBlob is the + supported value. This field is currently read only. + :paramtype blob_type: list[str] + """ + super().__init__(**kwargs) + self.enable = enable + self.name = name + self.tracking_granularity_in_days = tracking_granularity_in_days + self.blob_type = blob_type + + +class LeaseContainerRequest(_serialization.Model): + """Lease Container request schema. + + All required parameters must be populated in order to send to Azure. + + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". + :vartype action: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequestEnum + :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :vartype lease_id: str + :ivar break_period: Optional. For a break action, proposed duration the lease should continue + before it is broken, in seconds, between 0 and 60. + :vartype break_period: int + :ivar lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, or + negative one (-1) for a lease that never expires. + :vartype lease_duration: int + :ivar proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :vartype proposed_lease_id: str + """ + + _validation = { + "action": {"required": True}, + } + + _attribute_map = { + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, + } + + def __init__( + self, + *, + action: Union[str, "_models.LeaseContainerRequestEnum"], + lease_id: Optional[str] = None, + break_period: Optional[int] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + **kwargs + ): + """ + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". + :paramtype action: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequestEnum + :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :paramtype lease_id: str + :keyword break_period: Optional. For a break action, proposed duration the lease should + continue before it is broken, in seconds, between 0 and 60. + :paramtype break_period: int + :keyword lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, + or negative one (-1) for a lease that never expires. + :paramtype lease_duration: int + :keyword proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :paramtype proposed_lease_id: str + """ + super().__init__(**kwargs) + self.action = action + self.lease_id = lease_id + self.break_period = break_period + self.lease_duration = lease_duration + self.proposed_lease_id = proposed_lease_id + + +class LeaseContainerResponse(_serialization.Model): + """Lease Container response schema. + + :ivar lease_id: Returned unique lease ID that must be included with any request to delete the + container, or to renew, change, or release the lease. + :vartype lease_id: str + :ivar lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :vartype lease_time_seconds: str + """ + + _attribute_map = { + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, + } + + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): + """ + :keyword lease_id: Returned unique lease ID that must be included with any request to delete + the container, or to renew, change, or release the lease. + :paramtype lease_id: str + :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :paramtype lease_time_seconds: str + """ + super().__init__(**kwargs) + self.lease_id = lease_id + self.lease_time_seconds = lease_time_seconds + + +class LeaseShareRequest(_serialization.Model): + """Lease Share request schema. + + All required parameters must be populated in order to send to Azure. + + :ivar action: Specifies the lease action. Can be one of the available actions. Required. Known + values are: "Acquire", "Renew", "Change", "Release", and "Break". + :vartype action: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseShareAction + :ivar lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :vartype lease_id: str + :ivar break_period: Optional. For a break action, proposed duration the lease should continue + before it is broken, in seconds, between 0 and 60. + :vartype break_period: int + :ivar lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, or + negative one (-1) for a lease that never expires. + :vartype lease_duration: int + :ivar proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :vartype proposed_lease_id: str + """ + + _validation = { + "action": {"required": True}, + } + + _attribute_map = { + "action": {"key": "action", "type": "str"}, + "lease_id": {"key": "leaseId", "type": "str"}, + "break_period": {"key": "breakPeriod", "type": "int"}, + "lease_duration": {"key": "leaseDuration", "type": "int"}, + "proposed_lease_id": {"key": "proposedLeaseId", "type": "str"}, + } + + def __init__( + self, + *, + action: Union[str, "_models.LeaseShareAction"], + lease_id: Optional[str] = None, + break_period: Optional[int] = None, + lease_duration: Optional[int] = None, + proposed_lease_id: Optional[str] = None, + **kwargs + ): + """ + :keyword action: Specifies the lease action. Can be one of the available actions. Required. + Known values are: "Acquire", "Renew", "Change", "Release", and "Break". + :paramtype action: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseShareAction + :keyword lease_id: Identifies the lease. Can be specified in any valid GUID string format. + :paramtype lease_id: str + :keyword break_period: Optional. For a break action, proposed duration the lease should + continue before it is broken, in seconds, between 0 and 60. + :paramtype break_period: int + :keyword lease_duration: Required for acquire. Specifies the duration of the lease, in seconds, + or negative one (-1) for a lease that never expires. + :paramtype lease_duration: int + :keyword proposed_lease_id: Optional for acquire, required for change. Proposed lease ID, in a + GUID string format. + :paramtype proposed_lease_id: str + """ + super().__init__(**kwargs) + self.action = action + self.lease_id = lease_id + self.break_period = break_period + self.lease_duration = lease_duration + self.proposed_lease_id = proposed_lease_id + + +class LeaseShareResponse(_serialization.Model): + """Lease Share response schema. + + :ivar lease_id: Returned unique lease ID that must be included with any request to delete the + share, or to renew, change, or release the lease. + :vartype lease_id: str + :ivar lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :vartype lease_time_seconds: str + """ + + _attribute_map = { + "lease_id": {"key": "leaseId", "type": "str"}, + "lease_time_seconds": {"key": "leaseTimeSeconds", "type": "str"}, + } + + def __init__(self, *, lease_id: Optional[str] = None, lease_time_seconds: Optional[str] = None, **kwargs): + """ + :keyword lease_id: Returned unique lease ID that must be included with any request to delete + the share, or to renew, change, or release the lease. + :paramtype lease_id: str + :keyword lease_time_seconds: Approximate time remaining in the lease period, in seconds. + :paramtype lease_time_seconds: str + """ + super().__init__(**kwargs) + self.lease_id = lease_id + self.lease_time_seconds = lease_time_seconds + + +class LegalHold(_serialization.Model): + """The LegalHold property of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower case + at SRP. Required. + :vartype tags: list[str] + :ivar allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + "has_legal_hold": {"readonly": True}, + "tags": {"required": True}, + } + + _attribute_map = { + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[str]"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, + } + + def __init__(self, *, tags: List[str], allow_protected_append_writes_all: Optional[bool] = None, **kwargs): + """ + :keyword tags: Each tag should be 3 to 23 alphanumeric characters and is normalized to lower + case at SRP. Required. + :paramtype tags: list[str] + :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :paramtype allow_protected_append_writes_all: bool + """ + super().__init__(**kwargs) + self.has_legal_hold = None + self.tags = tags + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class LegalHoldProperties(_serialization.Model): + """The LegalHold property of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar tags: The list of LegalHold tags of a blob container. + :vartype tags: list[~azure.mgmt.storage.v2022_09_01.models.TagProperty] + :ivar protected_append_writes_history: Protected append blob writes history. + :vartype protected_append_writes_history: + ~azure.mgmt.storage.v2022_09_01.models.ProtectedAppendWritesHistory + """ + + _validation = { + "has_legal_hold": {"readonly": True}, + } + + _attribute_map = { + "has_legal_hold": {"key": "hasLegalHold", "type": "bool"}, + "tags": {"key": "tags", "type": "[TagProperty]"}, + "protected_append_writes_history": { + "key": "protectedAppendWritesHistory", + "type": "ProtectedAppendWritesHistory", + }, + } + + def __init__( + self, + *, + tags: Optional[List["_models.TagProperty"]] = None, + protected_append_writes_history: Optional["_models.ProtectedAppendWritesHistory"] = None, + **kwargs + ): + """ + :keyword tags: The list of LegalHold tags of a blob container. + :paramtype tags: list[~azure.mgmt.storage.v2022_09_01.models.TagProperty] + :keyword protected_append_writes_history: Protected append blob writes history. + :paramtype protected_append_writes_history: + ~azure.mgmt.storage.v2022_09_01.models.ProtectedAppendWritesHistory + """ + super().__init__(**kwargs) + self.has_legal_hold = None + self.tags = tags + self.protected_append_writes_history = protected_append_writes_history + + +class ListAccountSasResponse(_serialization.Model): + """The List SAS credentials operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar account_sas_token: List SAS credentials of storage account. + :vartype account_sas_token: str + """ + + _validation = { + "account_sas_token": {"readonly": True}, + } + + _attribute_map = { + "account_sas_token": {"key": "accountSasToken", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.account_sas_token = None + + +class ListBlobInventoryPolicy(_serialization.Model): + """List of blob inventory policies returned. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blob inventory policies. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[BlobInventoryPolicy]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + + +class ListContainerItem(AzureEntityResource): # pylint: disable=too-many-instance-attributes + """The blob container properties be listed out. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar etag: Resource Etag. + :vartype etag: str + :ivar version: The version of the deleted blob container. + :vartype version: str + :ivar deleted: Indicates whether the blob container was deleted. + :vartype deleted: bool + :ivar deleted_time: Blob container deletion time. + :vartype deleted_time: ~datetime.datetime + :ivar remaining_retention_days: Remaining retention days for soft deleted blob container. + :vartype remaining_retention_days: int + :ivar default_encryption_scope: Default the container to use specified encryption scope for all + writes. + :vartype default_encryption_scope: str + :ivar deny_encryption_scope_override: Block override of encryption scope from the container + default. + :vartype deny_encryption_scope_override: bool + :ivar public_access: Specifies whether data in the container may be accessed publicly and the + level of access. Known values are: "Container", "Blob", and "None". + :vartype public_access: str or ~azure.mgmt.storage.v2022_09_01.models.PublicAccess + :ivar last_modified_time: Returns the date and time the container was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar lease_status: The lease status of the container. Known values are: "Locked" and + "Unlocked". + :vartype lease_status: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseStatus + :ivar lease_state: Lease state of the container. Known values are: "Available", "Leased", + "Expired", "Breaking", and "Broken". + :vartype lease_state: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseState + :ivar lease_duration: Specifies whether the lease on a container is of infinite or fixed + duration, only when the container is leased. Known values are: "Infinite" and "Fixed". + :vartype lease_duration: str or ~azure.mgmt.storage.v2022_09_01.models.LeaseDuration + :ivar metadata: A name-value pair to associate with the container as metadata. + :vartype metadata: dict[str, str] + :ivar immutability_policy: The ImmutabilityPolicy property of the container. + :vartype immutability_policy: + ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicyProperties + :ivar legal_hold: The LegalHold property of the container. + :vartype legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHoldProperties + :ivar has_legal_hold: The hasLegalHold public property is set to true by SRP if there are at + least one existing tag. The hasLegalHold public property is set to false by SRP if all existing + legal hold tags are cleared out. There can be a maximum of 1000 blob containers with + hasLegalHold=true for a given account. + :vartype has_legal_hold: bool + :ivar has_immutability_policy: The hasImmutabilityPolicy public property is set to true by SRP + if ImmutabilityPolicy has been created for this container. The hasImmutabilityPolicy public + property is set to false by SRP if ImmutabilityPolicy has not been created for this container. + :vartype has_immutability_policy: bool + :ivar immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_09_01.models.ImmutableStorageWithVersioning + :ivar enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :vartype enable_nfs_v3_root_squash: bool + :ivar enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :vartype enable_nfs_v3_all_squash: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "etag": {"readonly": True}, + "version": {"readonly": True}, + "deleted": {"readonly": True}, + "deleted_time": {"readonly": True}, + "remaining_retention_days": {"readonly": True}, + "last_modified_time": {"readonly": True}, + "lease_status": {"readonly": True}, + "lease_state": {"readonly": True}, + "lease_duration": {"readonly": True}, + "immutability_policy": {"readonly": True}, + "legal_hold": {"readonly": True}, + "has_legal_hold": {"readonly": True}, + "has_immutability_policy": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "etag": {"key": "etag", "type": "str"}, + "version": {"key": "properties.version", "type": "str"}, + "deleted": {"key": "properties.deleted", "type": "bool"}, + "deleted_time": {"key": "properties.deletedTime", "type": "iso-8601"}, + "remaining_retention_days": {"key": "properties.remainingRetentionDays", "type": "int"}, + "default_encryption_scope": {"key": "properties.defaultEncryptionScope", "type": "str"}, + "deny_encryption_scope_override": {"key": "properties.denyEncryptionScopeOverride", "type": "bool"}, + "public_access": {"key": "properties.publicAccess", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "lease_status": {"key": "properties.leaseStatus", "type": "str"}, + "lease_state": {"key": "properties.leaseState", "type": "str"}, + "lease_duration": {"key": "properties.leaseDuration", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "immutability_policy": {"key": "properties.immutabilityPolicy", "type": "ImmutabilityPolicyProperties"}, + "legal_hold": {"key": "properties.legalHold", "type": "LegalHoldProperties"}, + "has_legal_hold": {"key": "properties.hasLegalHold", "type": "bool"}, + "has_immutability_policy": {"key": "properties.hasImmutabilityPolicy", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageWithVersioning", + }, + "enable_nfs_v3_root_squash": {"key": "properties.enableNfsV3RootSquash", "type": "bool"}, + "enable_nfs_v3_all_squash": {"key": "properties.enableNfsV3AllSquash", "type": "bool"}, + } + + def __init__( + self, + *, + default_encryption_scope: Optional[str] = None, + deny_encryption_scope_override: Optional[bool] = None, + public_access: Optional[Union[str, "_models.PublicAccess"]] = None, + metadata: Optional[Dict[str, str]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageWithVersioning"] = None, + enable_nfs_v3_root_squash: Optional[bool] = None, + enable_nfs_v3_all_squash: Optional[bool] = None, + **kwargs + ): + """ + :keyword default_encryption_scope: Default the container to use specified encryption scope for + all writes. + :paramtype default_encryption_scope: str + :keyword deny_encryption_scope_override: Block override of encryption scope from the container + default. + :paramtype deny_encryption_scope_override: bool + :keyword public_access: Specifies whether data in the container may be accessed publicly and + the level of access. Known values are: "Container", "Blob", and "None". + :paramtype public_access: str or ~azure.mgmt.storage.v2022_09_01.models.PublicAccess + :keyword metadata: A name-value pair to associate with the container as metadata. + :paramtype metadata: dict[str, str] + :keyword immutable_storage_with_versioning: The object level immutability property of the + container. The property is immutable and can only be set to true at the container creation + time. Existing containers must undergo a migration process. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_09_01.models.ImmutableStorageWithVersioning + :keyword enable_nfs_v3_root_squash: Enable NFSv3 root squash on blob container. + :paramtype enable_nfs_v3_root_squash: bool + :keyword enable_nfs_v3_all_squash: Enable NFSv3 all squash on blob container. + :paramtype enable_nfs_v3_all_squash: bool + """ + super().__init__(**kwargs) + self.version = None + self.deleted = None + self.deleted_time = None + self.remaining_retention_days = None + self.default_encryption_scope = default_encryption_scope + self.deny_encryption_scope_override = deny_encryption_scope_override + self.public_access = public_access + self.last_modified_time = None + self.lease_status = None + self.lease_state = None + self.lease_duration = None + self.metadata = metadata + self.immutability_policy = None + self.legal_hold = None + self.has_legal_hold = None + self.has_immutability_policy = None + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.enable_nfs_v3_root_squash = enable_nfs_v3_root_squash + self.enable_nfs_v3_all_squash = enable_nfs_v3_all_squash + + +class ListContainerItems(_serialization.Model): + """Response schema. Contains list of blobs returned, and if paging is requested or required, a URL to next page of containers. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of blobs containers returned. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.ListContainerItem] + :ivar next_link: Request URL that can be used to query next page of containers. Returned when + total number of requested containers exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ListContainerItem]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ListQueue(Resource): + """ListQueue. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar metadata: A name-value pair that represents queue metadata. + :vartype metadata: dict[str, str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + } + + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword metadata: A name-value pair that represents queue metadata. + :paramtype metadata: dict[str, str] + """ + super().__init__(**kwargs) + self.metadata = metadata + + +class ListQueueResource(_serialization.Model): + """Response schema. Contains list of queues returned. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of queues returned. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.ListQueue] + :ivar next_link: Request URL that can be used to list next page of queues. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[ListQueue]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ListQueueServices(_serialization.Model): + """ListQueueServices. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of queue services returned. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[QueueServiceProperties]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + + +class ListServiceSasResponse(_serialization.Model): + """The List service SAS credentials operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar service_sas_token: List service SAS credentials of specific resource. + :vartype service_sas_token: str + """ + + _validation = { + "service_sas_token": {"readonly": True}, + } + + _attribute_map = { + "service_sas_token": {"key": "serviceSasToken", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.service_sas_token = None + + +class ListTableResource(_serialization.Model): + """Response schema. Contains list of tables returned. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of tables returned. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.Table] + :ivar next_link: Request URL that can be used to query next page of tables. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[Table]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class ListTableServices(_serialization.Model): + """ListTableServices. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: List of table services returned. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[TableServiceProperties]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + + +class LocalUser(Resource): # pylint: disable=too-many-instance-attributes + """The local user associated with the storage accounts. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.storage.v2022_09_01.models.SystemData + :ivar permission_scopes: The permission scopes of the local user. + :vartype permission_scopes: list[~azure.mgmt.storage.v2022_09_01.models.PermissionScope] + :ivar home_directory: Optional, local user home directory. + :vartype home_directory: str + :ivar ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :vartype ssh_authorized_keys: list[~azure.mgmt.storage.v2022_09_01.models.SshPublicKey] + :ivar sid: A unique Security Identifier that is generated by the server. + :vartype sid: str + :ivar has_shared_key: Indicates whether shared key exists. Set it to false to remove existing + shared key. + :vartype has_shared_key: bool + :ivar has_ssh_key: Indicates whether ssh key exists. Set it to false to remove existing SSH + key. + :vartype has_ssh_key: bool + :ivar has_ssh_password: Indicates whether ssh password exists. Set it to false to remove + existing SSH password. + :vartype has_ssh_password: bool + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "system_data": {"readonly": True}, + "sid": {"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"}, + "permission_scopes": {"key": "properties.permissionScopes", "type": "[PermissionScope]"}, + "home_directory": {"key": "properties.homeDirectory", "type": "str"}, + "ssh_authorized_keys": {"key": "properties.sshAuthorizedKeys", "type": "[SshPublicKey]"}, + "sid": {"key": "properties.sid", "type": "str"}, + "has_shared_key": {"key": "properties.hasSharedKey", "type": "bool"}, + "has_ssh_key": {"key": "properties.hasSshKey", "type": "bool"}, + "has_ssh_password": {"key": "properties.hasSshPassword", "type": "bool"}, + } + + def __init__( + self, + *, + permission_scopes: Optional[List["_models.PermissionScope"]] = None, + home_directory: Optional[str] = None, + ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, + has_shared_key: Optional[bool] = None, + has_ssh_key: Optional[bool] = None, + has_ssh_password: Optional[bool] = None, + **kwargs + ): + """ + :keyword permission_scopes: The permission scopes of the local user. + :paramtype permission_scopes: list[~azure.mgmt.storage.v2022_09_01.models.PermissionScope] + :keyword home_directory: Optional, local user home directory. + :paramtype home_directory: str + :keyword ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :paramtype ssh_authorized_keys: list[~azure.mgmt.storage.v2022_09_01.models.SshPublicKey] + :keyword has_shared_key: Indicates whether shared key exists. Set it to false to remove + existing shared key. + :paramtype has_shared_key: bool + :keyword has_ssh_key: Indicates whether ssh key exists. Set it to false to remove existing SSH + key. + :paramtype has_ssh_key: bool + :keyword has_ssh_password: Indicates whether ssh password exists. Set it to false to remove + existing SSH password. + :paramtype has_ssh_password: bool + """ + super().__init__(**kwargs) + self.system_data = None + self.permission_scopes = permission_scopes + self.home_directory = home_directory + self.ssh_authorized_keys = ssh_authorized_keys + self.sid = None + self.has_shared_key = has_shared_key + self.has_ssh_key = has_ssh_key + self.has_ssh_password = has_ssh_password + + +class LocalUserKeys(_serialization.Model): + """The Storage Account Local User keys. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :vartype ssh_authorized_keys: list[~azure.mgmt.storage.v2022_09_01.models.SshPublicKey] + :ivar shared_key: Auto generated by the server for SMB authentication. + :vartype shared_key: str + """ + + _validation = { + "shared_key": {"readonly": True}, + } + + _attribute_map = { + "ssh_authorized_keys": {"key": "sshAuthorizedKeys", "type": "[SshPublicKey]"}, + "shared_key": {"key": "sharedKey", "type": "str"}, + } + + def __init__(self, *, ssh_authorized_keys: Optional[List["_models.SshPublicKey"]] = None, **kwargs): + """ + :keyword ssh_authorized_keys: Optional, local user ssh authorized keys for SFTP. + :paramtype ssh_authorized_keys: list[~azure.mgmt.storage.v2022_09_01.models.SshPublicKey] + """ + super().__init__(**kwargs) + self.ssh_authorized_keys = ssh_authorized_keys + self.shared_key = None + + +class LocalUserRegeneratePasswordResult(_serialization.Model): + """The secrets of Storage Account Local User. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar ssh_password: Auto generated password by the server for SSH authentication if + hasSshPassword is set to true on the creation of local user. + :vartype ssh_password: str + """ + + _validation = { + "ssh_password": {"readonly": True}, + } + + _attribute_map = { + "ssh_password": {"key": "sshPassword", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.ssh_password = None + + +class LocalUsers(_serialization.Model): + """List storage account local users. + + :ivar value: The local users associated with the storage account. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.LocalUser] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[LocalUser]"}, + } + + def __init__(self, *, value: Optional[List["_models.LocalUser"]] = None, **kwargs): + """ + :keyword value: The local users associated with the storage account. + :paramtype value: list[~azure.mgmt.storage.v2022_09_01.models.LocalUser] + """ + super().__init__(**kwargs) + self.value = value + + +class ManagementPolicy(Resource): + """The Get Storage Account ManagementPolicies operation response. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar last_modified_time: Returns the date and time the ManagementPolicies was last modified. + :vartype last_modified_time: ~datetime.datetime + :ivar policy: The Storage Account ManagementPolicy, in JSON format. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + :vartype policy: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicySchema + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "last_modified_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "last_modified_time": {"key": "properties.lastModifiedTime", "type": "iso-8601"}, + "policy": {"key": "properties.policy", "type": "ManagementPolicySchema"}, + } + + def __init__(self, *, policy: Optional["_models.ManagementPolicySchema"] = None, **kwargs): + """ + :keyword policy: The Storage Account ManagementPolicy, in JSON format. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + :paramtype policy: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicySchema + """ + super().__init__(**kwargs) + self.last_modified_time = None + self.policy = policy + + +class ManagementPolicyAction(_serialization.Model): + """Actions are applied to the filtered blobs when the execution condition is met. + + :ivar base_blob: The management policy action for base blob. + :vartype base_blob: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyBaseBlob + :ivar snapshot: The management policy action for snapshot. + :vartype snapshot: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicySnapShot + :ivar version: The management policy action for version. + :vartype version: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyVersion + """ + + _attribute_map = { + "base_blob": {"key": "baseBlob", "type": "ManagementPolicyBaseBlob"}, + "snapshot": {"key": "snapshot", "type": "ManagementPolicySnapShot"}, + "version": {"key": "version", "type": "ManagementPolicyVersion"}, + } + + def __init__( + self, + *, + base_blob: Optional["_models.ManagementPolicyBaseBlob"] = None, + snapshot: Optional["_models.ManagementPolicySnapShot"] = None, + version: Optional["_models.ManagementPolicyVersion"] = None, + **kwargs + ): + """ + :keyword base_blob: The management policy action for base blob. + :paramtype base_blob: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyBaseBlob + :keyword snapshot: The management policy action for snapshot. + :paramtype snapshot: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicySnapShot + :keyword version: The management policy action for version. + :paramtype version: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyVersion + """ + super().__init__(**kwargs) + self.base_blob = base_blob + self.snapshot = snapshot + self.version = version + + +class ManagementPolicyBaseBlob(_serialization.Model): + """Management policy action for base blob. + + :ivar tier_to_cool: The function to tier blobs to cool storage. + :vartype tier_to_cool: ~azure.mgmt.storage.v2022_09_01.models.DateAfterModification + :ivar tier_to_archive: The function to tier blobs to archive storage. + :vartype tier_to_archive: ~azure.mgmt.storage.v2022_09_01.models.DateAfterModification + :ivar tier_to_cold: The function to tier blobs to cold storage. + :vartype tier_to_cold: ~azure.mgmt.storage.v2022_09_01.models.DateAfterModification + :ivar tier_to_hot: The function to tier blobs to hot storage. This action can only be used with + Premium Block Blob Storage Accounts. + :vartype tier_to_hot: ~azure.mgmt.storage.v2022_09_01.models.DateAfterModification + :ivar delete: The function to delete the blob. + :vartype delete: ~azure.mgmt.storage.v2022_09_01.models.DateAfterModification + :ivar enable_auto_tier_to_hot_from_cool: This property enables auto tiering of a blob from cool + to hot on a blob access. This property requires tierToCool.daysAfterLastAccessTimeGreaterThan. + :vartype enable_auto_tier_to_hot_from_cool: bool + """ + + _attribute_map = { + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterModification"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterModification"}, + "tier_to_cold": {"key": "tierToCold", "type": "DateAfterModification"}, + "tier_to_hot": {"key": "tierToHot", "type": "DateAfterModification"}, + "delete": {"key": "delete", "type": "DateAfterModification"}, + "enable_auto_tier_to_hot_from_cool": {"key": "enableAutoTierToHotFromCool", "type": "bool"}, + } + + def __init__( + self, + *, + tier_to_cool: Optional["_models.DateAfterModification"] = None, + tier_to_archive: Optional["_models.DateAfterModification"] = None, + tier_to_cold: Optional["_models.DateAfterModification"] = None, + tier_to_hot: Optional["_models.DateAfterModification"] = None, + delete: Optional["_models.DateAfterModification"] = None, + enable_auto_tier_to_hot_from_cool: Optional[bool] = None, + **kwargs + ): + """ + :keyword tier_to_cool: The function to tier blobs to cool storage. + :paramtype tier_to_cool: ~azure.mgmt.storage.v2022_09_01.models.DateAfterModification + :keyword tier_to_archive: The function to tier blobs to archive storage. + :paramtype tier_to_archive: ~azure.mgmt.storage.v2022_09_01.models.DateAfterModification + :keyword tier_to_cold: The function to tier blobs to cold storage. + :paramtype tier_to_cold: ~azure.mgmt.storage.v2022_09_01.models.DateAfterModification + :keyword tier_to_hot: The function to tier blobs to hot storage. This action can only be used + with Premium Block Blob Storage Accounts. + :paramtype tier_to_hot: ~azure.mgmt.storage.v2022_09_01.models.DateAfterModification + :keyword delete: The function to delete the blob. + :paramtype delete: ~azure.mgmt.storage.v2022_09_01.models.DateAfterModification + :keyword enable_auto_tier_to_hot_from_cool: This property enables auto tiering of a blob from + cool to hot on a blob access. This property requires + tierToCool.daysAfterLastAccessTimeGreaterThan. + :paramtype enable_auto_tier_to_hot_from_cool: bool + """ + super().__init__(**kwargs) + self.tier_to_cool = tier_to_cool + self.tier_to_archive = tier_to_archive + self.tier_to_cold = tier_to_cold + self.tier_to_hot = tier_to_hot + self.delete = delete + self.enable_auto_tier_to_hot_from_cool = enable_auto_tier_to_hot_from_cool + + +class ManagementPolicyDefinition(_serialization.Model): + """An object that defines the Lifecycle rule. Each definition is made up with a filters set and an actions set. + + All required parameters must be populated in order to send to Azure. + + :ivar actions: An object that defines the action set. Required. + :vartype actions: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyAction + :ivar filters: An object that defines the filter set. + :vartype filters: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyFilter + """ + + _validation = { + "actions": {"required": True}, + } + + _attribute_map = { + "actions": {"key": "actions", "type": "ManagementPolicyAction"}, + "filters": {"key": "filters", "type": "ManagementPolicyFilter"}, + } + + def __init__( + self, + *, + actions: "_models.ManagementPolicyAction", + filters: Optional["_models.ManagementPolicyFilter"] = None, + **kwargs + ): + """ + :keyword actions: An object that defines the action set. Required. + :paramtype actions: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyAction + :keyword filters: An object that defines the filter set. + :paramtype filters: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyFilter + """ + super().__init__(**kwargs) + self.actions = actions + self.filters = filters + + +class ManagementPolicyFilter(_serialization.Model): + """Filters limit rule actions to a subset of blobs within the storage account. If multiple filters are defined, a logical AND is performed on all filters. + + All required parameters must be populated in order to send to Azure. + + :ivar prefix_match: An array of strings for prefixes to be match. + :vartype prefix_match: list[str] + :ivar blob_types: An array of predefined enum values. Currently blockBlob supports all tiering + and delete actions. Only delete actions are supported for appendBlob. Required. + :vartype blob_types: list[str] + :ivar blob_index_match: An array of blob index tag based filters, there can be at most 10 tag + filters. + :vartype blob_index_match: list[~azure.mgmt.storage.v2022_09_01.models.TagFilter] + """ + + _validation = { + "blob_types": {"required": True}, + } + + _attribute_map = { + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "blob_types": {"key": "blobTypes", "type": "[str]"}, + "blob_index_match": {"key": "blobIndexMatch", "type": "[TagFilter]"}, + } + + def __init__( + self, + *, + blob_types: List[str], + prefix_match: Optional[List[str]] = None, + blob_index_match: Optional[List["_models.TagFilter"]] = None, + **kwargs + ): + """ + :keyword prefix_match: An array of strings for prefixes to be match. + :paramtype prefix_match: list[str] + :keyword blob_types: An array of predefined enum values. Currently blockBlob supports all + tiering and delete actions. Only delete actions are supported for appendBlob. Required. + :paramtype blob_types: list[str] + :keyword blob_index_match: An array of blob index tag based filters, there can be at most 10 + tag filters. + :paramtype blob_index_match: list[~azure.mgmt.storage.v2022_09_01.models.TagFilter] + """ + super().__init__(**kwargs) + self.prefix_match = prefix_match + self.blob_types = blob_types + self.blob_index_match = blob_index_match + + +class ManagementPolicyRule(_serialization.Model): + """An object that wraps the Lifecycle rule. Each rule is uniquely defined by name. + + All required parameters must be populated in order to send to Azure. + + :ivar enabled: Rule is enabled if set to true. + :vartype enabled: bool + :ivar name: A rule name can contain any combination of alpha numeric characters. Rule name is + case-sensitive. It must be unique within a policy. Required. + :vartype name: str + :ivar type: The valid value is Lifecycle. Required. "Lifecycle" + :vartype type: str or ~azure.mgmt.storage.v2022_09_01.models.RuleType + :ivar definition: An object that defines the Lifecycle rule. Required. + :vartype definition: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyDefinition + """ + + _validation = { + "name": {"required": True}, + "type": {"required": True}, + "definition": {"required": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "definition": {"key": "definition", "type": "ManagementPolicyDefinition"}, + } + + def __init__( + self, + *, + name: str, + type: Union[str, "_models.RuleType"], + definition: "_models.ManagementPolicyDefinition", + enabled: Optional[bool] = None, + **kwargs + ): + """ + :keyword enabled: Rule is enabled if set to true. + :paramtype enabled: bool + :keyword name: A rule name can contain any combination of alpha numeric characters. Rule name + is case-sensitive. It must be unique within a policy. Required. + :paramtype name: str + :keyword type: The valid value is Lifecycle. Required. "Lifecycle" + :paramtype type: str or ~azure.mgmt.storage.v2022_09_01.models.RuleType + :keyword definition: An object that defines the Lifecycle rule. Required. + :paramtype definition: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyDefinition + """ + super().__init__(**kwargs) + self.enabled = enabled + self.name = name + self.type = type + self.definition = definition + + +class ManagementPolicySchema(_serialization.Model): + """The Storage Account ManagementPolicies Rules. See more details in: https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + + All required parameters must be populated in order to send to Azure. + + :ivar rules: The Storage Account ManagementPolicies Rules. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. + :vartype rules: list[~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyRule] + """ + + _validation = { + "rules": {"required": True}, + } + + _attribute_map = { + "rules": {"key": "rules", "type": "[ManagementPolicyRule]"}, + } + + def __init__(self, *, rules: List["_models.ManagementPolicyRule"], **kwargs): + """ + :keyword rules: The Storage Account ManagementPolicies Rules. See more details in: + https://docs.microsoft.com/en-us/azure/storage/common/storage-lifecycle-managment-concepts. + Required. + :paramtype rules: list[~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyRule] + """ + super().__init__(**kwargs) + self.rules = rules + + +class ManagementPolicySnapShot(_serialization.Model): + """Management policy action for snapshot. + + :ivar tier_to_cool: The function to tier blob snapshot to cool storage. + :vartype tier_to_cool: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :ivar tier_to_archive: The function to tier blob snapshot to archive storage. + :vartype tier_to_archive: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :ivar tier_to_cold: The function to tier blobs to cold storage. + :vartype tier_to_cold: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :ivar tier_to_hot: The function to tier blobs to hot storage. This action can only be used with + Premium Block Blob Storage Accounts. + :vartype tier_to_hot: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :ivar delete: The function to delete the blob snapshot. + :vartype delete: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + """ + + _attribute_map = { + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "tier_to_cold": {"key": "tierToCold", "type": "DateAfterCreation"}, + "tier_to_hot": {"key": "tierToHot", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, + } + + def __init__( + self, + *, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + tier_to_cold: Optional["_models.DateAfterCreation"] = None, + tier_to_hot: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, + **kwargs + ): + """ + :keyword tier_to_cool: The function to tier blob snapshot to cool storage. + :paramtype tier_to_cool: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :keyword tier_to_archive: The function to tier blob snapshot to archive storage. + :paramtype tier_to_archive: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :keyword tier_to_cold: The function to tier blobs to cold storage. + :paramtype tier_to_cold: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :keyword tier_to_hot: The function to tier blobs to hot storage. This action can only be used + with Premium Block Blob Storage Accounts. + :paramtype tier_to_hot: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :keyword delete: The function to delete the blob snapshot. + :paramtype delete: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + """ + super().__init__(**kwargs) + self.tier_to_cool = tier_to_cool + self.tier_to_archive = tier_to_archive + self.tier_to_cold = tier_to_cold + self.tier_to_hot = tier_to_hot + self.delete = delete + + +class ManagementPolicyVersion(_serialization.Model): + """Management policy action for blob version. + + :ivar tier_to_cool: The function to tier blob version to cool storage. + :vartype tier_to_cool: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :ivar tier_to_archive: The function to tier blob version to archive storage. + :vartype tier_to_archive: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :ivar tier_to_cold: The function to tier blobs to cold storage. + :vartype tier_to_cold: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :ivar tier_to_hot: The function to tier blobs to hot storage. This action can only be used with + Premium Block Blob Storage Accounts. + :vartype tier_to_hot: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :ivar delete: The function to delete the blob version. + :vartype delete: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + """ + + _attribute_map = { + "tier_to_cool": {"key": "tierToCool", "type": "DateAfterCreation"}, + "tier_to_archive": {"key": "tierToArchive", "type": "DateAfterCreation"}, + "tier_to_cold": {"key": "tierToCold", "type": "DateAfterCreation"}, + "tier_to_hot": {"key": "tierToHot", "type": "DateAfterCreation"}, + "delete": {"key": "delete", "type": "DateAfterCreation"}, + } + + def __init__( + self, + *, + tier_to_cool: Optional["_models.DateAfterCreation"] = None, + tier_to_archive: Optional["_models.DateAfterCreation"] = None, + tier_to_cold: Optional["_models.DateAfterCreation"] = None, + tier_to_hot: Optional["_models.DateAfterCreation"] = None, + delete: Optional["_models.DateAfterCreation"] = None, + **kwargs + ): + """ + :keyword tier_to_cool: The function to tier blob version to cool storage. + :paramtype tier_to_cool: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :keyword tier_to_archive: The function to tier blob version to archive storage. + :paramtype tier_to_archive: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :keyword tier_to_cold: The function to tier blobs to cold storage. + :paramtype tier_to_cold: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :keyword tier_to_hot: The function to tier blobs to hot storage. This action can only be used + with Premium Block Blob Storage Accounts. + :paramtype tier_to_hot: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + :keyword delete: The function to delete the blob version. + :paramtype delete: ~azure.mgmt.storage.v2022_09_01.models.DateAfterCreation + """ + super().__init__(**kwargs) + self.tier_to_cool = tier_to_cool + self.tier_to_archive = tier_to_archive + self.tier_to_cold = tier_to_cold + self.tier_to_hot = tier_to_hot + self.delete = delete + + +class MetricSpecification(_serialization.Model): + """Metric specification of operation. + + :ivar name: Name of metric specification. + :vartype name: str + :ivar display_name: Display name of metric specification. + :vartype display_name: str + :ivar display_description: Display description of metric specification. + :vartype display_description: str + :ivar unit: Unit could be Bytes or Count. + :vartype unit: str + :ivar dimensions: Dimensions of blobs, including blob type and access tier. + :vartype dimensions: list[~azure.mgmt.storage.v2022_09_01.models.Dimension] + :ivar aggregation_type: Aggregation type could be Average. + :vartype aggregation_type: str + :ivar fill_gap_with_zero: The property to decide fill gap with zero or not. + :vartype fill_gap_with_zero: bool + :ivar category: The category this metric specification belong to, could be Capacity. + :vartype category: str + :ivar resource_id_dimension_name_override: Account Resource Id. + :vartype resource_id_dimension_name_override: str + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display_name": {"key": "displayName", "type": "str"}, + "display_description": {"key": "displayDescription", "type": "str"}, + "unit": {"key": "unit", "type": "str"}, + "dimensions": {"key": "dimensions", "type": "[Dimension]"}, + "aggregation_type": {"key": "aggregationType", "type": "str"}, + "fill_gap_with_zero": {"key": "fillGapWithZero", "type": "bool"}, + "category": {"key": "category", "type": "str"}, + "resource_id_dimension_name_override": {"key": "resourceIdDimensionNameOverride", "type": "str"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display_name: Optional[str] = None, + display_description: Optional[str] = None, + unit: Optional[str] = None, + dimensions: Optional[List["_models.Dimension"]] = None, + aggregation_type: Optional[str] = None, + fill_gap_with_zero: Optional[bool] = None, + category: Optional[str] = None, + resource_id_dimension_name_override: Optional[str] = None, + **kwargs + ): + """ + :keyword name: Name of metric specification. + :paramtype name: str + :keyword display_name: Display name of metric specification. + :paramtype display_name: str + :keyword display_description: Display description of metric specification. + :paramtype display_description: str + :keyword unit: Unit could be Bytes or Count. + :paramtype unit: str + :keyword dimensions: Dimensions of blobs, including blob type and access tier. + :paramtype dimensions: list[~azure.mgmt.storage.v2022_09_01.models.Dimension] + :keyword aggregation_type: Aggregation type could be Average. + :paramtype aggregation_type: str + :keyword fill_gap_with_zero: The property to decide fill gap with zero or not. + :paramtype fill_gap_with_zero: bool + :keyword category: The category this metric specification belong to, could be Capacity. + :paramtype category: str + :keyword resource_id_dimension_name_override: Account Resource Id. + :paramtype resource_id_dimension_name_override: str + """ + super().__init__(**kwargs) + self.name = name + self.display_name = display_name + self.display_description = display_description + self.unit = unit + self.dimensions = dimensions + self.aggregation_type = aggregation_type + self.fill_gap_with_zero = fill_gap_with_zero + self.category = category + self.resource_id_dimension_name_override = resource_id_dimension_name_override + + +class Multichannel(_serialization.Model): + """Multichannel setting. Applies to Premium FileStorage only. + + :ivar enabled: Indicates whether multichannel is enabled. + :vartype enabled: bool + """ + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + } + + def __init__(self, *, enabled: Optional[bool] = None, **kwargs): + """ + :keyword enabled: Indicates whether multichannel is enabled. + :paramtype enabled: bool + """ + super().__init__(**kwargs) + self.enabled = enabled + + +class NetworkRuleSet(_serialization.Model): + """Network rule set. + + All required parameters must be populated in order to send to Azure. + + :ivar bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible + values are any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), + or None to bypass none of those traffics. Known values are: "None", "Logging", "Metrics", and + "AzureServices". + :vartype bypass: str or ~azure.mgmt.storage.v2022_09_01.models.Bypass + :ivar resource_access_rules: Sets the resource access rules. + :vartype resource_access_rules: list[~azure.mgmt.storage.v2022_09_01.models.ResourceAccessRule] + :ivar virtual_network_rules: Sets the virtual network rules. + :vartype virtual_network_rules: list[~azure.mgmt.storage.v2022_09_01.models.VirtualNetworkRule] + :ivar ip_rules: Sets the IP ACL rules. + :vartype ip_rules: list[~azure.mgmt.storage.v2022_09_01.models.IPRule] + :ivar default_action: Specifies the default action of allow or deny when no other rules match. + Known values are: "Allow" and "Deny". + :vartype default_action: str or ~azure.mgmt.storage.v2022_09_01.models.DefaultAction + """ + + _validation = { + "default_action": {"required": True}, + } + + _attribute_map = { + "bypass": {"key": "bypass", "type": "str"}, + "resource_access_rules": {"key": "resourceAccessRules", "type": "[ResourceAccessRule]"}, + "virtual_network_rules": {"key": "virtualNetworkRules", "type": "[VirtualNetworkRule]"}, + "ip_rules": {"key": "ipRules", "type": "[IPRule]"}, + "default_action": {"key": "defaultAction", "type": "str"}, + } + + def __init__( + self, + *, + default_action: Union[str, "_models.DefaultAction"] = "Allow", + bypass: Union[str, "_models.Bypass"] = "AzureServices", + resource_access_rules: Optional[List["_models.ResourceAccessRule"]] = None, + virtual_network_rules: Optional[List["_models.VirtualNetworkRule"]] = None, + ip_rules: Optional[List["_models.IPRule"]] = None, + **kwargs + ): + """ + :keyword bypass: Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. + Possible values are any combination of Logging|Metrics|AzureServices (For example, "Logging, + Metrics"), or None to bypass none of those traffics. Known values are: "None", "Logging", + "Metrics", and "AzureServices". + :paramtype bypass: str or ~azure.mgmt.storage.v2022_09_01.models.Bypass + :keyword resource_access_rules: Sets the resource access rules. + :paramtype resource_access_rules: + list[~azure.mgmt.storage.v2022_09_01.models.ResourceAccessRule] + :keyword virtual_network_rules: Sets the virtual network rules. + :paramtype virtual_network_rules: + list[~azure.mgmt.storage.v2022_09_01.models.VirtualNetworkRule] + :keyword ip_rules: Sets the IP ACL rules. + :paramtype ip_rules: list[~azure.mgmt.storage.v2022_09_01.models.IPRule] + :keyword default_action: Specifies the default action of allow or deny when no other rules + match. Known values are: "Allow" and "Deny". + :paramtype default_action: str or ~azure.mgmt.storage.v2022_09_01.models.DefaultAction + """ + super().__init__(**kwargs) + self.bypass = bypass + self.resource_access_rules = resource_access_rules + self.virtual_network_rules = virtual_network_rules + self.ip_rules = ip_rules + self.default_action = default_action + + +class ObjectReplicationPolicies(_serialization.Model): + """List storage account object replication policies. + + :ivar value: The replication policy between two storage accounts. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[ObjectReplicationPolicy]"}, + } + + def __init__(self, *, value: Optional[List["_models.ObjectReplicationPolicy"]] = None, **kwargs): + """ + :keyword value: The replication policy between two storage accounts. + :paramtype value: list[~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy] + """ + super().__init__(**kwargs) + self.value = value + + +class ObjectReplicationPolicy(Resource): + """The replication policy between two storage accounts. Multiple rules can be defined in one policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar policy_id: A unique id for object replication policy. + :vartype policy_id: str + :ivar enabled_time: Indicates when the policy is enabled on the source account. + :vartype enabled_time: ~datetime.datetime + :ivar source_account: Required. Source account name. It should be full resource id if + allowCrossTenantReplication set to false. + :vartype source_account: str + :ivar destination_account: Required. Destination account name. It should be full resource id if + allowCrossTenantReplication set to false. + :vartype destination_account: str + :ivar rules: The storage account object replication rules. + :vartype rules: list[~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicyRule] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "policy_id": {"readonly": True}, + "enabled_time": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "policy_id": {"key": "properties.policyId", "type": "str"}, + "enabled_time": {"key": "properties.enabledTime", "type": "iso-8601"}, + "source_account": {"key": "properties.sourceAccount", "type": "str"}, + "destination_account": {"key": "properties.destinationAccount", "type": "str"}, + "rules": {"key": "properties.rules", "type": "[ObjectReplicationPolicyRule]"}, + } + + def __init__( + self, + *, + source_account: Optional[str] = None, + destination_account: Optional[str] = None, + rules: Optional[List["_models.ObjectReplicationPolicyRule"]] = None, + **kwargs + ): + """ + :keyword source_account: Required. Source account name. It should be full resource id if + allowCrossTenantReplication set to false. + :paramtype source_account: str + :keyword destination_account: Required. Destination account name. It should be full resource id + if allowCrossTenantReplication set to false. + :paramtype destination_account: str + :keyword rules: The storage account object replication rules. + :paramtype rules: list[~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicyRule] + """ + super().__init__(**kwargs) + self.policy_id = None + self.enabled_time = None + self.source_account = source_account + self.destination_account = destination_account + self.rules = rules + + +class ObjectReplicationPolicyFilter(_serialization.Model): + """Filters limit replication to a subset of blobs within the storage account. A logical OR is performed on values in the filter. If multiple filters are defined, a logical AND is performed on all filters. + + :ivar prefix_match: Optional. Filters the results to replicate only blobs whose names begin + with the specified prefix. + :vartype prefix_match: list[str] + :ivar min_creation_time: Blobs created after the time will be replicated to the destination. It + must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. + :vartype min_creation_time: str + """ + + _attribute_map = { + "prefix_match": {"key": "prefixMatch", "type": "[str]"}, + "min_creation_time": {"key": "minCreationTime", "type": "str"}, + } + + def __init__(self, *, prefix_match: Optional[List[str]] = None, min_creation_time: Optional[str] = None, **kwargs): + """ + :keyword prefix_match: Optional. Filters the results to replicate only blobs whose names begin + with the specified prefix. + :paramtype prefix_match: list[str] + :keyword min_creation_time: Blobs created after the time will be replicated to the destination. + It must be in datetime format 'yyyy-MM-ddTHH:mm:ssZ'. Example: 2020-02-19T16:05:00Z. + :paramtype min_creation_time: str + """ + super().__init__(**kwargs) + self.prefix_match = prefix_match + self.min_creation_time = min_creation_time + + +class ObjectReplicationPolicyRule(_serialization.Model): + """The replication policy rule between two containers. + + All required parameters must be populated in order to send to Azure. + + :ivar rule_id: Rule Id is auto-generated for each new rule on destination account. It is + required for put policy on source account. + :vartype rule_id: str + :ivar source_container: Required. Source container name. Required. + :vartype source_container: str + :ivar destination_container: Required. Destination container name. Required. + :vartype destination_container: str + :ivar filters: Optional. An object that defines the filter set. + :vartype filters: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicyFilter + """ + + _validation = { + "source_container": {"required": True}, + "destination_container": {"required": True}, + } + + _attribute_map = { + "rule_id": {"key": "ruleId", "type": "str"}, + "source_container": {"key": "sourceContainer", "type": "str"}, + "destination_container": {"key": "destinationContainer", "type": "str"}, + "filters": {"key": "filters", "type": "ObjectReplicationPolicyFilter"}, + } + + def __init__( + self, + *, + source_container: str, + destination_container: str, + rule_id: Optional[str] = None, + filters: Optional["_models.ObjectReplicationPolicyFilter"] = None, + **kwargs + ): + """ + :keyword rule_id: Rule Id is auto-generated for each new rule on destination account. It is + required for put policy on source account. + :paramtype rule_id: str + :keyword source_container: Required. Source container name. Required. + :paramtype source_container: str + :keyword destination_container: Required. Destination container name. Required. + :paramtype destination_container: str + :keyword filters: Optional. An object that defines the filter set. + :paramtype filters: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicyFilter + """ + super().__init__(**kwargs) + self.rule_id = rule_id + self.source_container = source_container + self.destination_container = destination_container + self.filters = filters + + +class Operation(_serialization.Model): + """Storage REST API operation definition. + + :ivar name: Operation name: {provider}/{resource}/{operation}. + :vartype name: str + :ivar display: Display metadata associated with the operation. + :vartype display: ~azure.mgmt.storage.v2022_09_01.models.OperationDisplay + :ivar origin: The origin of operations. + :vartype origin: str + :ivar service_specification: One property of operation, include metric specifications. + :vartype service_specification: ~azure.mgmt.storage.v2022_09_01.models.ServiceSpecification + """ + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "display": {"key": "display", "type": "OperationDisplay"}, + "origin": {"key": "origin", "type": "str"}, + "service_specification": {"key": "properties.serviceSpecification", "type": "ServiceSpecification"}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + display: Optional["_models.OperationDisplay"] = None, + origin: Optional[str] = None, + service_specification: Optional["_models.ServiceSpecification"] = None, + **kwargs + ): + """ + :keyword name: Operation name: {provider}/{resource}/{operation}. + :paramtype name: str + :keyword display: Display metadata associated with the operation. + :paramtype display: ~azure.mgmt.storage.v2022_09_01.models.OperationDisplay + :keyword origin: The origin of operations. + :paramtype origin: str + :keyword service_specification: One property of operation, include metric specifications. + :paramtype service_specification: ~azure.mgmt.storage.v2022_09_01.models.ServiceSpecification + """ + super().__init__(**kwargs) + self.name = name + self.display = display + self.origin = origin + self.service_specification = service_specification + + +class OperationDisplay(_serialization.Model): + """Display metadata associated with the operation. + + :ivar provider: Service provider: Microsoft Storage. + :vartype provider: str + :ivar resource: Resource on which the operation is performed etc. + :vartype resource: str + :ivar operation: Type of operation: get, read, delete, etc. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str + """ + + _attribute_map = { + "provider": {"key": "provider", "type": "str"}, + "resource": {"key": "resource", "type": "str"}, + "operation": {"key": "operation", "type": "str"}, + "description": {"key": "description", "type": "str"}, + } + + def __init__( + self, + *, + provider: Optional[str] = None, + resource: Optional[str] = None, + operation: Optional[str] = None, + description: Optional[str] = None, + **kwargs + ): + """ + :keyword provider: Service provider: Microsoft Storage. + :paramtype provider: str + :keyword resource: Resource on which the operation is performed etc. + :paramtype resource: str + :keyword operation: Type of operation: get, read, delete, etc. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ + super().__init__(**kwargs) + self.provider = provider + self.resource = resource + self.operation = operation + self.description = description + + +class OperationListResult(_serialization.Model): + """Result of the request to list Storage operations. It contains a list of operations and a URL link to get the next set of results. + + :ivar value: List of Storage operations supported by the Storage resource provider. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.Operation] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Operation]"}, + } + + def __init__(self, *, value: Optional[List["_models.Operation"]] = None, **kwargs): + """ + :keyword value: List of Storage operations supported by the Storage resource provider. + :paramtype value: list[~azure.mgmt.storage.v2022_09_01.models.Operation] + """ + super().__init__(**kwargs) + self.value = value + + +class PermissionScope(_serialization.Model): + """PermissionScope. + + All required parameters must be populated in order to send to Azure. + + :ivar permissions: The permissions for the local user. Possible values include: Read (r), Write + (w), Delete (d), List (l), and Create (c). Required. + :vartype permissions: str + :ivar service: The service used by the local user, e.g. blob, file. Required. + :vartype service: str + :ivar resource_name: The name of resource, normally the container name or the file share name, + used by the local user. Required. + :vartype resource_name: str + """ + + _validation = { + "permissions": {"required": True}, + "service": {"required": True}, + "resource_name": {"required": True}, + } + + _attribute_map = { + "permissions": {"key": "permissions", "type": "str"}, + "service": {"key": "service", "type": "str"}, + "resource_name": {"key": "resourceName", "type": "str"}, + } + + def __init__(self, *, permissions: str, service: str, resource_name: str, **kwargs): + """ + :keyword permissions: The permissions for the local user. Possible values include: Read (r), + Write (w), Delete (d), List (l), and Create (c). Required. + :paramtype permissions: str + :keyword service: The service used by the local user, e.g. blob, file. Required. + :paramtype service: str + :keyword resource_name: The name of resource, normally the container name or the file share + name, used by the local user. Required. + :paramtype resource_name: str + """ + super().__init__(**kwargs) + self.permissions = permissions + self.service = service + self.resource_name = resource_name + + +class PrivateEndpoint(_serialization.Model): + """The Private Endpoint resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: The ARM identifier for Private Endpoint. + :vartype id: str + """ + + _validation = { + "id": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.id = None + + +class PrivateEndpointConnection(Resource): + """The Private Endpoint Connection resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar private_endpoint: The resource of private end point. + :vartype private_endpoint: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpoint + :ivar private_link_service_connection_state: A collection of information about the state of the + connection between service consumer and provider. + :vartype private_link_service_connection_state: + ~azure.mgmt.storage.v2022_09_01.models.PrivateLinkServiceConnectionState + :ivar provisioning_state: The provisioning state of the private endpoint connection resource. + Known values are: "Succeeded", "Creating", "Deleting", and "Failed". + :vartype provisioning_state: str or + ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnectionProvisioningState + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "provisioning_state": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "private_endpoint": {"key": "properties.privateEndpoint", "type": "PrivateEndpoint"}, + "private_link_service_connection_state": { + "key": "properties.privateLinkServiceConnectionState", + "type": "PrivateLinkServiceConnectionState", + }, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + } + + def __init__( + self, + *, + private_endpoint: Optional["_models.PrivateEndpoint"] = None, + private_link_service_connection_state: Optional["_models.PrivateLinkServiceConnectionState"] = None, + **kwargs + ): + """ + :keyword private_endpoint: The resource of private end point. + :paramtype private_endpoint: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpoint + :keyword private_link_service_connection_state: A collection of information about the state of + the connection between service consumer and provider. + :paramtype private_link_service_connection_state: + ~azure.mgmt.storage.v2022_09_01.models.PrivateLinkServiceConnectionState + """ + super().__init__(**kwargs) + self.private_endpoint = private_endpoint + self.private_link_service_connection_state = private_link_service_connection_state + self.provisioning_state = None + + +class PrivateEndpointConnectionListResult(_serialization.Model): + """List of private endpoint connection associated with the specified storage account. + + :ivar value: Array of private endpoint connections. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateEndpointConnection]"}, + } + + def __init__(self, *, value: Optional[List["_models.PrivateEndpointConnection"]] = None, **kwargs): + """ + :keyword value: Array of private endpoint connections. + :paramtype value: list[~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkResource(Resource): + """A private link resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + :ivar required_zone_names: The private link resource Private link DNS zone name. + :vartype required_zone_names: list[str] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "group_id": {"readonly": True}, + "required_members": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "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, *, required_zone_names: Optional[List[str]] = None, **kwargs): + """ + :keyword required_zone_names: The private link resource Private link DNS zone name. + :paramtype required_zone_names: list[str] + """ + super().__init__(**kwargs) + self.group_id = None + self.required_members = None + self.required_zone_names = required_zone_names + + +class PrivateLinkResourceListResult(_serialization.Model): + """A list of private link resources. + + :ivar value: Array of private link resources. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.PrivateLinkResource] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[PrivateLinkResource]"}, + } + + def __init__(self, *, value: Optional[List["_models.PrivateLinkResource"]] = None, **kwargs): + """ + :keyword value: Array of private link resources. + :paramtype value: list[~azure.mgmt.storage.v2022_09_01.models.PrivateLinkResource] + """ + super().__init__(**kwargs) + self.value = value + + +class PrivateLinkServiceConnectionState(_serialization.Model): + """A collection of information about the state of the connection between service consumer and provider. + + :ivar status: Indicates whether the connection has been Approved/Rejected/Removed by the owner + of the service. Known values are: "Pending", "Approved", and "Rejected". + :vartype status: str or + ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointServiceConnectionStatus + :ivar description: The reason for approval/rejection of the connection. + :vartype description: str + :ivar action_required: A message indicating if changes on the service provider require any + updates on the consumer. + :vartype action_required: str + """ + + _attribute_map = { + "status": {"key": "status", "type": "str"}, + "description": {"key": "description", "type": "str"}, + "action_required": {"key": "actionRequired", "type": "str"}, + } + + def __init__( + self, + *, + status: Optional[Union[str, "_models.PrivateEndpointServiceConnectionStatus"]] = None, + description: Optional[str] = None, + action_required: Optional[str] = None, + **kwargs + ): + """ + :keyword status: Indicates whether the connection has been Approved/Rejected/Removed by the + owner of the service. Known values are: "Pending", "Approved", and "Rejected". + :paramtype status: str or + ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointServiceConnectionStatus + :keyword description: The reason for approval/rejection of the connection. + :paramtype description: str + :keyword action_required: A message indicating if changes on the service provider require any + updates on the consumer. + :paramtype action_required: str + """ + super().__init__(**kwargs) + self.status = status + self.description = description + self.action_required = action_required + + +class ProtectedAppendWritesHistory(_serialization.Model): + """Protected append writes history setting for the blob container with Legal holds. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :vartype allow_protected_append_writes_all: bool + :ivar timestamp: Returns the date and time the tag was added. + :vartype timestamp: ~datetime.datetime + """ + + _validation = { + "timestamp": {"readonly": True}, + } + + _attribute_map = { + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + } + + def __init__(self, *, allow_protected_append_writes_all: Optional[bool] = None, **kwargs): + """ + :keyword allow_protected_append_writes_all: When enabled, new blocks can be written to both + 'Append and Bock Blobs' while maintaining legal hold protection and compliance. Only new blocks + can be added and any existing blocks cannot be modified or deleted. + :paramtype allow_protected_append_writes_all: bool + """ + super().__init__(**kwargs) + self.allow_protected_append_writes_all = allow_protected_append_writes_all + self.timestamp = None + + +class ProtocolSettings(_serialization.Model): + """Protocol settings for file service. + + :ivar smb: Setting for SMB protocol. + :vartype smb: ~azure.mgmt.storage.v2022_09_01.models.SmbSetting + """ + + _attribute_map = { + "smb": {"key": "smb", "type": "SmbSetting"}, + } + + def __init__(self, *, smb: Optional["_models.SmbSetting"] = None, **kwargs): + """ + :keyword smb: Setting for SMB protocol. + :paramtype smb: ~azure.mgmt.storage.v2022_09_01.models.SmbSetting + """ + super().__init__(**kwargs) + self.smb = smb + + +class QueueServiceProperties(Resource): + """The properties of a storage account’s Queue service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Queue service. + :vartype cors: ~azure.mgmt.storage.v2022_09_01.models.CorsRules + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + } + + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): + """ + :keyword cors: Specifies CORS rules for the Queue service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Queue service. + :paramtype cors: ~azure.mgmt.storage.v2022_09_01.models.CorsRules + """ + super().__init__(**kwargs) + self.cors = cors + + +class ResourceAccessRule(_serialization.Model): + """Resource Access Rule. + + :ivar tenant_id: Tenant Id. + :vartype tenant_id: str + :ivar resource_id: Resource Id. + :vartype resource_id: str + """ + + _attribute_map = { + "tenant_id": {"key": "tenantId", "type": "str"}, + "resource_id": {"key": "resourceId", "type": "str"}, + } + + def __init__(self, *, tenant_id: Optional[str] = None, resource_id: Optional[str] = None, **kwargs): + """ + :keyword tenant_id: Tenant Id. + :paramtype tenant_id: str + :keyword resource_id: Resource Id. + :paramtype resource_id: str + """ + super().__init__(**kwargs) + self.tenant_id = tenant_id + self.resource_id = resource_id + + +class RestorePolicyProperties(_serialization.Model): + """The blob service properties for blob restore policy. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar enabled: Blob restore is enabled if set to true. Required. + :vartype enabled: bool + :ivar days: how long this blob can be restored. It should be great than zero and less than + DeleteRetentionPolicy.days. + :vartype days: int + :ivar last_enabled_time: Deprecated in favor of minRestoreTime property. + :vartype last_enabled_time: ~datetime.datetime + :ivar min_restore_time: Returns the minimum date and time that the restore can be started. + :vartype min_restore_time: ~datetime.datetime + """ + + _validation = { + "enabled": {"required": True}, + "days": {"maximum": 365, "minimum": 1}, + "last_enabled_time": {"readonly": True}, + "min_restore_time": {"readonly": True}, + } + + _attribute_map = { + "enabled": {"key": "enabled", "type": "bool"}, + "days": {"key": "days", "type": "int"}, + "last_enabled_time": {"key": "lastEnabledTime", "type": "iso-8601"}, + "min_restore_time": {"key": "minRestoreTime", "type": "iso-8601"}, + } + + def __init__(self, *, enabled: bool, days: Optional[int] = None, **kwargs): + """ + :keyword enabled: Blob restore is enabled if set to true. Required. + :paramtype enabled: bool + :keyword days: how long this blob can be restored. It should be great than zero and less than + DeleteRetentionPolicy.days. + :paramtype days: int + """ + super().__init__(**kwargs) + self.enabled = enabled + self.days = days + self.last_enabled_time = None + self.min_restore_time = None + + +class Restriction(_serialization.Model): + """The restriction because of which SKU cannot be used. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar type: The type of restrictions. As of now only possible value for this is location. + :vartype type: str + :ivar values: The value of restrictions. If the restriction type is set to location. This would + be different locations where the SKU is restricted. + :vartype values: list[str] + :ivar reason_code: The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the + subscription does not belong to that quota. The "NotAvailableForSubscription" is related to + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". + :vartype reason_code: str or ~azure.mgmt.storage.v2022_09_01.models.ReasonCode + """ + + _validation = { + "type": {"readonly": True}, + "values": {"readonly": True}, + } + + _attribute_map = { + "type": {"key": "type", "type": "str"}, + "values": {"key": "values", "type": "[str]"}, + "reason_code": {"key": "reasonCode", "type": "str"}, + } + + def __init__(self, *, reason_code: Optional[Union[str, "_models.ReasonCode"]] = None, **kwargs): + """ + :keyword reason_code: The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the + subscription does not belong to that quota. The "NotAvailableForSubscription" is related to + capacity at DC. Known values are: "QuotaId" and "NotAvailableForSubscription". + :paramtype reason_code: str or ~azure.mgmt.storage.v2022_09_01.models.ReasonCode + """ + super().__init__(**kwargs) + self.type = None + self.values = None + self.reason_code = reason_code + + +class RoutingPreference(_serialization.Model): + """Routing preference defines the type of network, either microsoft or internet routing to be used to deliver the user data, the default option is microsoft routing. + + :ivar routing_choice: Routing Choice defines the kind of network routing opted by the user. + Known values are: "MicrosoftRouting" and "InternetRouting". + :vartype routing_choice: str or ~azure.mgmt.storage.v2022_09_01.models.RoutingChoice + :ivar publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing + storage endpoints are to be published. + :vartype publish_microsoft_endpoints: bool + :ivar publish_internet_endpoints: A boolean flag which indicates whether internet routing + storage endpoints are to be published. + :vartype publish_internet_endpoints: bool + """ + + _attribute_map = { + "routing_choice": {"key": "routingChoice", "type": "str"}, + "publish_microsoft_endpoints": {"key": "publishMicrosoftEndpoints", "type": "bool"}, + "publish_internet_endpoints": {"key": "publishInternetEndpoints", "type": "bool"}, + } + + def __init__( + self, + *, + routing_choice: Optional[Union[str, "_models.RoutingChoice"]] = None, + publish_microsoft_endpoints: Optional[bool] = None, + publish_internet_endpoints: Optional[bool] = None, + **kwargs + ): + """ + :keyword routing_choice: Routing Choice defines the kind of network routing opted by the user. + Known values are: "MicrosoftRouting" and "InternetRouting". + :paramtype routing_choice: str or ~azure.mgmt.storage.v2022_09_01.models.RoutingChoice + :keyword publish_microsoft_endpoints: A boolean flag which indicates whether microsoft routing + storage endpoints are to be published. + :paramtype publish_microsoft_endpoints: bool + :keyword publish_internet_endpoints: A boolean flag which indicates whether internet routing + storage endpoints are to be published. + :paramtype publish_internet_endpoints: bool + """ + super().__init__(**kwargs) + self.routing_choice = routing_choice + self.publish_microsoft_endpoints = publish_microsoft_endpoints + self.publish_internet_endpoints = publish_internet_endpoints + + +class SasPolicy(_serialization.Model): + """SasPolicy assigned to the storage account. + + All required parameters must be populated in order to send to Azure. + + :ivar sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. + :vartype sas_expiration_period: str + :ivar expiration_action: The SAS expiration action. Can only be Log. "Log" + :vartype expiration_action: str or ~azure.mgmt.storage.v2022_09_01.models.ExpirationAction + """ + + _validation = { + "sas_expiration_period": {"required": True}, + "expiration_action": {"required": True}, + } + + _attribute_map = { + "sas_expiration_period": {"key": "sasExpirationPeriod", "type": "str"}, + "expiration_action": {"key": "expirationAction", "type": "str"}, + } + + def __init__( + self, *, sas_expiration_period: str, expiration_action: Union[str, "_models.ExpirationAction"] = "Log", **kwargs + ): + """ + :keyword sas_expiration_period: The SAS expiration period, DD.HH:MM:SS. Required. + :paramtype sas_expiration_period: str + :keyword expiration_action: The SAS expiration action. Can only be Log. "Log" + :paramtype expiration_action: str or ~azure.mgmt.storage.v2022_09_01.models.ExpirationAction + """ + super().__init__(**kwargs) + self.sas_expiration_period = sas_expiration_period + self.expiration_action = expiration_action + + +class ServiceSasParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The parameters to list service SAS credentials of a specific resource. + + All required parameters must be populated in order to send to Azure. + + :ivar canonicalized_resource: The canonical path to the signed resource. Required. + :vartype canonicalized_resource: str + :ivar resource: The signed services accessible with the service SAS. Possible values include: + Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and "s". + :vartype resource: str or ~azure.mgmt.storage.v2022_09_01.models.SignedResource + :ivar permissions: The signed permissions for the service SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", and "p". + :vartype permissions: str or ~azure.mgmt.storage.v2022_09_01.models.Permissions + :ivar ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :vartype ip_address_or_range: str + :ivar protocols: The protocol permitted for a request made with the account SAS. Known values + are: "https,http" and "https". + :vartype protocols: str or ~azure.mgmt.storage.v2022_09_01.models.HttpProtocol + :ivar shared_access_start_time: The time at which the SAS becomes valid. + :vartype shared_access_start_time: ~datetime.datetime + :ivar shared_access_expiry_time: The time at which the shared access signature becomes invalid. + :vartype shared_access_expiry_time: ~datetime.datetime + :ivar identifier: A unique value up to 64 characters in length that correlates to an access + policy specified for the container, queue, or table. + :vartype identifier: str + :ivar partition_key_start: The start of partition key. + :vartype partition_key_start: str + :ivar partition_key_end: The end of partition key. + :vartype partition_key_end: str + :ivar row_key_start: The start of row key. + :vartype row_key_start: str + :ivar row_key_end: The end of row key. + :vartype row_key_end: str + :ivar key_to_sign: The key to sign the account SAS token with. + :vartype key_to_sign: str + :ivar cache_control: The response header override for cache control. + :vartype cache_control: str + :ivar content_disposition: The response header override for content disposition. + :vartype content_disposition: str + :ivar content_encoding: The response header override for content encoding. + :vartype content_encoding: str + :ivar content_language: The response header override for content language. + :vartype content_language: str + :ivar content_type: The response header override for content type. + :vartype content_type: str + """ + + _validation = { + "canonicalized_resource": {"required": True}, + "identifier": {"max_length": 64}, + } + + _attribute_map = { + "canonicalized_resource": {"key": "canonicalizedResource", "type": "str"}, + "resource": {"key": "signedResource", "type": "str"}, + "permissions": {"key": "signedPermission", "type": "str"}, + "ip_address_or_range": {"key": "signedIp", "type": "str"}, + "protocols": {"key": "signedProtocol", "type": "str"}, + "shared_access_start_time": {"key": "signedStart", "type": "iso-8601"}, + "shared_access_expiry_time": {"key": "signedExpiry", "type": "iso-8601"}, + "identifier": {"key": "signedIdentifier", "type": "str"}, + "partition_key_start": {"key": "startPk", "type": "str"}, + "partition_key_end": {"key": "endPk", "type": "str"}, + "row_key_start": {"key": "startRk", "type": "str"}, + "row_key_end": {"key": "endRk", "type": "str"}, + "key_to_sign": {"key": "keyToSign", "type": "str"}, + "cache_control": {"key": "rscc", "type": "str"}, + "content_disposition": {"key": "rscd", "type": "str"}, + "content_encoding": {"key": "rsce", "type": "str"}, + "content_language": {"key": "rscl", "type": "str"}, + "content_type": {"key": "rsct", "type": "str"}, + } + + def __init__( + self, + *, + canonicalized_resource: str, + resource: Optional[Union[str, "_models.SignedResource"]] = None, + permissions: Optional[Union[str, "_models.Permissions"]] = None, + ip_address_or_range: Optional[str] = None, + protocols: Optional[Union[str, "_models.HttpProtocol"]] = None, + shared_access_start_time: Optional[datetime.datetime] = None, + shared_access_expiry_time: Optional[datetime.datetime] = None, + identifier: Optional[str] = None, + partition_key_start: Optional[str] = None, + partition_key_end: Optional[str] = None, + row_key_start: Optional[str] = None, + row_key_end: Optional[str] = None, + key_to_sign: Optional[str] = None, + cache_control: Optional[str] = None, + content_disposition: Optional[str] = None, + content_encoding: Optional[str] = None, + content_language: Optional[str] = None, + content_type: Optional[str] = None, + **kwargs + ): + """ + :keyword canonicalized_resource: The canonical path to the signed resource. Required. + :paramtype canonicalized_resource: str + :keyword resource: The signed services accessible with the service SAS. Possible values + include: Blob (b), Container (c), File (f), Share (s). Known values are: "b", "c", "f", and + "s". + :paramtype resource: str or ~azure.mgmt.storage.v2022_09_01.models.SignedResource + :keyword permissions: The signed permissions for the service SAS. Possible values include: Read + (r), Write (w), Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). Known + values are: "r", "d", "w", "l", "a", "c", "u", and "p". + :paramtype permissions: str or ~azure.mgmt.storage.v2022_09_01.models.Permissions + :keyword ip_address_or_range: An IP address or a range of IP addresses from which to accept + requests. + :paramtype ip_address_or_range: str + :keyword protocols: The protocol permitted for a request made with the account SAS. Known + values are: "https,http" and "https". + :paramtype protocols: str or ~azure.mgmt.storage.v2022_09_01.models.HttpProtocol + :keyword shared_access_start_time: The time at which the SAS becomes valid. + :paramtype shared_access_start_time: ~datetime.datetime + :keyword shared_access_expiry_time: The time at which the shared access signature becomes + invalid. + :paramtype shared_access_expiry_time: ~datetime.datetime + :keyword identifier: A unique value up to 64 characters in length that correlates to an access + policy specified for the container, queue, or table. + :paramtype identifier: str + :keyword partition_key_start: The start of partition key. + :paramtype partition_key_start: str + :keyword partition_key_end: The end of partition key. + :paramtype partition_key_end: str + :keyword row_key_start: The start of row key. + :paramtype row_key_start: str + :keyword row_key_end: The end of row key. + :paramtype row_key_end: str + :keyword key_to_sign: The key to sign the account SAS token with. + :paramtype key_to_sign: str + :keyword cache_control: The response header override for cache control. + :paramtype cache_control: str + :keyword content_disposition: The response header override for content disposition. + :paramtype content_disposition: str + :keyword content_encoding: The response header override for content encoding. + :paramtype content_encoding: str + :keyword content_language: The response header override for content language. + :paramtype content_language: str + :keyword content_type: The response header override for content type. + :paramtype content_type: str + """ + super().__init__(**kwargs) + self.canonicalized_resource = canonicalized_resource + self.resource = resource + self.permissions = permissions + self.ip_address_or_range = ip_address_or_range + self.protocols = protocols + self.shared_access_start_time = shared_access_start_time + self.shared_access_expiry_time = shared_access_expiry_time + self.identifier = identifier + self.partition_key_start = partition_key_start + self.partition_key_end = partition_key_end + self.row_key_start = row_key_start + self.row_key_end = row_key_end + self.key_to_sign = key_to_sign + self.cache_control = cache_control + self.content_disposition = content_disposition + self.content_encoding = content_encoding + self.content_language = content_language + self.content_type = content_type + + +class ServiceSpecification(_serialization.Model): + """One property of operation, include metric specifications. + + :ivar metric_specifications: Metric specifications of operation. + :vartype metric_specifications: + list[~azure.mgmt.storage.v2022_09_01.models.MetricSpecification] + """ + + _attribute_map = { + "metric_specifications": {"key": "metricSpecifications", "type": "[MetricSpecification]"}, + } + + def __init__(self, *, metric_specifications: Optional[List["_models.MetricSpecification"]] = None, **kwargs): + """ + :keyword metric_specifications: Metric specifications of operation. + :paramtype metric_specifications: + list[~azure.mgmt.storage.v2022_09_01.models.MetricSpecification] + """ + super().__init__(**kwargs) + self.metric_specifications = metric_specifications + + +class SignedIdentifier(_serialization.Model): + """SignedIdentifier. + + :ivar id: An unique identifier of the stored access policy. + :vartype id: str + :ivar access_policy: Access policy. + :vartype access_policy: ~azure.mgmt.storage.v2022_09_01.models.AccessPolicy + """ + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "access_policy": {"key": "accessPolicy", "type": "AccessPolicy"}, + } + + def __init__( + self, + *, + id: Optional[str] = None, # pylint: disable=redefined-builtin + access_policy: Optional["_models.AccessPolicy"] = None, + **kwargs + ): + """ + :keyword id: An unique identifier of the stored access policy. + :paramtype id: str + :keyword access_policy: Access policy. + :paramtype access_policy: ~azure.mgmt.storage.v2022_09_01.models.AccessPolicy + """ + super().__init__(**kwargs) + self.id = id + self.access_policy = access_policy + + +class Sku(_serialization.Model): + """The SKU of the storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", and "Standard_RAGZRS". + :vartype name: str or ~azure.mgmt.storage.v2022_09_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and + "Premium". + :vartype tier: str or ~azure.mgmt.storage.v2022_09_01.models.SkuTier + """ + + _validation = { + "name": {"required": True}, + "tier": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + } + + def __init__(self, *, name: Union[str, "_models.SkuName"], **kwargs): + """ + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", and "Standard_RAGZRS". + :paramtype name: str or ~azure.mgmt.storage.v2022_09_01.models.SkuName + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + + +class SKUCapability(_serialization.Model): + """The capability information in the specified SKU, including file encryption, network ACLs, change notification, etc. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of capability, The capability information in the specified SKU, including + file encryption, network ACLs, change notification, etc. + :vartype name: str + :ivar value: A string value to indicate states of given capability. Possibly 'true' or 'false'. + :vartype value: str + """ + + _validation = { + "name": {"readonly": True}, + "value": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.name = None + self.value = None + + +class SkuInformation(_serialization.Model): + """Storage SKU and its properties. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", and "Standard_RAGZRS". + :vartype name: str or ~azure.mgmt.storage.v2022_09_01.models.SkuName + :ivar tier: The SKU tier. This is based on the SKU name. Known values are: "Standard" and + "Premium". + :vartype tier: str or ~azure.mgmt.storage.v2022_09_01.models.SkuTier + :ivar resource_type: The type of the resource, usually it is 'storageAccounts'. + :vartype resource_type: str + :ivar kind: Indicates the type of storage account. Known values are: "Storage", "StorageV2", + "BlobStorage", "FileStorage", and "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2022_09_01.models.Kind + :ivar locations: The set of locations that the SKU is available. This will be supported and + registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). + :vartype locations: list[str] + :ivar capabilities: The capability information in the specified SKU, including file encryption, + network ACLs, change notification, etc. + :vartype capabilities: list[~azure.mgmt.storage.v2022_09_01.models.SKUCapability] + :ivar restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :vartype restrictions: list[~azure.mgmt.storage.v2022_09_01.models.Restriction] + """ + + _validation = { + "name": {"required": True}, + "tier": {"readonly": True}, + "resource_type": {"readonly": True}, + "kind": {"readonly": True}, + "locations": {"readonly": True}, + "capabilities": {"readonly": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "tier": {"key": "tier", "type": "str"}, + "resource_type": {"key": "resourceType", "type": "str"}, + "kind": {"key": "kind", "type": "str"}, + "locations": {"key": "locations", "type": "[str]"}, + "capabilities": {"key": "capabilities", "type": "[SKUCapability]"}, + "restrictions": {"key": "restrictions", "type": "[Restriction]"}, + } + + def __init__( + self, + *, + name: Union[str, "_models.SkuName"], + restrictions: Optional[List["_models.Restriction"]] = None, + **kwargs + ): + """ + :keyword name: The SKU name. Required for account creation; optional for update. Note that in + older versions, SKU name was called accountType. Required. Known values are: "Standard_LRS", + "Standard_GRS", "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", + "Standard_GZRS", and "Standard_RAGZRS". + :paramtype name: str or ~azure.mgmt.storage.v2022_09_01.models.SkuName + :keyword restrictions: The restrictions because of which SKU cannot be used. This is empty if + there are no restrictions. + :paramtype restrictions: list[~azure.mgmt.storage.v2022_09_01.models.Restriction] + """ + super().__init__(**kwargs) + self.name = name + self.tier = None + self.resource_type = None + self.kind = None + self.locations = None + self.capabilities = None + self.restrictions = restrictions + + +class SmbSetting(_serialization.Model): + """Setting for SMB protocol. + + :ivar multichannel: Multichannel setting. Applies to Premium FileStorage only. + :vartype multichannel: ~azure.mgmt.storage.v2022_09_01.models.Multichannel + :ivar versions: SMB protocol versions supported by server. Valid values are SMB2.1, SMB3.0, + SMB3.1.1. Should be passed as a string with delimiter ';'. + :vartype versions: str + :ivar authentication_methods: SMB authentication methods supported by server. Valid values are + NTLMv2, Kerberos. Should be passed as a string with delimiter ';'. + :vartype authentication_methods: str + :ivar kerberos_ticket_encryption: Kerberos ticket encryption supported by server. Valid values + are RC4-HMAC, AES-256. Should be passed as a string with delimiter ';'. + :vartype kerberos_ticket_encryption: str + :ivar channel_encryption: SMB channel encryption supported by server. Valid values are + AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. + :vartype channel_encryption: str + """ + + _attribute_map = { + "multichannel": {"key": "multichannel", "type": "Multichannel"}, + "versions": {"key": "versions", "type": "str"}, + "authentication_methods": {"key": "authenticationMethods", "type": "str"}, + "kerberos_ticket_encryption": {"key": "kerberosTicketEncryption", "type": "str"}, + "channel_encryption": {"key": "channelEncryption", "type": "str"}, + } + + def __init__( + self, + *, + multichannel: Optional["_models.Multichannel"] = None, + versions: Optional[str] = None, + authentication_methods: Optional[str] = None, + kerberos_ticket_encryption: Optional[str] = None, + channel_encryption: Optional[str] = None, + **kwargs + ): + """ + :keyword multichannel: Multichannel setting. Applies to Premium FileStorage only. + :paramtype multichannel: ~azure.mgmt.storage.v2022_09_01.models.Multichannel + :keyword versions: SMB protocol versions supported by server. Valid values are SMB2.1, SMB3.0, + SMB3.1.1. Should be passed as a string with delimiter ';'. + :paramtype versions: str + :keyword authentication_methods: SMB authentication methods supported by server. Valid values + are NTLMv2, Kerberos. Should be passed as a string with delimiter ';'. + :paramtype authentication_methods: str + :keyword kerberos_ticket_encryption: Kerberos ticket encryption supported by server. Valid + values are RC4-HMAC, AES-256. Should be passed as a string with delimiter ';'. + :paramtype kerberos_ticket_encryption: str + :keyword channel_encryption: SMB channel encryption supported by server. Valid values are + AES-128-CCM, AES-128-GCM, AES-256-GCM. Should be passed as a string with delimiter ';'. + :paramtype channel_encryption: str + """ + super().__init__(**kwargs) + self.multichannel = multichannel + self.versions = versions + self.authentication_methods = authentication_methods + self.kerberos_ticket_encryption = kerberos_ticket_encryption + self.channel_encryption = channel_encryption + + +class SshPublicKey(_serialization.Model): + """SshPublicKey. + + :ivar description: Optional. It is used to store the function/usage of the key. + :vartype description: str + :ivar key: Ssh public key base64 encoded. The format should be: ':code:`` + :code:``', e.g. ssh-rsa AAAABBBB. + :vartype key: str + """ + + _attribute_map = { + "description": {"key": "description", "type": "str"}, + "key": {"key": "key", "type": "str"}, + } + + def __init__(self, *, description: Optional[str] = None, key: Optional[str] = None, **kwargs): + """ + :keyword description: Optional. It is used to store the function/usage of the key. + :paramtype description: str + :keyword key: Ssh public key base64 encoded. The format should be: ':code:`` + :code:``', e.g. ssh-rsa AAAABBBB. + :paramtype key: str + """ + super().__init__(**kwargs) + self.description = description + self.key = key + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + } + + def __init__(self, *, location: str, tags: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + """ + super().__init__(**kwargs) + self.tags = tags + self.location = location + + +class StorageAccount(TrackedResource): # pylint: disable=too-many-instance-attributes + """The storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: Resource tags. + :vartype tags: dict[str, str] + :ivar location: The geo-location where the resource lives. Required. + :vartype location: str + :ivar sku: Gets the SKU. + :vartype sku: ~azure.mgmt.storage.v2022_09_01.models.Sku + :ivar kind: Gets the Kind. Known values are: "Storage", "StorageV2", "BlobStorage", + "FileStorage", and "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2022_09_01.models.Kind + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.storage.v2022_09_01.models.Identity + :ivar extended_location: The extendedLocation of the resource. + :vartype extended_location: ~azure.mgmt.storage.v2022_09_01.models.ExtendedLocation + :ivar provisioning_state: Gets the status of the storage account at the time the operation was + called. Known values are: "Creating", "ResolvingDNS", and "Succeeded". + :vartype provisioning_state: str or ~azure.mgmt.storage.v2022_09_01.models.ProvisioningState + :ivar primary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, + queue, or table object. Note that Standard_ZRS and Premium_LRS accounts only return the blob + endpoint. + :vartype primary_endpoints: ~azure.mgmt.storage.v2022_09_01.models.Endpoints + :ivar primary_location: Gets the location of the primary data center for the storage account. + :vartype primary_location: str + :ivar status_of_primary: Gets the status indicating whether the primary location of the storage + account is available or unavailable. Known values are: "available" and "unavailable". + :vartype status_of_primary: str or ~azure.mgmt.storage.v2022_09_01.models.AccountStatus + :ivar last_geo_failover_time: Gets the timestamp of the most recent instance of a failover to + the secondary location. Only the most recent timestamp is retained. This element is not + returned if there has never been a failover instance. Only available if the accountType is + Standard_GRS or Standard_RAGRS. + :vartype last_geo_failover_time: ~datetime.datetime + :ivar secondary_location: Gets the location of the geo-replicated secondary for the storage + account. Only available if the accountType is Standard_GRS or Standard_RAGRS. + :vartype secondary_location: str + :ivar status_of_secondary: Gets the status indicating whether the secondary location of the + storage account is available or unavailable. Only available if the SKU name is Standard_GRS or + Standard_RAGRS. Known values are: "available" and "unavailable". + :vartype status_of_secondary: str or ~azure.mgmt.storage.v2022_09_01.models.AccountStatus + :ivar creation_time: Gets the creation date and time of the storage account in UTC. + :vartype creation_time: ~datetime.datetime + :ivar custom_domain: Gets the custom domain the user assigned to this storage account. + :vartype custom_domain: ~azure.mgmt.storage.v2022_09_01.models.CustomDomain + :ivar sas_policy: SasPolicy assigned to the storage account. + :vartype sas_policy: ~azure.mgmt.storage.v2022_09_01.models.SasPolicy + :ivar key_policy: KeyPolicy assigned to the storage account. + :vartype key_policy: ~azure.mgmt.storage.v2022_09_01.models.KeyPolicy + :ivar key_creation_time: Storage account keys creation time. + :vartype key_creation_time: ~azure.mgmt.storage.v2022_09_01.models.KeyCreationTime + :ivar secondary_endpoints: Gets the URLs that are used to perform a retrieval of a public blob, + queue, or table object from the secondary location of the storage account. Only available if + the SKU name is Standard_RAGRS. + :vartype secondary_endpoints: ~azure.mgmt.storage.v2022_09_01.models.Endpoints + :ivar encryption: Encryption settings to be used for server-side encryption for the storage + account. + :vartype encryption: ~azure.mgmt.storage.v2022_09_01.models.Encryption + :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is + used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", and "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2022_09_01.models.AccessTier + :ivar azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :vartype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_09_01.models.AzureFilesIdentityBasedAuthentication + :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. + :vartype enable_https_traffic_only: bool + :ivar network_rule_set: Network rule set. + :vartype network_rule_set: ~azure.mgmt.storage.v2022_09_01.models.NetworkRuleSet + :ivar is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :vartype is_sftp_enabled: bool + :ivar is_local_user_enabled: Enables local users feature, if set to true. + :vartype is_local_user_enabled: bool + :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :vartype is_hns_enabled: bool + :ivar geo_replication_stats: Geo Replication Stats. + :vartype geo_replication_stats: ~azure.mgmt.storage.v2022_09_01.models.GeoReplicationStats + :ivar failover_in_progress: If the failover is in progress, the value will be true, otherwise, + it will be null. + :vartype failover_in_progress: bool + :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :vartype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_09_01.models.LargeFileSharesState + :ivar private_endpoint_connections: List of private endpoint connection associated with the + specified storage account. + :vartype private_endpoint_connections: + list[~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection] + :ivar routing_preference: Maintains information about the network routing choice opted by the + user for data transfer. + :vartype routing_preference: ~azure.mgmt.storage.v2022_09_01.models.RoutingPreference + :ivar blob_restore_status: Blob restore status. + :vartype blob_restore_status: ~azure.mgmt.storage.v2022_09_01.models.BlobRestoreStatus + :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in + the storage account. The default interpretation is true for this property. + :vartype allow_blob_public_access: bool + :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + and "TLS1_2". + :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2022_09_01.models.MinimumTlsVersion + :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :vartype allow_shared_key_access: bool + :ivar enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :vartype enable_nfs_v3: bool + :ivar allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :vartype allow_cross_tenant_replication: bool + :ivar default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :vartype default_to_o_auth_authentication: bool + :ivar public_network_access: Allow or disallow public network access to Storage Account. Value + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and + "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.storage.v2022_09_01.models.PublicNetworkAccess + :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true + at the account creation time. When set to true, it enables object level immutability for all + the containers in the account by default. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_09_01.models.ImmutableStorageAccount + :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_09_01.models.AllowedCopyScope + :ivar storage_account_sku_conversion_status: This property is readOnly and is set by server + during asynchronous storage account sku conversion operations. + :vartype storage_account_sku_conversion_status: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountSkuConversionStatus + :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone + to create a large number of accounts in a single subscription, which creates accounts in an + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard" and "AzureDnsZone". + :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_09_01.models.DnsEndpointType + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "location": {"required": True}, + "sku": {"readonly": True}, + "kind": {"readonly": True}, + "provisioning_state": {"readonly": True}, + "primary_endpoints": {"readonly": True}, + "primary_location": {"readonly": True}, + "status_of_primary": {"readonly": True}, + "last_geo_failover_time": {"readonly": True}, + "secondary_location": {"readonly": True}, + "status_of_secondary": {"readonly": True}, + "creation_time": {"readonly": True}, + "custom_domain": {"readonly": True}, + "sas_policy": {"readonly": True}, + "key_policy": {"readonly": True}, + "key_creation_time": {"readonly": True}, + "secondary_endpoints": {"readonly": True}, + "encryption": {"readonly": True}, + "access_tier": {"readonly": True}, + "network_rule_set": {"readonly": True}, + "geo_replication_stats": {"readonly": True}, + "failover_in_progress": {"readonly": True}, + "private_endpoint_connections": {"readonly": True}, + "blob_restore_status": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "tags": {"key": "tags", "type": "{str}"}, + "location": {"key": "location", "type": "str"}, + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "identity": {"key": "identity", "type": "Identity"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "provisioning_state": {"key": "properties.provisioningState", "type": "str"}, + "primary_endpoints": {"key": "properties.primaryEndpoints", "type": "Endpoints"}, + "primary_location": {"key": "properties.primaryLocation", "type": "str"}, + "status_of_primary": {"key": "properties.statusOfPrimary", "type": "str"}, + "last_geo_failover_time": {"key": "properties.lastGeoFailoverTime", "type": "iso-8601"}, + "secondary_location": {"key": "properties.secondaryLocation", "type": "str"}, + "status_of_secondary": {"key": "properties.statusOfSecondary", "type": "str"}, + "creation_time": {"key": "properties.creationTime", "type": "iso-8601"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "key_creation_time": {"key": "properties.keyCreationTime", "type": "KeyCreationTime"}, + "secondary_endpoints": {"key": "properties.secondaryEndpoints", "type": "Endpoints"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "geo_replication_stats": {"key": "properties.geoReplicationStats", "type": "GeoReplicationStats"}, + "failover_in_progress": {"key": "properties.failoverInProgress", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "private_endpoint_connections": { + "key": "properties.privateEndpointConnections", + "type": "[PrivateEndpointConnection]", + }, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "blob_restore_status": {"key": "properties.blobRestoreStatus", "type": "BlobRestoreStatus"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "storage_account_sku_conversion_status": { + "key": "properties.storageAccountSkuConversionStatus", + "type": "StorageAccountSkuConversionStatus", + }, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + extended_location: Optional["_models.ExtendedLocation"] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, + enable_https_traffic_only: Optional[bool] = None, + is_sftp_enabled: Optional[bool] = None, + is_local_user_enabled: Optional[bool] = None, + is_hns_enabled: Optional[bool] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, + allow_blob_public_access: Optional[bool] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + allow_shared_key_access: Optional[bool] = None, + enable_nfs_v3: Optional[bool] = None, + allow_cross_tenant_replication: Optional[bool] = None, + default_to_o_auth_authentication: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + storage_account_sku_conversion_status: Optional["_models.StorageAccountSkuConversionStatus"] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, + **kwargs + ): + """ + :keyword tags: Resource tags. + :paramtype tags: dict[str, str] + :keyword location: The geo-location where the resource lives. Required. + :paramtype location: str + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.storage.v2022_09_01.models.Identity + :keyword extended_location: The extendedLocation of the resource. + :paramtype extended_location: ~azure.mgmt.storage.v2022_09_01.models.ExtendedLocation + :keyword azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :paramtype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_09_01.models.AzureFilesIdentityBasedAuthentication + :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to + true. + :paramtype enable_https_traffic_only: bool + :keyword is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :paramtype is_sftp_enabled: bool + :keyword is_local_user_enabled: Enables local users feature, if set to true. + :paramtype is_local_user_enabled: bool + :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :paramtype is_hns_enabled: bool + :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :paramtype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_09_01.models.LargeFileSharesState + :keyword routing_preference: Maintains information about the network routing choice opted by + the user for data transfer. + :paramtype routing_preference: ~azure.mgmt.storage.v2022_09_01.models.RoutingPreference + :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers + in the storage account. The default interpretation is true for this property. + :paramtype allow_blob_public_access: bool + :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", and "TLS1_2". + :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2022_09_01.models.MinimumTlsVersion + :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :paramtype allow_shared_key_access: bool + :keyword enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :paramtype enable_nfs_v3: bool + :keyword allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :paramtype allow_cross_tenant_replication: bool + :keyword default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :paramtype default_to_o_auth_authentication: bool + :keyword public_network_access: Allow or disallow public network access to Storage Account. + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: + "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.storage.v2022_09_01.models.PublicNetworkAccess + :keyword immutable_storage_with_versioning: The property is immutable and can only be set to + true at the account creation time. When set to true, it enables object level immutability for + all the containers in the account by default. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_09_01.models.ImmutableStorageAccount + :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_09_01.models.AllowedCopyScope + :keyword storage_account_sku_conversion_status: This property is readOnly and is set by server + during asynchronous storage account sku conversion operations. + :paramtype storage_account_sku_conversion_status: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountSkuConversionStatus + :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to + AzureDNSZone to create a large number of accounts in a single subscription, which creates + accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone + identifier. Known values are: "Standard" and "AzureDnsZone". + :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_09_01.models.DnsEndpointType + """ + super().__init__(tags=tags, location=location, **kwargs) + self.sku = None + self.kind = None + self.identity = identity + self.extended_location = extended_location + self.provisioning_state = None + self.primary_endpoints = None + self.primary_location = None + self.status_of_primary = None + self.last_geo_failover_time = None + self.secondary_location = None + self.status_of_secondary = None + self.creation_time = None + self.custom_domain = None + self.sas_policy = None + self.key_policy = None + self.key_creation_time = None + self.secondary_endpoints = None + self.encryption = None + self.access_tier = None + self.azure_files_identity_based_authentication = azure_files_identity_based_authentication + self.enable_https_traffic_only = enable_https_traffic_only + self.network_rule_set = None + self.is_sftp_enabled = is_sftp_enabled + self.is_local_user_enabled = is_local_user_enabled + self.is_hns_enabled = is_hns_enabled + self.geo_replication_stats = None + self.failover_in_progress = None + self.large_file_shares_state = large_file_shares_state + self.private_endpoint_connections = None + self.routing_preference = routing_preference + self.blob_restore_status = None + self.allow_blob_public_access = allow_blob_public_access + self.minimum_tls_version = minimum_tls_version + self.allow_shared_key_access = allow_shared_key_access + self.enable_nfs_v3 = enable_nfs_v3 + self.allow_cross_tenant_replication = allow_cross_tenant_replication + self.default_to_o_auth_authentication = default_to_o_auth_authentication + self.public_network_access = public_network_access + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.allowed_copy_scope = allowed_copy_scope + self.storage_account_sku_conversion_status = storage_account_sku_conversion_status + self.dns_endpoint_type = dns_endpoint_type + + +class StorageAccountCheckNameAvailabilityParameters(_serialization.Model): + """The parameters used to check the availability of the storage account name. + + Variables are only populated by the server, and will be ignored when sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar name: The storage account name. Required. + :vartype name: str + :ivar type: The type of resource, Microsoft.Storage/storageAccounts. Required. Default value is + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + "name": {"required": True}, + "type": {"required": True, "constant": True}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + } + + type = "Microsoft.Storage/storageAccounts" + + def __init__(self, *, name: str, **kwargs): + """ + :keyword name: The storage account name. Required. + :paramtype name: str + """ + super().__init__(**kwargs) + self.name = name + + +class StorageAccountCreateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The parameters used when creating a storage account. + + All required parameters must be populated in order to send to Azure. + + :ivar sku: Required. Gets or sets the SKU name. Required. + :vartype sku: ~azure.mgmt.storage.v2022_09_01.models.Sku + :ivar kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2022_09_01.models.Kind + :ivar location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. + :vartype location: str + :ivar extended_location: Optional. Set the extended location of the resource. If not set, the + storage account will be created in Azure main region. Otherwise it will be created in the + specified extended location. + :vartype extended_location: ~azure.mgmt.storage.v2022_09_01.models.ExtendedLocation + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used for viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. + :vartype tags: dict[str, str] + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.storage.v2022_09_01.models.Identity + :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_09_01.models.AllowedCopyScope + :ivar public_network_access: Allow or disallow public network access to Storage Account. Value + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and + "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.storage.v2022_09_01.models.PublicNetworkAccess + :ivar sas_policy: SasPolicy assigned to the storage account. + :vartype sas_policy: ~azure.mgmt.storage.v2022_09_01.models.SasPolicy + :ivar key_policy: KeyPolicy assigned to the storage account. + :vartype key_policy: ~azure.mgmt.storage.v2022_09_01.models.KeyPolicy + :ivar custom_domain: User domain assigned to the storage account. Name is the CNAME source. + Only one custom domain is supported per storage account at this time. To clear the existing + custom domain, use an empty string for the custom domain name property. + :vartype custom_domain: ~azure.mgmt.storage.v2022_09_01.models.CustomDomain + :ivar encryption: Encryption settings to be used for server-side encryption for the storage + account. + :vartype encryption: ~azure.mgmt.storage.v2022_09_01.models.Encryption + :ivar network_rule_set: Network rule set. + :vartype network_rule_set: ~azure.mgmt.storage.v2022_09_01.models.NetworkRuleSet + :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is + used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", and "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2022_09_01.models.AccessTier + :ivar azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :vartype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_09_01.models.AzureFilesIdentityBasedAuthentication + :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. + The default value is true since API version 2019-04-01. + :vartype enable_https_traffic_only: bool + :ivar is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :vartype is_sftp_enabled: bool + :ivar is_local_user_enabled: Enables local users feature, if set to true. + :vartype is_local_user_enabled: bool + :ivar is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :vartype is_hns_enabled: bool + :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :vartype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_09_01.models.LargeFileSharesState + :ivar routing_preference: Maintains information about the network routing choice opted by the + user for data transfer. + :vartype routing_preference: ~azure.mgmt.storage.v2022_09_01.models.RoutingPreference + :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in + the storage account. The default interpretation is true for this property. + :vartype allow_blob_public_access: bool + :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + and "TLS1_2". + :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2022_09_01.models.MinimumTlsVersion + :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :vartype allow_shared_key_access: bool + :ivar enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :vartype enable_nfs_v3: bool + :ivar allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :vartype allow_cross_tenant_replication: bool + :ivar default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :vartype default_to_o_auth_authentication: bool + :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true + at the account creation time. When set to true, it enables object level immutability for all + the new containers in the account by default. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_09_01.models.ImmutableStorageAccount + :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone + to create a large number of accounts in a single subscription, which creates accounts in an + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard" and "AzureDnsZone". + :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_09_01.models.DnsEndpointType + """ + + _validation = { + "sku": {"required": True}, + "kind": {"required": True}, + "location": {"required": True}, + } + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "kind": {"key": "kind", "type": "str"}, + "location": {"key": "location", "type": "str"}, + "extended_location": {"key": "extendedLocation", "type": "ExtendedLocation"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "is_hns_enabled": {"key": "properties.isHnsEnabled", "type": "bool"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "enable_nfs_v3": {"key": "properties.isNfsV3Enabled", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + sku: "_models.Sku", + kind: Union[str, "_models.Kind"], + location: str, + extended_location: Optional["_models.ExtendedLocation"] = None, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, + enable_https_traffic_only: Optional[bool] = None, + is_sftp_enabled: Optional[bool] = None, + is_local_user_enabled: Optional[bool] = None, + is_hns_enabled: Optional[bool] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, + allow_blob_public_access: Optional[bool] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + allow_shared_key_access: Optional[bool] = None, + enable_nfs_v3: Optional[bool] = None, + allow_cross_tenant_replication: Optional[bool] = None, + default_to_o_auth_authentication: Optional[bool] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, + **kwargs + ): + """ + :keyword sku: Required. Gets or sets the SKU name. Required. + :paramtype sku: ~azure.mgmt.storage.v2022_09_01.models.Sku + :keyword kind: Required. Indicates the type of storage account. Required. Known values are: + "Storage", "StorageV2", "BlobStorage", "FileStorage", and "BlockBlobStorage". + :paramtype kind: str or ~azure.mgmt.storage.v2022_09_01.models.Kind + :keyword location: Required. Gets or sets the location of the resource. This will be one of the + supported and registered Azure Geo Regions (e.g. West US, East US, Southeast Asia, etc.). The + geo region of a resource cannot be changed once it is created, but if an identical geo region + is specified on update, the request will succeed. Required. + :paramtype location: str + :keyword extended_location: Optional. Set the extended location of the resource. If not set, + the storage account will be created in Azure main region. Otherwise it will be created in the + specified extended location. + :paramtype extended_location: ~azure.mgmt.storage.v2022_09_01.models.ExtendedLocation + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used for viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key with a length no greater than 128 + characters and a value with a length no greater than 256 characters. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.storage.v2022_09_01.models.Identity + :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_09_01.models.AllowedCopyScope + :keyword public_network_access: Allow or disallow public network access to Storage Account. + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: + "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.storage.v2022_09_01.models.PublicNetworkAccess + :keyword sas_policy: SasPolicy assigned to the storage account. + :paramtype sas_policy: ~azure.mgmt.storage.v2022_09_01.models.SasPolicy + :keyword key_policy: KeyPolicy assigned to the storage account. + :paramtype key_policy: ~azure.mgmt.storage.v2022_09_01.models.KeyPolicy + :keyword custom_domain: User domain assigned to the storage account. Name is the CNAME source. + Only one custom domain is supported per storage account at this time. To clear the existing + custom domain, use an empty string for the custom domain name property. + :paramtype custom_domain: ~azure.mgmt.storage.v2022_09_01.models.CustomDomain + :keyword encryption: Encryption settings to be used for server-side encryption for the storage + account. + :paramtype encryption: ~azure.mgmt.storage.v2022_09_01.models.Encryption + :keyword network_rule_set: Network rule set. + :paramtype network_rule_set: ~azure.mgmt.storage.v2022_09_01.models.NetworkRuleSet + :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier + is used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", and "Premium". + :paramtype access_tier: str or ~azure.mgmt.storage.v2022_09_01.models.AccessTier + :keyword azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :paramtype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_09_01.models.AzureFilesIdentityBasedAuthentication + :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to + true. The default value is true since API version 2019-04-01. + :paramtype enable_https_traffic_only: bool + :keyword is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :paramtype is_sftp_enabled: bool + :keyword is_local_user_enabled: Enables local users feature, if set to true. + :paramtype is_local_user_enabled: bool + :keyword is_hns_enabled: Account HierarchicalNamespace enabled if sets to true. + :paramtype is_hns_enabled: bool + :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :paramtype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_09_01.models.LargeFileSharesState + :keyword routing_preference: Maintains information about the network routing choice opted by + the user for data transfer. + :paramtype routing_preference: ~azure.mgmt.storage.v2022_09_01.models.RoutingPreference + :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers + in the storage account. The default interpretation is true for this property. + :paramtype allow_blob_public_access: bool + :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", and "TLS1_2". + :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2022_09_01.models.MinimumTlsVersion + :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :paramtype allow_shared_key_access: bool + :keyword enable_nfs_v3: NFS 3.0 protocol support enabled if set to true. + :paramtype enable_nfs_v3: bool + :keyword allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :paramtype allow_cross_tenant_replication: bool + :keyword default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :paramtype default_to_o_auth_authentication: bool + :keyword immutable_storage_with_versioning: The property is immutable and can only be set to + true at the account creation time. When set to true, it enables object level immutability for + all the new containers in the account by default. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_09_01.models.ImmutableStorageAccount + :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to + AzureDNSZone to create a large number of accounts in a single subscription, which creates + accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone + identifier. Known values are: "Standard" and "AzureDnsZone". + :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_09_01.models.DnsEndpointType + """ + super().__init__(**kwargs) + self.sku = sku + self.kind = kind + self.location = location + self.extended_location = extended_location + self.tags = tags + self.identity = identity + self.allowed_copy_scope = allowed_copy_scope + self.public_network_access = public_network_access + self.sas_policy = sas_policy + self.key_policy = key_policy + self.custom_domain = custom_domain + self.encryption = encryption + self.network_rule_set = network_rule_set + self.access_tier = access_tier + self.azure_files_identity_based_authentication = azure_files_identity_based_authentication + self.enable_https_traffic_only = enable_https_traffic_only + self.is_sftp_enabled = is_sftp_enabled + self.is_local_user_enabled = is_local_user_enabled + self.is_hns_enabled = is_hns_enabled + self.large_file_shares_state = large_file_shares_state + self.routing_preference = routing_preference + self.allow_blob_public_access = allow_blob_public_access + self.minimum_tls_version = minimum_tls_version + self.allow_shared_key_access = allow_shared_key_access + self.enable_nfs_v3 = enable_nfs_v3 + self.allow_cross_tenant_replication = allow_cross_tenant_replication + self.default_to_o_auth_authentication = default_to_o_auth_authentication + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.dns_endpoint_type = dns_endpoint_type + + +class StorageAccountInternetEndpoints(_serialization.Model): + """The URIs that are used to perform a retrieval of a public blob, file, web or dfs object via a internet routing endpoint. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar blob: Gets the blob endpoint. + :vartype blob: str + :ivar file: Gets the file endpoint. + :vartype file: str + :ivar web: Gets the web endpoint. + :vartype web: str + :ivar dfs: Gets the dfs endpoint. + :vartype dfs: str + """ + + _validation = { + "blob": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, + } + + _attribute_map = { + "blob": {"key": "blob", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.blob = None + self.file = None + self.web = None + self.dfs = None + + +class StorageAccountKey(_serialization.Model): + """An access key for the storage account. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar key_name: Name of the key. + :vartype key_name: str + :ivar value: Base 64-encoded value of the key. + :vartype value: str + :ivar permissions: Permissions for the key -- read-only or full permissions. Known values are: + "Read" and "Full". + :vartype permissions: str or ~azure.mgmt.storage.v2022_09_01.models.KeyPermission + :ivar creation_time: Creation time of the key, in round trip date format. + :vartype creation_time: ~datetime.datetime + """ + + _validation = { + "key_name": {"readonly": True}, + "value": {"readonly": True}, + "permissions": {"readonly": True}, + "creation_time": {"readonly": True}, + } + + _attribute_map = { + "key_name": {"key": "keyName", "type": "str"}, + "value": {"key": "value", "type": "str"}, + "permissions": {"key": "permissions", "type": "str"}, + "creation_time": {"key": "creationTime", "type": "iso-8601"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.key_name = None + self.value = None + self.permissions = None + self.creation_time = None + + +class StorageAccountListKeysResult(_serialization.Model): + """The response from the ListKeys operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar keys: Gets the list of storage account keys and their properties for the specified + storage account. + :vartype keys: list[~azure.mgmt.storage.v2022_09_01.models.StorageAccountKey] + """ + + _validation = { + "keys": {"readonly": True}, + } + + _attribute_map = { + "keys": {"key": "keys", "type": "[StorageAccountKey]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.keys = None + + +class StorageAccountListResult(_serialization.Model): + """The response from the List Storage Accounts operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets the list of storage accounts and their properties. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] + :ivar next_link: Request URL that can be used to query next page of storage accounts. Returned + when total number of requested storage accounts exceed maximum page size. + :vartype next_link: str + """ + + _validation = { + "value": {"readonly": True}, + "next_link": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[StorageAccount]"}, + "next_link": {"key": "nextLink", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.next_link = None + + +class StorageAccountMicrosoftEndpoints(_serialization.Model): + """The URIs that are used to perform a retrieval of a public blob, queue, table, web or dfs object via a microsoft routing endpoint. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar blob: Gets the blob endpoint. + :vartype blob: str + :ivar queue: Gets the queue endpoint. + :vartype queue: str + :ivar table: Gets the table endpoint. + :vartype table: str + :ivar file: Gets the file endpoint. + :vartype file: str + :ivar web: Gets the web endpoint. + :vartype web: str + :ivar dfs: Gets the dfs endpoint. + :vartype dfs: str + """ + + _validation = { + "blob": {"readonly": True}, + "queue": {"readonly": True}, + "table": {"readonly": True}, + "file": {"readonly": True}, + "web": {"readonly": True}, + "dfs": {"readonly": True}, + } + + _attribute_map = { + "blob": {"key": "blob", "type": "str"}, + "queue": {"key": "queue", "type": "str"}, + "table": {"key": "table", "type": "str"}, + "file": {"key": "file", "type": "str"}, + "web": {"key": "web", "type": "str"}, + "dfs": {"key": "dfs", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.blob = None + self.queue = None + self.table = None + self.file = None + self.web = None + self.dfs = None + + +class StorageAccountRegenerateKeyParameters(_serialization.Model): + """The parameters used to regenerate the storage account key. + + All required parameters must be populated in order to send to Azure. + + :ivar key_name: The name of storage keys that want to be regenerated, possible values are key1, + key2, kerb1, kerb2. Required. + :vartype key_name: str + """ + + _validation = { + "key_name": {"required": True}, + } + + _attribute_map = { + "key_name": {"key": "keyName", "type": "str"}, + } + + def __init__(self, *, key_name: str, **kwargs): + """ + :keyword key_name: The name of storage keys that want to be regenerated, possible values are + key1, key2, kerb1, kerb2. Required. + :paramtype key_name: str + """ + super().__init__(**kwargs) + self.key_name = key_name + + +class StorageAccountSkuConversionStatus(_serialization.Model): + """This defines the sku conversion status object for asynchronous sku conversions. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar sku_conversion_status: This property indicates the current sku conversion status. Known + values are: "InProgress", "Succeeded", and "Failed". + :vartype sku_conversion_status: str or + ~azure.mgmt.storage.v2022_09_01.models.SkuConversionStatus + :ivar target_sku_name: This property represents the target sku name to which the account sku is + being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", + "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", and + "Standard_RAGZRS". + :vartype target_sku_name: str or ~azure.mgmt.storage.v2022_09_01.models.SkuName + :ivar start_time: This property represents the sku conversion start time. + :vartype start_time: str + :ivar end_time: This property represents the sku conversion end time. + :vartype end_time: str + """ + + _validation = { + "sku_conversion_status": {"readonly": True}, + "start_time": {"readonly": True}, + "end_time": {"readonly": True}, + } + + _attribute_map = { + "sku_conversion_status": {"key": "skuConversionStatus", "type": "str"}, + "target_sku_name": {"key": "targetSkuName", "type": "str"}, + "start_time": {"key": "startTime", "type": "str"}, + "end_time": {"key": "endTime", "type": "str"}, + } + + def __init__(self, *, target_sku_name: Optional[Union[str, "_models.SkuName"]] = None, **kwargs): + """ + :keyword target_sku_name: This property represents the target sku name to which the account sku + is being converted asynchronously. Known values are: "Standard_LRS", "Standard_GRS", + "Standard_RAGRS", "Standard_ZRS", "Premium_LRS", "Premium_ZRS", "Standard_GZRS", and + "Standard_RAGZRS". + :paramtype target_sku_name: str or ~azure.mgmt.storage.v2022_09_01.models.SkuName + """ + super().__init__(**kwargs) + self.sku_conversion_status = None + self.target_sku_name = target_sku_name + self.start_time = None + self.end_time = None + + +class StorageAccountUpdateParameters(_serialization.Model): # pylint: disable=too-many-instance-attributes + """The parameters that can be provided when updating the storage account properties. + + :ivar sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to Standard_ZRS, + Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any other value. + :vartype sku: ~azure.mgmt.storage.v2022_09_01.models.Sku + :ivar tags: Gets or sets a list of key value pairs that describe the resource. These tags can + be used in viewing and grouping this resource (across resource groups). A maximum of 15 tags + can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. + :vartype tags: dict[str, str] + :ivar identity: The identity of the resource. + :vartype identity: ~azure.mgmt.storage.v2022_09_01.models.Identity + :ivar kind: Optional. Indicates the type of storage account. Currently only StorageV2 value + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + and "BlockBlobStorage". + :vartype kind: str or ~azure.mgmt.storage.v2022_09_01.models.Kind + :ivar custom_domain: Custom domain assigned to the storage account by the user. Name is the + CNAME source. Only one custom domain is supported per storage account at this time. To clear + the existing custom domain, use an empty string for the custom domain name property. + :vartype custom_domain: ~azure.mgmt.storage.v2022_09_01.models.CustomDomain + :ivar encryption: Not applicable. Azure Storage encryption at rest is enabled by default for + all storage accounts and cannot be disabled. + :vartype encryption: ~azure.mgmt.storage.v2022_09_01.models.Encryption + :ivar sas_policy: SasPolicy assigned to the storage account. + :vartype sas_policy: ~azure.mgmt.storage.v2022_09_01.models.SasPolicy + :ivar key_policy: KeyPolicy assigned to the storage account. + :vartype key_policy: ~azure.mgmt.storage.v2022_09_01.models.KeyPolicy + :ivar access_tier: Required for storage accounts where kind = BlobStorage. The access tier is + used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", and "Premium". + :vartype access_tier: str or ~azure.mgmt.storage.v2022_09_01.models.AccessTier + :ivar azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :vartype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_09_01.models.AzureFilesIdentityBasedAuthentication + :ivar enable_https_traffic_only: Allows https traffic only to storage service if sets to true. + :vartype enable_https_traffic_only: bool + :ivar is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :vartype is_sftp_enabled: bool + :ivar is_local_user_enabled: Enables local users feature, if set to true. + :vartype is_local_user_enabled: bool + :ivar network_rule_set: Network rule set. + :vartype network_rule_set: ~azure.mgmt.storage.v2022_09_01.models.NetworkRuleSet + :ivar large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :vartype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_09_01.models.LargeFileSharesState + :ivar routing_preference: Maintains information about the network routing choice opted by the + user for data transfer. + :vartype routing_preference: ~azure.mgmt.storage.v2022_09_01.models.RoutingPreference + :ivar allow_blob_public_access: Allow or disallow public access to all blobs or containers in + the storage account. The default interpretation is true for this property. + :vartype allow_blob_public_access: bool + :ivar minimum_tls_version: Set the minimum TLS version to be permitted on requests to storage. + The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", "TLS1_1", + and "TLS1_2". + :vartype minimum_tls_version: str or ~azure.mgmt.storage.v2022_09_01.models.MinimumTlsVersion + :ivar allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :vartype allow_shared_key_access: bool + :ivar allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :vartype allow_cross_tenant_replication: bool + :ivar default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :vartype default_to_o_auth_authentication: bool + :ivar public_network_access: Allow or disallow public network access to Storage Account. Value + is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: "Enabled" and + "Disabled". + :vartype public_network_access: str or + ~azure.mgmt.storage.v2022_09_01.models.PublicNetworkAccess + :ivar immutable_storage_with_versioning: The property is immutable and can only be set to true + at the account creation time. When set to true, it enables object level immutability for all + the containers in the account by default. + :vartype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_09_01.models.ImmutableStorageAccount + :ivar allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :vartype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_09_01.models.AllowedCopyScope + :ivar dns_endpoint_type: Allows you to specify the type of endpoint. Set this to AzureDNSZone + to create a large number of accounts in a single subscription, which creates accounts in an + Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone identifier. Known values + are: "Standard" and "AzureDnsZone". + :vartype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_09_01.models.DnsEndpointType + """ + + _attribute_map = { + "sku": {"key": "sku", "type": "Sku"}, + "tags": {"key": "tags", "type": "{str}"}, + "identity": {"key": "identity", "type": "Identity"}, + "kind": {"key": "kind", "type": "str"}, + "custom_domain": {"key": "properties.customDomain", "type": "CustomDomain"}, + "encryption": {"key": "properties.encryption", "type": "Encryption"}, + "sas_policy": {"key": "properties.sasPolicy", "type": "SasPolicy"}, + "key_policy": {"key": "properties.keyPolicy", "type": "KeyPolicy"}, + "access_tier": {"key": "properties.accessTier", "type": "str"}, + "azure_files_identity_based_authentication": { + "key": "properties.azureFilesIdentityBasedAuthentication", + "type": "AzureFilesIdentityBasedAuthentication", + }, + "enable_https_traffic_only": {"key": "properties.supportsHttpsTrafficOnly", "type": "bool"}, + "is_sftp_enabled": {"key": "properties.isSftpEnabled", "type": "bool"}, + "is_local_user_enabled": {"key": "properties.isLocalUserEnabled", "type": "bool"}, + "network_rule_set": {"key": "properties.networkAcls", "type": "NetworkRuleSet"}, + "large_file_shares_state": {"key": "properties.largeFileSharesState", "type": "str"}, + "routing_preference": {"key": "properties.routingPreference", "type": "RoutingPreference"}, + "allow_blob_public_access": {"key": "properties.allowBlobPublicAccess", "type": "bool"}, + "minimum_tls_version": {"key": "properties.minimumTlsVersion", "type": "str"}, + "allow_shared_key_access": {"key": "properties.allowSharedKeyAccess", "type": "bool"}, + "allow_cross_tenant_replication": {"key": "properties.allowCrossTenantReplication", "type": "bool"}, + "default_to_o_auth_authentication": {"key": "properties.defaultToOAuthAuthentication", "type": "bool"}, + "public_network_access": {"key": "properties.publicNetworkAccess", "type": "str"}, + "immutable_storage_with_versioning": { + "key": "properties.immutableStorageWithVersioning", + "type": "ImmutableStorageAccount", + }, + "allowed_copy_scope": {"key": "properties.allowedCopyScope", "type": "str"}, + "dns_endpoint_type": {"key": "properties.dnsEndpointType", "type": "str"}, + } + + def __init__( # pylint: disable=too-many-locals + self, + *, + sku: Optional["_models.Sku"] = None, + tags: Optional[Dict[str, str]] = None, + identity: Optional["_models.Identity"] = None, + kind: Optional[Union[str, "_models.Kind"]] = None, + custom_domain: Optional["_models.CustomDomain"] = None, + encryption: Optional["_models.Encryption"] = None, + sas_policy: Optional["_models.SasPolicy"] = None, + key_policy: Optional["_models.KeyPolicy"] = None, + access_tier: Optional[Union[str, "_models.AccessTier"]] = None, + azure_files_identity_based_authentication: Optional["_models.AzureFilesIdentityBasedAuthentication"] = None, + enable_https_traffic_only: Optional[bool] = None, + is_sftp_enabled: Optional[bool] = None, + is_local_user_enabled: Optional[bool] = None, + network_rule_set: Optional["_models.NetworkRuleSet"] = None, + large_file_shares_state: Optional[Union[str, "_models.LargeFileSharesState"]] = None, + routing_preference: Optional["_models.RoutingPreference"] = None, + allow_blob_public_access: Optional[bool] = None, + minimum_tls_version: Optional[Union[str, "_models.MinimumTlsVersion"]] = None, + allow_shared_key_access: Optional[bool] = None, + allow_cross_tenant_replication: Optional[bool] = None, + default_to_o_auth_authentication: Optional[bool] = None, + public_network_access: Optional[Union[str, "_models.PublicNetworkAccess"]] = None, + immutable_storage_with_versioning: Optional["_models.ImmutableStorageAccount"] = None, + allowed_copy_scope: Optional[Union[str, "_models.AllowedCopyScope"]] = None, + dns_endpoint_type: Optional[Union[str, "_models.DnsEndpointType"]] = None, + **kwargs + ): + """ + :keyword sku: Gets or sets the SKU name. Note that the SKU name cannot be updated to + Standard_ZRS, Premium_LRS or Premium_ZRS, nor can accounts of those SKU names be updated to any + other value. + :paramtype sku: ~azure.mgmt.storage.v2022_09_01.models.Sku + :keyword tags: Gets or sets a list of key value pairs that describe the resource. These tags + can be used in viewing and grouping this resource (across resource groups). A maximum of 15 + tags can be provided for a resource. Each tag must have a key no greater in length than 128 + characters and a value no greater in length than 256 characters. + :paramtype tags: dict[str, str] + :keyword identity: The identity of the resource. + :paramtype identity: ~azure.mgmt.storage.v2022_09_01.models.Identity + :keyword kind: Optional. Indicates the type of storage account. Currently only StorageV2 value + supported by server. Known values are: "Storage", "StorageV2", "BlobStorage", "FileStorage", + and "BlockBlobStorage". + :paramtype kind: str or ~azure.mgmt.storage.v2022_09_01.models.Kind + :keyword custom_domain: Custom domain assigned to the storage account by the user. Name is the + CNAME source. Only one custom domain is supported per storage account at this time. To clear + the existing custom domain, use an empty string for the custom domain name property. + :paramtype custom_domain: ~azure.mgmt.storage.v2022_09_01.models.CustomDomain + :keyword encryption: Not applicable. Azure Storage encryption at rest is enabled by default for + all storage accounts and cannot be disabled. + :paramtype encryption: ~azure.mgmt.storage.v2022_09_01.models.Encryption + :keyword sas_policy: SasPolicy assigned to the storage account. + :paramtype sas_policy: ~azure.mgmt.storage.v2022_09_01.models.SasPolicy + :keyword key_policy: KeyPolicy assigned to the storage account. + :paramtype key_policy: ~azure.mgmt.storage.v2022_09_01.models.KeyPolicy + :keyword access_tier: Required for storage accounts where kind = BlobStorage. The access tier + is used for billing. The 'Premium' access tier is the default value for premium block blobs + storage account type and it cannot be changed for the premium block blobs storage account type. + Known values are: "Hot", "Cool", and "Premium". + :paramtype access_tier: str or ~azure.mgmt.storage.v2022_09_01.models.AccessTier + :keyword azure_files_identity_based_authentication: Provides the identity based authentication + settings for Azure Files. + :paramtype azure_files_identity_based_authentication: + ~azure.mgmt.storage.v2022_09_01.models.AzureFilesIdentityBasedAuthentication + :keyword enable_https_traffic_only: Allows https traffic only to storage service if sets to + true. + :paramtype enable_https_traffic_only: bool + :keyword is_sftp_enabled: Enables Secure File Transfer Protocol, if set to true. + :paramtype is_sftp_enabled: bool + :keyword is_local_user_enabled: Enables local users feature, if set to true. + :paramtype is_local_user_enabled: bool + :keyword network_rule_set: Network rule set. + :paramtype network_rule_set: ~azure.mgmt.storage.v2022_09_01.models.NetworkRuleSet + :keyword large_file_shares_state: Allow large file shares if sets to Enabled. It cannot be + disabled once it is enabled. Known values are: "Disabled" and "Enabled". + :paramtype large_file_shares_state: str or + ~azure.mgmt.storage.v2022_09_01.models.LargeFileSharesState + :keyword routing_preference: Maintains information about the network routing choice opted by + the user for data transfer. + :paramtype routing_preference: ~azure.mgmt.storage.v2022_09_01.models.RoutingPreference + :keyword allow_blob_public_access: Allow or disallow public access to all blobs or containers + in the storage account. The default interpretation is true for this property. + :paramtype allow_blob_public_access: bool + :keyword minimum_tls_version: Set the minimum TLS version to be permitted on requests to + storage. The default interpretation is TLS 1.0 for this property. Known values are: "TLS1_0", + "TLS1_1", and "TLS1_2". + :paramtype minimum_tls_version: str or ~azure.mgmt.storage.v2022_09_01.models.MinimumTlsVersion + :keyword allow_shared_key_access: Indicates whether the storage account permits requests to be + authorized with the account access key via Shared Key. If false, then all requests, including + shared access signatures, must be authorized with Azure Active Directory (Azure AD). The + default value is null, which is equivalent to true. + :paramtype allow_shared_key_access: bool + :keyword allow_cross_tenant_replication: Allow or disallow cross AAD tenant object replication. + The default interpretation is true for this property. + :paramtype allow_cross_tenant_replication: bool + :keyword default_to_o_auth_authentication: A boolean flag which indicates whether the default + authentication is OAuth or not. The default interpretation is false for this property. + :paramtype default_to_o_auth_authentication: bool + :keyword public_network_access: Allow or disallow public network access to Storage Account. + Value is optional but if passed in, must be 'Enabled' or 'Disabled'. Known values are: + "Enabled" and "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.storage.v2022_09_01.models.PublicNetworkAccess + :keyword immutable_storage_with_versioning: The property is immutable and can only be set to + true at the account creation time. When set to true, it enables object level immutability for + all the containers in the account by default. + :paramtype immutable_storage_with_versioning: + ~azure.mgmt.storage.v2022_09_01.models.ImmutableStorageAccount + :keyword allowed_copy_scope: Restrict copy to and from Storage Accounts within an AAD tenant or + with Private Links to the same VNet. Known values are: "PrivateLink" and "AAD". + :paramtype allowed_copy_scope: str or ~azure.mgmt.storage.v2022_09_01.models.AllowedCopyScope + :keyword dns_endpoint_type: Allows you to specify the type of endpoint. Set this to + AzureDNSZone to create a large number of accounts in a single subscription, which creates + accounts in an Azure DNS Zone and the endpoint URL will have an alphanumeric DNS Zone + identifier. Known values are: "Standard" and "AzureDnsZone". + :paramtype dns_endpoint_type: str or ~azure.mgmt.storage.v2022_09_01.models.DnsEndpointType + """ + super().__init__(**kwargs) + self.sku = sku + self.tags = tags + self.identity = identity + self.kind = kind + self.custom_domain = custom_domain + self.encryption = encryption + self.sas_policy = sas_policy + self.key_policy = key_policy + self.access_tier = access_tier + self.azure_files_identity_based_authentication = azure_files_identity_based_authentication + self.enable_https_traffic_only = enable_https_traffic_only + self.is_sftp_enabled = is_sftp_enabled + self.is_local_user_enabled = is_local_user_enabled + self.network_rule_set = network_rule_set + self.large_file_shares_state = large_file_shares_state + self.routing_preference = routing_preference + self.allow_blob_public_access = allow_blob_public_access + self.minimum_tls_version = minimum_tls_version + self.allow_shared_key_access = allow_shared_key_access + self.allow_cross_tenant_replication = allow_cross_tenant_replication + self.default_to_o_auth_authentication = default_to_o_auth_authentication + self.public_network_access = public_network_access + self.immutable_storage_with_versioning = immutable_storage_with_versioning + self.allowed_copy_scope = allowed_copy_scope + self.dns_endpoint_type = dns_endpoint_type + + +class StorageQueue(Resource): + """StorageQueue. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar metadata: A name-value pair that represents queue metadata. + :vartype metadata: dict[str, str] + :ivar approximate_message_count: Integer indicating an approximate number of messages in the + queue. This number is not lower than the actual number of messages in the queue, but could be + higher. + :vartype approximate_message_count: int + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "approximate_message_count": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "metadata": {"key": "properties.metadata", "type": "{str}"}, + "approximate_message_count": {"key": "properties.approximateMessageCount", "type": "int"}, + } + + def __init__(self, *, metadata: Optional[Dict[str, str]] = None, **kwargs): + """ + :keyword metadata: A name-value pair that represents queue metadata. + :paramtype metadata: dict[str, str] + """ + super().__init__(**kwargs) + self.metadata = metadata + self.approximate_message_count = None + + +class StorageSkuListResult(_serialization.Model): + """The response from the List Storage SKUs operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Get the list result of storage SKUs and their properties. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.SkuInformation] + """ + + _validation = { + "value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "[SkuInformation]"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = 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.storage.v2022_09_01.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.storage.v2022_09_01.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 + ): + """ + :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.storage.v2022_09_01.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.storage.v2022_09_01.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 Table(Resource): + """Properties of the table, including Id, resource name, resource type. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar table_name: Table name under the specified account. + :vartype table_name: str + :ivar signed_identifiers: List of stored access policies specified on the table. + :vartype signed_identifiers: list[~azure.mgmt.storage.v2022_09_01.models.TableSignedIdentifier] + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + "table_name": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "table_name": {"key": "properties.tableName", "type": "str"}, + "signed_identifiers": {"key": "properties.signedIdentifiers", "type": "[TableSignedIdentifier]"}, + } + + def __init__(self, *, signed_identifiers: Optional[List["_models.TableSignedIdentifier"]] = None, **kwargs): + """ + :keyword signed_identifiers: List of stored access policies specified on the table. + :paramtype signed_identifiers: + list[~azure.mgmt.storage.v2022_09_01.models.TableSignedIdentifier] + """ + super().__init__(**kwargs) + self.table_name = None + self.signed_identifiers = signed_identifiers + + +class TableAccessPolicy(_serialization.Model): + """Table Access Policy Properties Object. + + All required parameters must be populated in order to send to Azure. + + :ivar start_time: Start time of the access policy. + :vartype start_time: ~datetime.datetime + :ivar expiry_time: Expiry time of the access policy. + :vartype expiry_time: ~datetime.datetime + :ivar permission: Required. List of abbreviated permissions. Supported permission values + include 'r','a','u','d'. Required. + :vartype permission: str + """ + + _validation = { + "permission": {"required": True}, + } + + _attribute_map = { + "start_time": {"key": "startTime", "type": "iso-8601"}, + "expiry_time": {"key": "expiryTime", "type": "iso-8601"}, + "permission": {"key": "permission", "type": "str"}, + } + + def __init__( + self, + *, + permission: str, + start_time: Optional[datetime.datetime] = None, + expiry_time: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword start_time: Start time of the access policy. + :paramtype start_time: ~datetime.datetime + :keyword expiry_time: Expiry time of the access policy. + :paramtype expiry_time: ~datetime.datetime + :keyword permission: Required. List of abbreviated permissions. Supported permission values + include 'r','a','u','d'. Required. + :paramtype permission: str + """ + super().__init__(**kwargs) + self.start_time = start_time + self.expiry_time = expiry_time + self.permission = permission + + +class TableServiceProperties(Resource): + """The properties of a storage account’s Table service. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar cors: Specifies CORS rules for the Table service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Table service. + :vartype cors: ~azure.mgmt.storage.v2022_09_01.models.CorsRules + """ + + _validation = { + "id": {"readonly": True}, + "name": {"readonly": True}, + "type": {"readonly": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "name": {"key": "name", "type": "str"}, + "type": {"key": "type", "type": "str"}, + "cors": {"key": "properties.cors", "type": "CorsRules"}, + } + + def __init__(self, *, cors: Optional["_models.CorsRules"] = None, **kwargs): + """ + :keyword cors: Specifies CORS rules for the Table service. You can include up to five CorsRule + elements in the request. If no CorsRule elements are included in the request body, all CORS + rules will be deleted, and CORS will be disabled for the Table service. + :paramtype cors: ~azure.mgmt.storage.v2022_09_01.models.CorsRules + """ + super().__init__(**kwargs) + self.cors = cors + + +class TableSignedIdentifier(_serialization.Model): + """Object to set Table Access Policy. + + All required parameters must be populated in order to send to Azure. + + :ivar id: unique-64-character-value of the stored access policy. Required. + :vartype id: str + :ivar access_policy: Access policy. + :vartype access_policy: ~azure.mgmt.storage.v2022_09_01.models.TableAccessPolicy + """ + + _validation = { + "id": {"required": True}, + } + + _attribute_map = { + "id": {"key": "id", "type": "str"}, + "access_policy": {"key": "accessPolicy", "type": "TableAccessPolicy"}, + } + + def __init__( + self, + *, + id: str, # pylint: disable=redefined-builtin + access_policy: Optional["_models.TableAccessPolicy"] = None, + **kwargs + ): + """ + :keyword id: unique-64-character-value of the stored access policy. Required. + :paramtype id: str + :keyword access_policy: Access policy. + :paramtype access_policy: ~azure.mgmt.storage.v2022_09_01.models.TableAccessPolicy + """ + super().__init__(**kwargs) + self.id = id + self.access_policy = access_policy + + +class TagFilter(_serialization.Model): + """Blob index tag based filtering for blob objects. + + All required parameters must be populated in order to send to Azure. + + :ivar name: This is the filter tag name, it can have 1 - 128 characters. Required. + :vartype name: str + :ivar op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. + :vartype op: str + :ivar value: This is the filter tag value field used for tag based filtering, it can have 0 - + 256 characters. Required. + :vartype value: str + """ + + _validation = { + "name": {"required": True, "max_length": 128, "min_length": 1}, + "op": {"required": True}, + "value": {"required": True, "max_length": 256}, + } + + _attribute_map = { + "name": {"key": "name", "type": "str"}, + "op": {"key": "op", "type": "str"}, + "value": {"key": "value", "type": "str"}, + } + + def __init__(self, *, name: str, op: str, value: str, **kwargs): + """ + :keyword name: This is the filter tag name, it can have 1 - 128 characters. Required. + :paramtype name: str + :keyword op: This is the comparison operator which is used for object comparison and filtering. + Only == (equality operator) is currently supported. Required. + :paramtype op: str + :keyword value: This is the filter tag value field used for tag based filtering, it can have 0 + - 256 characters. Required. + :paramtype value: str + """ + super().__init__(**kwargs) + self.name = name + self.op = op + self.value = value + + +class TagProperty(_serialization.Model): + """A tag of the LegalHold of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar tag: The tag value. + :vartype tag: str + :ivar timestamp: Returns the date and time the tag was added. + :vartype timestamp: ~datetime.datetime + :ivar object_identifier: Returns the Object ID of the user who added the tag. + :vartype object_identifier: str + :ivar tenant_id: Returns the Tenant ID that issued the token for the user who added the tag. + :vartype tenant_id: str + :ivar upn: Returns the User Principal Name of the user who added the tag. + :vartype upn: str + """ + + _validation = { + "tag": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, + } + + _attribute_map = { + "tag": {"key": "tag", "type": "str"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.tag = None + self.timestamp = None + self.object_identifier = None + self.tenant_id = None + self.upn = None + + +class UpdateHistoryProperty(_serialization.Model): + """An update history of the ImmutabilityPolicy of a blob container. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar update: The ImmutabilityPolicy update type of a blob container, possible values include: + put, lock and extend. Known values are: "put", "lock", and "extend". + :vartype update: str or ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicyUpdateType + :ivar immutability_period_since_creation_in_days: The immutability period for the blobs in the + container since the policy creation, in days. + :vartype immutability_period_since_creation_in_days: int + :ivar timestamp: Returns the date and time the ImmutabilityPolicy was updated. + :vartype timestamp: ~datetime.datetime + :ivar object_identifier: Returns the Object ID of the user who updated the ImmutabilityPolicy. + :vartype object_identifier: str + :ivar tenant_id: Returns the Tenant ID that issued the token for the user who updated the + ImmutabilityPolicy. + :vartype tenant_id: str + :ivar upn: Returns the User Principal Name of the user who updated the ImmutabilityPolicy. + :vartype upn: str + :ivar allow_protected_append_writes: This property can only be changed for unlocked time-based + retention policies. When enabled, new blocks can be written to an append blob while maintaining + immutability protection and compliance. Only new blocks can be added and any existing blocks + cannot be modified or deleted. This property cannot be changed with ExtendImmutabilityPolicy + API. + :vartype allow_protected_append_writes: bool + :ivar allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :vartype allow_protected_append_writes_all: bool + """ + + _validation = { + "update": {"readonly": True}, + "immutability_period_since_creation_in_days": {"readonly": True}, + "timestamp": {"readonly": True}, + "object_identifier": {"readonly": True}, + "tenant_id": {"readonly": True}, + "upn": {"readonly": True}, + } + + _attribute_map = { + "update": {"key": "update", "type": "str"}, + "immutability_period_since_creation_in_days": {"key": "immutabilityPeriodSinceCreationInDays", "type": "int"}, + "timestamp": {"key": "timestamp", "type": "iso-8601"}, + "object_identifier": {"key": "objectIdentifier", "type": "str"}, + "tenant_id": {"key": "tenantId", "type": "str"}, + "upn": {"key": "upn", "type": "str"}, + "allow_protected_append_writes": {"key": "allowProtectedAppendWrites", "type": "bool"}, + "allow_protected_append_writes_all": {"key": "allowProtectedAppendWritesAll", "type": "bool"}, + } + + def __init__( + self, + *, + allow_protected_append_writes: Optional[bool] = None, + allow_protected_append_writes_all: Optional[bool] = None, + **kwargs + ): + """ + :keyword allow_protected_append_writes: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to an append blob while + maintaining immutability protection and compliance. Only new blocks can be added and any + existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. + :paramtype allow_protected_append_writes: bool + :keyword allow_protected_append_writes_all: This property can only be changed for unlocked + time-based retention policies. When enabled, new blocks can be written to both 'Append and Bock + Blobs' while maintaining immutability protection and compliance. Only new blocks can be added + and any existing blocks cannot be modified or deleted. This property cannot be changed with + ExtendImmutabilityPolicy API. The 'allowProtectedAppendWrites' and + 'allowProtectedAppendWritesAll' properties are mutually exclusive. + :paramtype allow_protected_append_writes_all: bool + """ + super().__init__(**kwargs) + self.update = None + self.immutability_period_since_creation_in_days = None + self.timestamp = None + self.object_identifier = None + self.tenant_id = None + self.upn = None + self.allow_protected_append_writes = allow_protected_append_writes + self.allow_protected_append_writes_all = allow_protected_append_writes_all + + +class Usage(_serialization.Model): + """Describes Storage Resource Usage. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar unit: Gets the unit of measurement. Known values are: "Count", "Bytes", "Seconds", + "Percent", "CountsPerSecond", and "BytesPerSecond". + :vartype unit: str or ~azure.mgmt.storage.v2022_09_01.models.UsageUnit + :ivar current_value: Gets the current count of the allocated resources in the subscription. + :vartype current_value: int + :ivar limit: Gets the maximum count of the resources that can be allocated in the subscription. + :vartype limit: int + :ivar name: Gets the name of the type of usage. + :vartype name: ~azure.mgmt.storage.v2022_09_01.models.UsageName + """ + + _validation = { + "unit": {"readonly": True}, + "current_value": {"readonly": True}, + "limit": {"readonly": True}, + "name": {"readonly": True}, + } + + _attribute_map = { + "unit": {"key": "unit", "type": "str"}, + "current_value": {"key": "currentValue", "type": "int"}, + "limit": {"key": "limit", "type": "int"}, + "name": {"key": "name", "type": "UsageName"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.unit = None + self.current_value = None + self.limit = None + self.name = None + + +class UsageListResult(_serialization.Model): + """The response from the List Usages operation. + + :ivar value: Gets or sets the list of Storage Resource Usages. + :vartype value: list[~azure.mgmt.storage.v2022_09_01.models.Usage] + """ + + _attribute_map = { + "value": {"key": "value", "type": "[Usage]"}, + } + + def __init__(self, *, value: Optional[List["_models.Usage"]] = None, **kwargs): + """ + :keyword value: Gets or sets the list of Storage Resource Usages. + :paramtype value: list[~azure.mgmt.storage.v2022_09_01.models.Usage] + """ + super().__init__(**kwargs) + self.value = value + + +class UsageName(_serialization.Model): + """The usage names that can be used; currently limited to StorageAccount. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Gets a string describing the resource name. + :vartype value: str + :ivar localized_value: Gets a localized string describing the resource name. + :vartype localized_value: str + """ + + _validation = { + "value": {"readonly": True}, + "localized_value": {"readonly": True}, + } + + _attribute_map = { + "value": {"key": "value", "type": "str"}, + "localized_value": {"key": "localizedValue", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.value = None + self.localized_value = None + + +class UserAssignedIdentity(_serialization.Model): + """UserAssignedIdentity for the resource. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar principal_id: The principal ID of the identity. + :vartype principal_id: str + :ivar client_id: The client ID of the identity. + :vartype client_id: str + """ + + _validation = { + "principal_id": {"readonly": True}, + "client_id": {"readonly": True}, + } + + _attribute_map = { + "principal_id": {"key": "principalId", "type": "str"}, + "client_id": {"key": "clientId", "type": "str"}, + } + + def __init__(self, **kwargs): + """ """ + super().__init__(**kwargs) + self.principal_id = None + self.client_id = None + + +class VirtualNetworkRule(_serialization.Model): + """Virtual Network rule. + + All required parameters must be populated in order to send to Azure. + + :ivar virtual_network_resource_id: Resource ID of a subnet, for example: + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. + :vartype virtual_network_resource_id: str + :ivar action: The action of virtual network rule. Default value is "Allow". + :vartype action: str + :ivar state: Gets the state of virtual network rule. Known values are: "Provisioning", + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". + :vartype state: str or ~azure.mgmt.storage.v2022_09_01.models.State + """ + + _validation = { + "virtual_network_resource_id": {"required": True}, + } + + _attribute_map = { + "virtual_network_resource_id": {"key": "id", "type": "str"}, + "action": {"key": "action", "type": "str"}, + "state": {"key": "state", "type": "str"}, + } + + def __init__( + self, + *, + virtual_network_resource_id: str, + action: Optional[Literal["Allow"]] = None, + state: Optional[Union[str, "_models.State"]] = None, + **kwargs + ): + """ + :keyword virtual_network_resource_id: Resource ID of a subnet, for example: + /subscriptions/{subscriptionId}/resourceGroups/{groupName}/providers/Microsoft.Network/virtualNetworks/{vnetName}/subnets/{subnetName}. + Required. + :paramtype virtual_network_resource_id: str + :keyword action: The action of virtual network rule. Default value is "Allow". + :paramtype action: str + :keyword state: Gets the state of virtual network rule. Known values are: "Provisioning", + "Deprovisioning", "Succeeded", "Failed", and "NetworkSourceDeleted". + :paramtype state: str or ~azure.mgmt.storage.v2022_09_01.models.State + """ + super().__init__(**kwargs) + self.virtual_network_resource_id = virtual_network_resource_id + self.action = action + self.state = state diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_storage_management_client_enums.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_storage_management_client_enums.py new file mode 100644 index 000000000000..c78f74aa0c3d --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/models/_storage_management_client_enums.py @@ -0,0 +1,592 @@ +# 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 enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class AccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Required for storage accounts where kind = BlobStorage. The access tier is used for billing. + The 'Premium' access tier is the default value for premium block blobs storage account type and + it cannot be changed for the premium block blobs storage account type. + """ + + HOT = "Hot" + COOL = "Cool" + PREMIUM = "Premium" + + +class AccountImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The ImmutabilityPolicy state defines the mode of the policy. Disabled state disables the + policy, Unlocked state allows increase and decrease of immutability retention time and also + allows toggling allowProtectedAppendWrites property, Locked state only allows the increase of + the immutability retention time. A policy can only be created in a Disabled or Unlocked state + and can be toggled between the two states. Only a policy in an Unlocked state can transition to + a Locked state which cannot be reverted. + """ + + UNLOCKED = "Unlocked" + LOCKED = "Locked" + DISABLED = "Disabled" + + +class AccountStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the status indicating whether the primary location of the storage account is available or + unavailable. + """ + + AVAILABLE = "available" + UNAVAILABLE = "unavailable" + + +class AccountType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the Active Directory account type for Azure Storage.""" + + USER = "User" + COMPUTER = "Computer" + + +class AllowedCopyScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the + same VNet. + """ + + PRIVATE_LINK = "PrivateLink" + AAD = "AAD" + + +class AllowedMethods(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """AllowedMethods.""" + + DELETE = "DELETE" + GET = "GET" + HEAD = "HEAD" + MERGE = "MERGE" + POST = "POST" + OPTIONS = "OPTIONS" + PUT = "PUT" + PATCH = "PATCH" + + +class BlobInventoryPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """BlobInventoryPolicyName.""" + + DEFAULT = "default" + + +class BlobRestoreProgressStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of blob restore progress. Possible values are: - InProgress: Indicates that blob + restore is ongoing. - Complete: Indicates that blob restore has been completed successfully. - + Failed: Indicates that blob restore is failed. + """ + + IN_PROGRESS = "InProgress" + COMPLETE = "Complete" + FAILED = "Failed" + + +class Bypass(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies whether traffic is bypassed for Logging/Metrics/AzureServices. Possible values are + any combination of Logging|Metrics|AzureServices (For example, "Logging, Metrics"), or None to + bypass none of those traffics. + """ + + NONE = "None" + LOGGING = "Logging" + METRICS = "Metrics" + AZURE_SERVICES = "AzureServices" + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of identity that created the resource.""" + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + + +class DefaultAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the default action of allow or deny when no other rules match.""" + + ALLOW = "Allow" + DENY = "Deny" + + +class DefaultSharePermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Default share permission for users using Kerberos authentication if RBAC role is not assigned.""" + + NONE = "None" + STORAGE_FILE_DATA_SMB_SHARE_READER = "StorageFileDataSmbShareReader" + STORAGE_FILE_DATA_SMB_SHARE_CONTRIBUTOR = "StorageFileDataSmbShareContributor" + STORAGE_FILE_DATA_SMB_SHARE_ELEVATED_CONTRIBUTOR = "StorageFileDataSmbShareElevatedContributor" + + +class DirectoryServiceOptions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the directory service used. Note that this enum may be extended in the future.""" + + NONE = "None" + AADDS = "AADDS" + AD = "AD" + AADKERB = "AADKERB" + + +class DnsEndpointType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allows you to specify the type of endpoint. Set this to AzureDNSZone to create a large number + of accounts in a single subscription, which creates accounts in an Azure DNS Zone and the + endpoint URL will have an alphanumeric DNS Zone identifier. + """ + + STANDARD = "Standard" + AZURE_DNS_ZONE = "AzureDnsZone" + + +class EnabledProtocols(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The authentication protocol that is used for the file share. Can only be specified when + creating a share. + """ + + SMB = "SMB" + NFS = "NFS" + + +class EncryptionScopeSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The provider for the encryption scope. Possible values (case-insensitive): Microsoft.Storage, + Microsoft.KeyVault. + """ + + MICROSOFT_STORAGE = "Microsoft.Storage" + MICROSOFT_KEY_VAULT = "Microsoft.KeyVault" + + +class EncryptionScopeState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The state of the encryption scope. Possible values (case-insensitive): Enabled, Disabled.""" + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ExpirationAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SAS expiration action. Can only be Log.""" + + LOG = "Log" + + +class ExtendedLocationTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of extendedLocation.""" + + EDGE_ZONE = "EdgeZone" + + +class Format(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This is a required field, it specifies the format for the inventory files.""" + + CSV = "Csv" + PARQUET = "Parquet" + + +class GeoReplicationStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The status of the secondary location. Possible values are: - Live: Indicates that the secondary + location is active and operational. - Bootstrap: Indicates initial synchronization from the + primary location to the secondary location is in progress.This typically occurs when + replication is first enabled. - Unavailable: Indicates that the secondary location is + temporarily unavailable. + """ + + LIVE = "Live" + BOOTSTRAP = "Bootstrap" + UNAVAILABLE = "Unavailable" + + +class HttpProtocol(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The protocol permitted for a request made with the account SAS.""" + + HTTPS_HTTP = "https,http" + HTTPS = "https" + + +class IdentityType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The identity type.""" + + NONE = "None" + SYSTEM_ASSIGNED = "SystemAssigned" + USER_ASSIGNED = "UserAssigned" + SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned,UserAssigned" + + +class ImmutabilityPolicyState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The ImmutabilityPolicy state of a blob container, possible values include: Locked and Unlocked.""" + + LOCKED = "Locked" + UNLOCKED = "Unlocked" + + +class ImmutabilityPolicyUpdateType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The ImmutabilityPolicy update type of a blob container, possible values include: put, lock and + extend. + """ + + PUT = "put" + LOCK = "lock" + EXTEND = "extend" + + +class InventoryRuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The valid value is Inventory.""" + + INVENTORY = "Inventory" + + +class KeyPermission(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Permissions for the key -- read-only or full permissions.""" + + READ = "Read" + FULL = "Full" + + +class KeySource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The encryption keySource (provider). Possible values (case-insensitive): Microsoft.Storage, + Microsoft.Keyvault. + """ + + MICROSOFT_STORAGE = "Microsoft.Storage" + MICROSOFT_KEYVAULT = "Microsoft.Keyvault" + + +class KeyType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Encryption key type to be used for the encryption service. 'Account' key type implies that an + account-scoped encryption key will be used. 'Service' key type implies that a default service + key is used. + """ + + SERVICE = "Service" + ACCOUNT = "Account" + + +class Kind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Indicates the type of storage account.""" + + STORAGE = "Storage" + STORAGE_V2 = "StorageV2" + BLOB_STORAGE = "BlobStorage" + FILE_STORAGE = "FileStorage" + BLOCK_BLOB_STORAGE = "BlockBlobStorage" + + +class LargeFileSharesState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allow large file shares if sets to Enabled. It cannot be disabled once it is enabled.""" + + DISABLED = "Disabled" + ENABLED = "Enabled" + + +class LeaseContainerRequestEnum(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the lease action. Can be one of the available actions.""" + + ACQUIRE = "Acquire" + RENEW = "Renew" + CHANGE = "Change" + RELEASE = "Release" + BREAK = "Break" + + +class LeaseDuration(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies whether the lease on a container is of infinite or fixed duration, only when the + container is leased. + """ + + INFINITE = "Infinite" + FIXED = "Fixed" + + +class LeaseShareAction(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies the lease action. Can be one of the available actions.""" + + ACQUIRE = "Acquire" + RENEW = "Renew" + CHANGE = "Change" + RELEASE = "Release" + BREAK = "Break" + + +class LeaseState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Lease state of the container.""" + + AVAILABLE = "Available" + LEASED = "Leased" + EXPIRED = "Expired" + BREAKING = "Breaking" + BROKEN = "Broken" + + +class LeaseStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The lease status of the container.""" + + LOCKED = "Locked" + UNLOCKED = "Unlocked" + + +class ListContainersInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListContainersInclude.""" + + DELETED = "deleted" + + +class ListEncryptionScopesInclude(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ListEncryptionScopesInclude.""" + + ALL = "All" + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class ManagementPolicyName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """ManagementPolicyName.""" + + DEFAULT = "default" + + +class MigrationState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property denotes the container level immutability to object level immutability migration + state. + """ + + IN_PROGRESS = "InProgress" + COMPLETED = "Completed" + + +class MinimumTlsVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Set the minimum TLS version to be permitted on requests to storage. The default interpretation + is TLS 1.0 for this property. + """ + + TLS1_0 = "TLS1_0" + TLS1_1 = "TLS1_1" + TLS1_2 = "TLS1_2" + + +class Name(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Name of the policy. The valid value is AccessTimeTracking. This field is currently read only.""" + + ACCESS_TIME_TRACKING = "AccessTimeTracking" + + +class ObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This is a required field. This field specifies the scope of the inventory created either at the + blob or container level. + """ + + BLOB = "Blob" + CONTAINER = "Container" + + +class Permissions(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed permissions for the account SAS. Possible values include: Read (r), Write (w), + Delete (d), List (l), Add (a), Create (c), Update (u) and Process (p). + """ + + R = "r" + D = "d" + W = "w" + L = "l" + A = "a" + C = "c" + U = "u" + P = "p" + + +class PrivateEndpointConnectionProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The current provisioning state.""" + + SUCCEEDED = "Succeeded" + CREATING = "Creating" + DELETING = "Deleting" + FAILED = "Failed" + + +class PrivateEndpointServiceConnectionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The private endpoint connection status.""" + + PENDING = "Pending" + APPROVED = "Approved" + REJECTED = "Rejected" + + +class ProvisioningState(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the status of the storage account at the time the operation was called.""" + + CREATING = "Creating" + RESOLVING_DNS = "ResolvingDNS" + SUCCEEDED = "Succeeded" + + +class PublicAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Specifies whether data in the container may be accessed publicly and the level of access.""" + + CONTAINER = "Container" + BLOB = "Blob" + NONE = "None" + + +class PublicNetworkAccess(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Allow or disallow public network access to Storage Account. Value is optional but if passed in, + must be 'Enabled' or 'Disabled'. + """ + + ENABLED = "Enabled" + DISABLED = "Disabled" + + +class Reason(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the reason that a storage account name could not be used. The Reason element is only + returned if NameAvailable is false. + """ + + ACCOUNT_NAME_INVALID = "AccountNameInvalid" + ALREADY_EXISTS = "AlreadyExists" + + +class ReasonCode(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The reason for the restriction. As of now this can be "QuotaId" or + "NotAvailableForSubscription". Quota Id is set when the SKU has requiredQuotas parameter as the + subscription does not belong to that quota. The "NotAvailableForSubscription" is related to + capacity at DC. + """ + + QUOTA_ID = "QuotaId" + NOT_AVAILABLE_FOR_SUBSCRIPTION = "NotAvailableForSubscription" + + +class RootSquashType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The property is for NFS share only. The default is NoRootSquash.""" + + NO_ROOT_SQUASH = "NoRootSquash" + ROOT_SQUASH = "RootSquash" + ALL_SQUASH = "AllSquash" + + +class RoutingChoice(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Routing Choice defines the kind of network routing opted by the user.""" + + MICROSOFT_ROUTING = "MicrosoftRouting" + INTERNET_ROUTING = "InternetRouting" + + +class RuleType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The valid value is Lifecycle.""" + + LIFECYCLE = "Lifecycle" + + +class Schedule(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This is a required field. This field is used to schedule an inventory formation.""" + + DAILY = "Daily" + WEEKLY = "Weekly" + + +class Services(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed services accessible with the account SAS. Possible values include: Blob (b), Queue + (q), Table (t), File (f). + """ + + B = "b" + Q = "q" + T = "t" + F = "f" + + +class ShareAccessTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Access tier for specific share. GpV2 account can choose between TransactionOptimized (default), + Hot, and Cool. FileStorage account can choose Premium. + """ + + TRANSACTION_OPTIMIZED = "TransactionOptimized" + HOT = "Hot" + COOL = "Cool" + PREMIUM = "Premium" + + +class SignedResource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed services accessible with the service SAS. Possible values include: Blob (b), + Container (c), File (f), Share (s). + """ + + B = "b" + C = "c" + F = "f" + S = "s" + + +class SignedResourceTypes(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The signed resource types that are accessible with the account SAS. Service (s): Access to + service-level APIs; Container (c): Access to container-level APIs; Object (o): Access to + object-level APIs for blobs, queue messages, table entities, and files. + """ + + S = "s" + C = "c" + O = "o" + + +class SkuConversionStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """This property indicates the current sku conversion status.""" + + IN_PROGRESS = "InProgress" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + + +class SkuName(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU name. Required for account creation; optional for update. Note that in older versions, + SKU name was called accountType. + """ + + STANDARD_LRS = "Standard_LRS" + STANDARD_GRS = "Standard_GRS" + STANDARD_RAGRS = "Standard_RAGRS" + STANDARD_ZRS = "Standard_ZRS" + PREMIUM_LRS = "Premium_LRS" + PREMIUM_ZRS = "Premium_ZRS" + STANDARD_GZRS = "Standard_GZRS" + STANDARD_RAGZRS = "Standard_RAGZRS" + + +class SkuTier(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The SKU tier. This is based on the SKU name.""" + + STANDARD = "Standard" + PREMIUM = "Premium" + + +class State(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the state of virtual network rule.""" + + PROVISIONING = "Provisioning" + DEPROVISIONING = "Deprovisioning" + SUCCEEDED = "Succeeded" + FAILED = "Failed" + NETWORK_SOURCE_DELETED = "NetworkSourceDeleted" + + +class StorageAccountExpand(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """StorageAccountExpand.""" + + GEO_REPLICATION_STATS = "geoReplicationStats" + BLOB_RESTORE_STATUS = "blobRestoreStatus" + + +class UsageUnit(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Gets the unit of measurement.""" + + COUNT = "Count" + BYTES = "Bytes" + SECONDS = "Seconds" + PERCENT = "Percent" + COUNTS_PER_SECOND = "CountsPerSecond" + BYTES_PER_SECOND = "BytesPerSecond" diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/__init__.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/__init__.py new file mode 100644 index 000000000000..b58975e023a9 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/__init__.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. +# -------------------------------------------------------------------------- + +from ._operations import Operations +from ._skus_operations import SkusOperations +from ._storage_accounts_operations import StorageAccountsOperations +from ._deleted_accounts_operations import DeletedAccountsOperations +from ._usages_operations import UsagesOperations +from ._management_policies_operations import ManagementPoliciesOperations +from ._blob_inventory_policies_operations import BlobInventoryPoliciesOperations +from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations +from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._object_replication_policies_operations import ObjectReplicationPoliciesOperations +from ._local_users_operations import LocalUsersOperations +from ._encryption_scopes_operations import EncryptionScopesOperations +from ._blob_services_operations import BlobServicesOperations +from ._blob_containers_operations import BlobContainersOperations +from ._file_services_operations import FileServicesOperations +from ._file_shares_operations import FileSharesOperations +from ._queue_services_operations import QueueServicesOperations +from ._queue_operations import QueueOperations +from ._table_services_operations import TableServicesOperations +from ._table_operations import TableOperations + +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk + +__all__ = [ + "Operations", + "SkusOperations", + "StorageAccountsOperations", + "DeletedAccountsOperations", + "UsagesOperations", + "ManagementPoliciesOperations", + "BlobInventoryPoliciesOperations", + "PrivateEndpointConnectionsOperations", + "PrivateLinkResourcesOperations", + "ObjectReplicationPoliciesOperations", + "LocalUsersOperations", + "EncryptionScopesOperations", + "BlobServicesOperations", + "BlobContainersOperations", + "FileServicesOperations", + "FileSharesOperations", + "QueueServicesOperations", + "QueueOperations", + "TableServicesOperations", + "TableOperations", +] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_containers_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_containers_operations.py new file mode 100644 index 000000000000..a0ba67390efe --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_containers_operations.py @@ -0,0 +1,2474 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.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 +from .._vendor import _convert_request, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if include is not None: + _params["$include"] = _SERIALIZER.query("include", include, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_delete_request( + resource_group_name: str, account_name: str, container_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_set_legal_hold_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_clear_legal_hold_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_or_update_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if if_match is not None: + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "immutabilityPolicyName": _SERIALIZER.url("immutability_policy_name", immutability_policy_name, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_lock_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_extend_immutability_policy_request( + resource_group_name: str, + account_name: str, + container_name: str, + subscription_id: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["If-Match"] = _SERIALIZER.header("if_match", if_match, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_lease_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_object_level_worm_request( + resource_group_name: str, account_name: str, container_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "containerName": _SERIALIZER.url("container_name", container_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 BlobContainersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`blob_containers` 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( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListContainersInclude]] = None, + **kwargs: Any + ) -> Iterable["_models.ListContainerItem"]: + """Lists all containers and does not support a prefix like data plane. Also SRP today does not + return continuation token. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of containers that can be included in + the list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only container names starting with the filter will be + listed. Default value is None. + :type filter: str + :param include: Optional, used to include the properties for soft deleted blob containers. + "deleted" Default value is None. + :type include: str or ~azure.mgmt.storage.v2022_09_01.models.ListContainersInclude + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ListContainerItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.ListContainerItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListContainerItems] + + 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_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + include=include, + 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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ListContainerItems", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers"} # type: ignore + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Creates a new container under the specified account as described by request body. The container + resource includes metadata and properties for that container. It does not include a list of the + blobs contained by the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties of the blob container to create. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: _models.BlobContainer, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Required. + :type blob_container: IO + :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: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + container_name: str, + blob_container: Union[_models.BlobContainer, IO], + **kwargs: Any + ) -> _models.BlobContainer: + """Updates container properties as specified in request body. Properties not mentioned in the + request will be unchanged. Update fails if the specified container doesn't already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param blob_container: Properties to update for the blob container. Is either a model type or a + IO type. Required. + :type blob_container: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer 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 + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(blob_container, (IO, bytes)): + _content = blob_container + else: + _json = self._serialize.body(blob_container, "BlobContainer") + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> _models.BlobContainer: + """Gets properties of a specified container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobContainer or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobContainer + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobContainer] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobContainer", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> None: + """Deletes specified container under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}"} # type: ignore + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Sets legal hold tags. Setting the same tag results in an idempotent operation. SetLegalHold + follows an append pattern and does not clear out the existing tags that are not specified in + the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be set to a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + request = build_set_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.set_legal_hold.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LegalHold", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/setLegalHold"} # type: ignore + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: _models.LegalHold, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Required. + :type legal_hold: IO + :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: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def clear_legal_hold( + self, + resource_group_name: str, + account_name: str, + container_name: str, + legal_hold: Union[_models.LegalHold, IO], + **kwargs: Any + ) -> _models.LegalHold: + """Clears legal hold tags. Clearing the same or non-existent tag results in an idempotent + operation. ClearLegalHold clears out only the specified tags in the request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param legal_hold: The LegalHold property that will be clear from a blob container. Is either a + model type or a IO type. Required. + :type legal_hold: ~azure.mgmt.storage.v2022_09_01.models.LegalHold 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 + :return: LegalHold or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LegalHold + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LegalHold] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(legal_hold, (IO, bytes)): + _content = legal_hold + else: + _json = self._serialize.body(legal_hold, "LegalHold") + + request = build_clear_legal_hold_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.clear_legal_hold.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LegalHold", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + clear_legal_hold.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/clearLegalHold"} # type: ignore + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Default value is None. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Creates or updates an unlocked immutability policy. ETag in If-Match is honored if given but + not required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be created or updated to a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy or IO + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: 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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None + + request = build_create_or_update_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update_immutability_policy.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + create_or_update_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + @distributed_trace + def get_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Gets the existing immutability policy along with the corresponding ETag in response headers and + body. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Default value is None. + :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 {}) + + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + request = build_get_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + template_url=self.get_immutability_policy.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + get_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + @distributed_trace + def delete_immutability_policy( + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Aborts an unlocked immutability policy. The response of delete has + immutabilityPeriodSinceCreationInDays set to 0. ETag in If-Match is required for this + operation. Deleting a locked immutability policy is not allowed, the only way is to delete the + container after deleting all expired blobs inside the policy locked container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :keyword immutability_policy_name: The name of the blob container immutabilityPolicy within the + specified storage account. ImmutabilityPolicy Name must be 'default'. Default value is + "default". Note that overriding this default value may result in unsupported behavior. + :paramtype immutability_policy_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 {}) + + immutability_policy_name = kwargs.pop("immutability_policy_name", "default") # type: Literal["default"] + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + request = build_delete_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + immutability_policy_name=immutability_policy_name, + api_version=api_version, + template_url=self.delete_immutability_policy.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + delete_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/{immutabilityPolicyName}"} # type: ignore + + @distributed_trace + def lock_immutability_policy( + self, resource_group_name: str, account_name: str, container_name: str, if_match: str, **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Sets the ImmutabilityPolicy to Locked state. The only action allowed on a Locked policy is + ExtendImmutabilityPolicy action. ETag in If-Match is required for this operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + request = build_lock_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + template_url=self.lock_immutability_policy.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + lock_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/lock"} # type: ignore + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[_models.ImmutabilityPolicy] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Default value is None. + :type parameters: IO + :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: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def extend_immutability_policy( + self, + resource_group_name: str, + account_name: str, + container_name: str, + if_match: str, + parameters: Optional[Union[_models.ImmutabilityPolicy, IO]] = None, + **kwargs: Any + ) -> _models.ImmutabilityPolicy: + """Extends the immutabilityPeriodSinceCreationInDays of a locked immutabilityPolicy. The only + action allowed on a Locked policy will be this action. ETag in If-Match is required for this + operation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param if_match: The entity state (ETag) version of the immutability policy to update. A value + of "*" can be used to apply the operation only if the immutability policy already exists. If + omitted, this operation will always be applied. Required. + :type if_match: str + :param parameters: The ImmutabilityPolicy Properties that will be extended for a blob + container. Is either a model type or a IO type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy 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 + :return: ImmutabilityPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ImmutabilityPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ImmutabilityPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "ImmutabilityPolicy") + else: + _json = None + + request = build_extend_immutability_policy_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + if_match=if_match, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.extend_immutability_policy.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("ImmutabilityPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + extend_immutability_policy.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/immutabilityPolicies/default/extend"} # type: ignore + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[_models.LeaseContainerRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequest + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Default value is None. + :type parameters: IO + :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: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + container_name: str, + parameters: Optional[Union[_models.LeaseContainerRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseContainerResponse: + """The Lease Container operation establishes and manages a lock on a container for delete + operations. The lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_name: str + :param parameters: Lease Container request body. Is either a model type or a IO type. Default + value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerRequest 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 + :return: LeaseContainerResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseContainerResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseContainerResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseContainerRequest") + else: + _json = None + + request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.lease.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LeaseContainerResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/lease"} # type: ignore + + def _object_level_worm_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> None: + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_object_level_worm_request( + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._object_level_worm_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _object_level_worm_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore + + @distributed_trace + def begin_object_level_worm( + self, resource_group_name: str, account_name: str, container_name: str, **kwargs: Any + ) -> LROPoller[None]: + """This operation migrates a blob container from container level WORM to object level immutability + enabled container. Prerequisites require a container level immutability policy either in locked + or unlocked state, Account level versioning must be enabled and there should be no Legal hold + on the container. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param container_name: The name of the blob container within the specified storage account. + Blob container names must be between 3 and 63 characters in length and use numbers, lower-case + letters and dash (-) only. Every dash (-) character must be immediately preceded and followed + by a letter or number. Required. + :type container_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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._object_level_worm_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + container_name=container_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + 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) + + begin_object_level_worm.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/default/containers/{containerName}/migrate"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_inventory_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_inventory_policies_operations.py new file mode 100644 index 000000000000..bac876eaac9e --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_inventory_policies_operations.py @@ -0,0 +1,602 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_create_or_update_request( + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "blobInventoryPolicyName": _SERIALIZER.url("blob_inventory_policy_name", blob_inventory_policy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +class BlobInventoryPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`blob_inventory_policies` 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 get( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: _models.BlobInventoryPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Required. + :type properties: IO + :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: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + properties: Union[_models.BlobInventoryPolicy, IO], + **kwargs: Any + ) -> _models.BlobInventoryPolicy: + """Sets the blob inventory policy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName + :param properties: The blob inventory policy set to a storage account. Is either a model type + or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy 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 + :return: BlobInventoryPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobInventoryPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "BlobInventoryPolicy") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobInventoryPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + blob_inventory_policy_name: Union[str, _models.BlobInventoryPolicyName], + **kwargs: Any + ) -> None: + """Deletes the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param blob_inventory_policy_name: The name of the storage account blob inventory policy. It + should always be 'default'. "default" Required. + :type blob_inventory_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicyName + :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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + blob_inventory_policy_name=blob_inventory_policy_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies/{blobInventoryPolicyName}"} # type: ignore + + @distributed_trace + def list( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobInventoryPolicy"]: + """Gets the blob inventory policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 BlobInventoryPolicy or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.BlobInventoryPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListBlobInventoryPolicy] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ListBlobInventoryPolicy", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/inventoryPolicies"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_services_operations.py new file mode 100644 index 000000000000..66d620f0bfb9 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_blob_services_operations.py @@ -0,0 +1,492 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_set_service_properties_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_service_properties_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "BlobServicesName": _SERIALIZER.url("blob_services_name", blob_services_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +class BlobServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`blob_services` 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( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.BlobServiceProperties"]: + """List blob services of storage account. It returns a collection of one object named default. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 BlobServiceProperties or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceItems] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("BlobServiceItems", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices"} # type: ignore + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobServiceProperties, IO], + **kwargs: Any + ) -> _models.BlobServiceProperties: + """Sets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Blob service, including properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules. Is either a model type or a + IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties or IO + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: 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: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobServiceProperties") + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self.set_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore + + @distributed_trace + def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.BlobServiceProperties: + """Gets the properties of a storage account’s Blob service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword blob_services_name: The name of the blob Service within the specified storage account. + Blob Service Name must be 'default'. Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype blob_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: BlobServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.BlobServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + blob_services_name = kwargs.pop("blob_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobServiceProperties] + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + blob_services_name=blob_services_name, + template_url=self.get_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("BlobServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/blobServices/{BlobServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_deleted_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_deleted_accounts_operations.py new file mode 100644 index 000000000000..c5512b142ed0 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_deleted_accounts_operations.py @@ -0,0 +1,255 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_request(deleted_account_name: str, location: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "deletedAccountName": _SERIALIZER.url( + "deleted_account_name", deleted_account_name, "str", max_length=24, min_length=3 + ), + "location": _SERIALIZER.url("location", location, "str"), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +class DeletedAccountsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`deleted_accounts` 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(self, **kwargs: Any) -> Iterable["_models.DeletedAccount"]: + """Lists deleted accounts under the subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either DeletedAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.DeletedAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccountListResult] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("DeletedAccountListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/deletedAccounts"} # type: ignore + + @distributed_trace + def get(self, deleted_account_name: str, location: str, **kwargs: Any) -> _models.DeletedAccount: + """Get properties of specified deleted account resource. + + :param deleted_account_name: Name of the deleted storage account. Required. + :type deleted_account_name: str + :param location: The location of the deleted storage account. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: DeletedAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.DeletedAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.DeletedAccount] + + request = build_get_request( + deleted_account_name=deleted_account_name, + location=location, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("DeletedAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/deletedAccounts/{deletedAccountName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_encryption_scopes_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_encryption_scopes_operations.py new file mode 100644 index 000000000000..4866763d9a94 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_encryption_scopes_operations.py @@ -0,0 +1,744 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_put_request( + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_patch_request( + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, encryption_scope_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "encryptionScopeName": _SERIALIZER.url( + "encryption_scope_name", encryption_scope_name, "str", max_length=63, min_length=3 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[int] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListEncryptionScopesInclude]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "int", maximum=5000, minimum=1) + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if include is not None: + _params["$include"] = _SERIALIZER.query("include", include, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class EncryptionScopesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`encryption_scopes` 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") + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. + Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Synchronously creates or updates an encryption scope under the specified storage account. If an + encryption scope is already created and a subsequent request is issued with different + properties, the encryption scope properties will be updated per the specified request. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the create or update. Is + either a model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") + + request = build_put_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: _models.EncryptionScope, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Required. + :type encryption_scope: IO + :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: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def patch( + self, + resource_group_name: str, + account_name: str, + encryption_scope_name: str, + encryption_scope: Union[_models.EncryptionScope, IO], + **kwargs: Any + ) -> _models.EncryptionScope: + """Update encryption scope properties as specified in the request body. Update fails if the + specified encryption scope does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :param encryption_scope: Encryption scope properties to be used for the update. Is either a + model type or a IO type. Required. + :type encryption_scope: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope 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 + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(encryption_scope, (IO, bytes)): + _content = encryption_scope + else: + _json = self._serialize.body(encryption_scope, "EncryptionScope") + + request = build_patch_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.patch.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + patch.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, encryption_scope_name: str, **kwargs: Any + ) -> _models.EncryptionScope: + """Returns the properties for the specified encryption scope. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param encryption_scope_name: The name of the encryption scope within the specified storage + account. Encryption scope names must be between 3 and 63 characters in length and use numbers, + lower-case letters and dash (-) only. Every dash (-) character must be immediately preceded and + followed by a letter or number. Required. + :type encryption_scope_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: EncryptionScope or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.EncryptionScope + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScope] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + encryption_scope_name=encryption_scope_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("EncryptionScope", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes/{encryptionScopeName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[int] = None, + filter: Optional[str] = None, + include: Optional[Union[str, _models.ListEncryptionScopesInclude]] = None, + **kwargs: Any + ) -> Iterable["_models.EncryptionScope"]: + """Lists all the encryption scopes available under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, specifies the maximum number of encryption scopes that will be + included in the list response. Default value is None. + :type maxpagesize: int + :param filter: Optional. When specified, only encryption scope names starting with the filter + will be listed. Default value is None. + :type filter: str + :param include: Optional, when specified, will list encryption scopes with the specific state. + Defaults to All. Known values are: "All", "Enabled", and "Disabled". Default value is None. + :type include: str or ~azure.mgmt.storage.v2022_09_01.models.ListEncryptionScopesInclude + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either EncryptionScope or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.EncryptionScope] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.EncryptionScopeListResult] + + 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_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + include=include, + 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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("EncryptionScopeListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/encryptionScopes"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_services_operations.py new file mode 100644 index 000000000000..0060c281a199 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_services_operations.py @@ -0,0 +1,458 @@ +# pylint: disable=too-many-lines +# 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, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_set_service_properties_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_service_properties_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "FileServicesName": _SERIALIZER.url("file_services_name", file_services_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +class FileServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`file_services` 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(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.FileServiceItems: + """List all file services in storage accounts. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceItems or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceItems + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceItems] + + request = build_list_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceItems", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices"} # type: ignore + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.FileServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.FileServiceProperties, IO], + **kwargs: Any + ) -> _models.FileServiceProperties: + """Sets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of file services in storage accounts, including CORS + (Cross-Origin Resource Sharing) rules. Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties or IO + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: 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: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "FileServiceProperties") + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self.set_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore + + @distributed_trace + def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.FileServiceProperties: + """Gets the properties of file services in storage accounts, including CORS (Cross-Origin Resource + Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword file_services_name: The name of the file Service within the specified storage account. + File Service Name must be "default". Default value is "default". Note that overriding this + default value may result in unsupported behavior. + :paramtype file_services_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + file_services_name = kwargs.pop("file_services_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileServiceProperties] + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + file_services_name=file_services_name, + template_url=self.get_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/{FileServicesName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_shares_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_shares_operations.py new file mode 100644 index 000000000000..81bc5c7a2352 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_file_shares_operations.py @@ -0,0 +1,1335 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, share_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + expand: Optional[str] = None, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + if x_ms_snapshot is not None: + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + x_ms_snapshot: Optional[str] = None, + include: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if include is not None: + _params["$include"] = _SERIALIZER.query("include", include, "str") + + # Construct headers + if x_ms_snapshot is not None: + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_restore_request( + resource_group_name: str, account_name: str, share_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_lease_request( + resource_group_name: str, + account_name: str, + share_name: str, + subscription_id: str, + *, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "shareName": _SERIALIZER.url("share_name", share_name, "str", max_length=63, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if x_ms_snapshot is not None: + _headers["x-ms-snapshot"] = _SERIALIZER.header("x_ms_snapshot", x_ms_snapshot, "str") + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +class FileSharesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`file_shares` 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( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.FileShareItem"]: + """Lists all shares. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional. Specified maximum number of shares that can be included in the + list. Default value is None. + :type maxpagesize: str + :param filter: Optional. When specified, only share names starting with the filter will be + listed. Default value is None. + :type filter: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: deleted, snapshots. Should be passed as a string with delimiter ','. Default value is + None. + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FileShareItem or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.FileShareItem] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShareItems] + + 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_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + expand=expand, + 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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("FileShareItems", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares"} # type: ignore + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + expand: Optional[str] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Required. + :type file_share: IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + expand: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Creates a new share under the specified account as described by request body. The share + resource includes metadata and properties for that share. It does not include a list of the + files contained by the share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties of the file share to create. Is either a model type or a IO type. + Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare or IO + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: snapshots. Should be passed as a string with delimiter ','. Default value is None. + :type expand: 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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("FileShare", pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: _models.FileShare, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Required. + :type file_share: IO + :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: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + share_name: str, + file_share: Union[_models.FileShare, IO], + **kwargs: Any + ) -> _models.FileShare: + """Updates share properties as specified in request body. Properties not mentioned in the request + will not be changed. Update fails if the specified share does not already exist. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param file_share: Properties to update for the file share. Is either a model type or a IO + type. Required. + :type file_share: ~azure.mgmt.storage.v2022_09_01.models.FileShare 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 + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(file_share, (IO, bytes)): + _content = file_share + else: + _json = self._serialize.body(file_share, "FileShare") + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + account_name: str, + share_name: str, + expand: Optional[str] = None, + x_ms_snapshot: Optional[str] = None, + **kwargs: Any + ) -> _models.FileShare: + """Gets properties of a specified share. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param expand: Optional, used to expand the properties within share's properties. Valid values + are: stats. Should be passed as a string with delimiter ','. Default value is None. + :type expand: str + :param x_ms_snapshot: Optional, used to retrieve properties of a snapshot. Default value is + None. + :type x_ms_snapshot: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FileShare or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.FileShare + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.FileShare] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + expand=expand, + x_ms_snapshot=x_ms_snapshot, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("FileShare", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + include: Optional[str] = None, + **kwargs: Any + ) -> None: + """Deletes specified share under its account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional, used to delete a snapshot. Default value is None. + :type x_ms_snapshot: str + :param include: Optional. Valid values are: snapshots, leased-snapshots, none. The default + value is snapshots. For 'snapshots', the file share is deleted including all of its file share + snapshots. If the file share contains leased-snapshots, the deletion fails. For + 'leased-snapshots', the file share is deleted included all of its file share snapshots + (leased/unleased). For 'none', the file share is deleted if it has no share snapshots. If the + file share contains any snapshots (leased or unleased), the deletion fails. Default value is + None. + :type include: 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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, + include=include, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}"} # type: ignore + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: _models.DeletedShare, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: ~azure.mgmt.storage.v2022_09_01.models.DeletedShare + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Required. + :type deleted_share: IO + :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: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def restore( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + share_name: str, + deleted_share: Union[_models.DeletedShare, IO], + **kwargs: Any + ) -> None: + """Restore a file share within a valid retention days if share soft delete is enabled. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param deleted_share: Is either a model type or a IO type. Required. + :type deleted_share: ~azure.mgmt.storage.v2022_09_01.models.DeletedShare 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 + :return: None or the result of cls(response) + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(deleted_share, (IO, bytes)): + _content = deleted_share + else: + _json = self._serialize.body(deleted_share, "DeletedShare") + + request = build_restore_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.restore.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + restore.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/restore"} # type: ignore + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[_models.LeaseShareRequest] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareRequest + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Default value is None. + :type parameters: IO + :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: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def lease( + self, + resource_group_name: str, + account_name: str, + share_name: str, + x_ms_snapshot: Optional[str] = None, + parameters: Optional[Union[_models.LeaseShareRequest, IO]] = None, + **kwargs: Any + ) -> _models.LeaseShareResponse: + """The Lease Share operation establishes and manages a lock on a share for delete operations. The + lock duration can be 15 to 60 seconds, or can be infinite. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param share_name: The name of the file share within the specified storage account. File share + names must be between 3 and 63 characters in length and use numbers, lower-case letters and + dash (-) only. Every dash (-) character must be immediately preceded and followed by a letter + or number. Required. + :type share_name: str + :param x_ms_snapshot: Optional. Specify the snapshot time to lease a snapshot. Default value is + None. + :type x_ms_snapshot: str + :param parameters: Lease Share request body. Is either a model type or a IO type. Default value + is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareRequest 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 + :return: LeaseShareResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LeaseShareResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LeaseShareResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "LeaseShareRequest") + else: + _json = None + + request = build_lease_request( + resource_group_name=resource_group_name, + account_name=account_name, + share_name=share_name, + subscription_id=self._config.subscription_id, + x_ms_snapshot=x_ms_snapshot, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.lease.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + response_headers = {} + response_headers["ETag"] = self._deserialize("str", response.headers.get("ETag")) + + deserialized = self._deserialize("LeaseShareResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, response_headers) + + return deserialized + + lease.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/fileServices/default/shares/{shareName}/lease"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_local_users_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_local_users_operations.py new file mode 100644 index 000000000000..ba38669fcb7f --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_local_users_operations.py @@ -0,0 +1,779 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_request( + resource_group_name: str, account_name: str, username: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_create_or_update_request( + resource_group_name: str, account_name: str, username: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, username: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_keys_request( + resource_group_name: str, account_name: str, username: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +def build_regenerate_password_request( + resource_group_name: str, account_name: str, username: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "username": _SERIALIZER.url("username", username, "str", max_length=64, min_length=3), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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 LocalUsersOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`local_users` 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(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.LocalUser"]: + """List the local users associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 LocalUser or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.LocalUser] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUsers] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("LocalUsers", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, account_name: str, username: str, **kwargs: Any) -> _models.LocalUser: + """Get the local user of the storage account by username. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUser", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: _models.LocalUser, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.LocalUser + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Required. + :type properties: IO + :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: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + username: str, + properties: Union[_models.LocalUser, IO], + **kwargs: Any + ) -> _models.LocalUser: + """Create or update the properties of a local user associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :param properties: The local user associated with a storage account. Is either a model type or + a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.LocalUser 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 + :return: LocalUser or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUser + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUser] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "LocalUser") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUser", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> None: + """Deletes the local user associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: 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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}"} # type: ignore + + @distributed_trace + def list_keys( + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> _models.LocalUserKeys: + """List SSH authorized keys and shared key of the local user. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUserKeys or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUserKeys + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserKeys] + + request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUserKeys", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/listKeys"} # type: ignore + + @distributed_trace + def regenerate_password( + self, resource_group_name: str, account_name: str, username: str, **kwargs: Any + ) -> _models.LocalUserRegeneratePasswordResult: + """Regenerate the local user SSH password. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param username: The name of local user. The username must contain lowercase letters and + numbers only. It must be unique only within the storage account. Required. + :type username: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: LocalUserRegeneratePasswordResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.LocalUserRegeneratePasswordResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.LocalUserRegeneratePasswordResult] + + request = build_regenerate_password_request( + resource_group_name=resource_group_name, + account_name=account_name, + username=username, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.regenerate_password.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("LocalUserRegeneratePasswordResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_password.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/localUsers/{username}/regeneratePassword"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_management_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_management_policies_operations.py new file mode 100644 index 000000000000..2ec901427e45 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_management_policies_operations.py @@ -0,0 +1,471 @@ +# pylint: disable=too-many-lines +# 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, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_get_request( + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_create_or_update_request( + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "managementPolicyName": _SERIALIZER.url("management_policy_name", management_policy_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +class ManagementPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`management_policies` 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 get( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Gets the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ManagementPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: _models.ManagementPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Required. + :type properties: IO + :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: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + properties: Union[_models.ManagementPolicy, IO], + **kwargs: Any + ) -> _models.ManagementPolicy: + """Sets the managementpolicy to the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName + :param properties: The ManagementPolicy set to a storage account. Is either a model type or a + IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy 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 + :return: ManagementPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ManagementPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ManagementPolicy") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ManagementPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, + resource_group_name: str, + account_name: str, + management_policy_name: Union[str, _models.ManagementPolicyName], + **kwargs: Any + ) -> None: + """Deletes the managementpolicy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param management_policy_name: The name of the Storage Account Management Policy. It should + always be 'default'. "default" Required. + :type management_policy_name: str or + ~azure.mgmt.storage.v2022_09_01.models.ManagementPolicyName + :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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + management_policy_name=management_policy_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/managementPolicies/{managementPolicyName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_object_replication_policies_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_object_replication_policies_operations.py new file mode 100644 index 000000000000..630523b0d0c9 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_object_replication_policies_operations.py @@ -0,0 +1,599 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_request( + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_create_or_update_request( + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, object_replication_policy_id: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "objectReplicationPolicyId": _SERIALIZER.url( + "object_replication_policy_id", object_replication_policy_id, "str", min_length=1 + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class ObjectReplicationPoliciesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`object_replication_policies` 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( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.ObjectReplicationPolicy"]: + """List the object replication policies associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 ObjectReplicationPolicy or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicies] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ObjectReplicationPolicies", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Get the object replication policy of the storage account by policy ID. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: _models.ObjectReplicationPolicy, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Required. + :type properties: IO + :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: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, + resource_group_name: str, + account_name: str, + object_replication_policy_id: str, + properties: Union[_models.ObjectReplicationPolicy, IO], + **kwargs: Any + ) -> _models.ObjectReplicationPolicy: + """Create or update the object replication policy of the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: str + :param properties: The object replication policy set to a storage account. A unique policy ID + will be created if absent. Is either a model type or a IO type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy 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 + :return: ObjectReplicationPolicy or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ObjectReplicationPolicy + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ObjectReplicationPolicy] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "ObjectReplicationPolicy") + + request = build_create_or_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.create_or_update.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ObjectReplicationPolicy", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create_or_update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, object_replication_policy_id: str, **kwargs: Any + ) -> None: + """Deletes the object replication policy associated with the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param object_replication_policy_id: For the destination account, provide the value 'default'. + Configure the policy on the destination account first. For the source account, provide the + value of the policy ID that is returned when you download the policy that was defined on the + destination account. The policy is downloaded as a JSON file. Required. + :type object_replication_policy_id: 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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + object_replication_policy_id=object_replication_policy_id, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/objectReplicationPolicies/{objectReplicationPolicyId}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_operations.py new file mode 100644 index 000000000000..af74251b8836 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_operations.py @@ -0,0 +1,158 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, 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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Storage/operations") + + # 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) + + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`operations` 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(self, **kwargs: Any) -> Iterable["_models.Operation"]: + """Lists all of the available Storage Rest API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Operation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.Operation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.OperationListResult] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/providers/Microsoft.Storage/operations"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_patch.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_patch.py new file mode 100644 index 000000000000..f7dd32510333 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_patch.py @@ -0,0 +1,20 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_endpoint_connections_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_endpoint_connections_operations.py new file mode 100644 index 000000000000..7de2a4c6a11a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_endpoint_connections_operations.py @@ -0,0 +1,598 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_request( + resource_group_name: str, + account_name: str, + private_endpoint_connection_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_put_request( + resource_group_name: str, + account_name: str, + private_endpoint_connection_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, + account_name: str, + private_endpoint_connection_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "privateEndpointConnectionName": _SERIALIZER.url( + "private_endpoint_connection_name", private_endpoint_connection_name, "str" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +class PrivateEndpointConnectionsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`private_endpoint_connections` 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( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> Iterable["_models.PrivateEndpointConnection"]: + """List all the private endpoint connections associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 PrivateEndpointConnection or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnectionListResult] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("PrivateEndpointConnectionListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections"} # type: ignore + + @distributed_trace + def get( + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Gets the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. 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.storage.v2022_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: _models.PrivateEndpointConnection, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Required. + :type properties: IO + :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: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def put( + self, + resource_group_name: str, + account_name: str, + private_endpoint_connection_name: str, + properties: Union[_models.PrivateEndpointConnection, IO], + **kwargs: Any + ) -> _models.PrivateEndpointConnection: + """Update the state of specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_name: str + :param properties: The private endpoint connection properties. Is either a model type or a IO + type. Required. + :type properties: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection 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 + :return: PrivateEndpointConnection or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateEndpointConnection + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateEndpointConnection] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(properties, (IO, bytes)): + _content = properties + else: + _json = self._serialize.body(properties, "PrivateEndpointConnection") + + request = build_put_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, + content_type=content_type, + json=_json, + content=_content, + template_url=self.put.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateEndpointConnection", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + put.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, private_endpoint_connection_name: str, **kwargs: Any + ) -> None: + """Deletes the specified private endpoint connection associated with the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param private_endpoint_connection_name: The name of the private endpoint connection associated + with the Azure resource. Required. + :type private_endpoint_connection_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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateEndpointConnections/{privateEndpointConnectionName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_link_resources_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_link_resources_operations.py new file mode 100644 index 000000000000..b286471096a4 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_private_link_resources_operations.py @@ -0,0 +1,155 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_storage_account_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +class PrivateLinkResourcesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`private_link_resources` 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_by_storage_account( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.PrivateLinkResourceListResult: + """Gets the private link resources that need to be created for a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: PrivateLinkResourceListResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.PrivateLinkResourceListResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.PrivateLinkResourceListResult] + + request = build_list_by_storage_account_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_by_storage_account.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("PrivateLinkResourceListResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_by_storage_account.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/privateLinkResources"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_operations.py new file mode 100644 index 000000000000..9e1ac43484ca --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_operations.py @@ -0,0 +1,837 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request( + resource_group_name: str, account_name: str, queue_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, queue_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, queue_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_delete_request( + resource_group_name: str, account_name: str, queue_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueName": _SERIALIZER.url( + "queue_name", + queue_name, + "str", + max_length=63, + min_length=3, + pattern=r"^[a-z0-9]([a-z0-9]|(-(?!-))){1,61}[a-z0-9]$", + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + maxpagesize: Optional[str] = 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if maxpagesize is not None: + _params["$maxpagesize"] = _SERIALIZER.query("maxpagesize", maxpagesize, "str") + if filter is not None: + _params["$filter"] = _SERIALIZER.query("filter", filter, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +class QueueOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`queue` 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") + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: _models.StorageQueue, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Required. + :type queue: IO + :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: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + queue_name: str, + queue: Union[_models.StorageQueue, IO], + **kwargs: Any + ) -> _models.StorageQueue: + """Creates a new queue with the specified queue name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :param queue: Queue properties and metadata to be created with. Is either a model type or a IO + type. Required. + :type queue: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue 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 + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(queue, (IO, bytes)): + _content = queue + else: + _json = self._serialize.body(queue, "StorageQueue") + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any) -> _models.StorageQueue: + """Gets the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageQueue or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageQueue + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageQueue] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageQueue", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, queue_name: str, **kwargs: Any + ) -> None: + """Deletes the queue with the specified queue name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param queue_name: A queue name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of lowercase alphanumeric and dash(-) characters only, + it should begin and end with an alphanumeric character and it cannot have two consecutive + dash(-) characters. Required. + :type queue_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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + queue_name=queue_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues/{queueName}"} # type: ignore + + @distributed_trace + def list( + self, + resource_group_name: str, + account_name: str, + maxpagesize: Optional[str] = None, + filter: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.ListQueue"]: + """Gets a list of all the queues under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param maxpagesize: Optional, a maximum number of queues that should be included in a list + queue response. Default value is None. + :type maxpagesize: str + :param filter: Optional, When specified, only the queues with a name starting with the given + filter will be listed. 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 ListQueue or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.ListQueue] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueResource] + + 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_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + maxpagesize=maxpagesize, + filter=filter, + 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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ListQueueResource", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/default/queues"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_services_operations.py new file mode 100644 index 000000000000..de8cedbead31 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_queue_services_operations.py @@ -0,0 +1,459 @@ +# pylint: disable=too-many-lines +# 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, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_set_service_properties_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_service_properties_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "queueServiceName": _SERIALIZER.url("queue_service_name", queue_service_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +class QueueServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`queue_services` 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(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListQueueServices: + """List all queue services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListQueueServices or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListQueueServices + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListQueueServices] + + request = build_list_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListQueueServices", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices"} # type: ignore + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.QueueServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.QueueServiceProperties, IO], + **kwargs: Any + ) -> _models.QueueServiceProperties: + """Sets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Queue service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties or IO + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: 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: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "QueueServiceProperties") + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self.set_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore + + @distributed_trace + def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.QueueServiceProperties: + """Gets the properties of a storage account’s Queue service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword queue_service_name: The name of the Queue Service within the specified storage + account. Queue Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype queue_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: QueueServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.QueueServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + queue_service_name = kwargs.pop("queue_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.QueueServiceProperties] + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + queue_service_name=queue_service_name, + template_url=self.get_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("QueueServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/queueServices/{queueServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_skus_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_skus_operations.py new file mode 100644 index 000000000000..c67a1bc088bf --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_skus_operations.py @@ -0,0 +1,164 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +class SkusOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`skus` 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(self, **kwargs: Any) -> Iterable["_models.SkuInformation"]: + """Lists the available SKUs supported by Microsoft.Storage for given subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either SkuInformation or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.SkuInformation] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageSkuListResult] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageSkuListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/skus"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_storage_accounts_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_storage_accounts_operations.py new file mode 100644 index 000000000000..72f871077730 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_storage_accounts_operations.py @@ -0,0 +1,2567 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, cast, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + 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.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 +from .._vendor import _convert_request, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_check_name_availability_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability" + ) + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_create_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_delete_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_get_properties_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts") + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_list_by_resource_group_request(resource_group_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_list_keys_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + expand: Literal["kerb"] = "kerb", + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if expand is not None: + _params["$expand"] = _SERIALIZER.query("expand", expand, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_regenerate_key_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_account_sas_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_service_sas_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_failover_request( + resource_group_name: str, + account_name: str, + subscription_id: str, + *, + failover_type: Literal["Planned"] = "Planned", + **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if failover_type is not None: + _params["failoverType"] = _SERIALIZER.query("failover_type", failover_type, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_hierarchical_namespace_migration_request( + resource_group_name: str, account_name: str, subscription_id: str, *, request_type: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + _params["requestType"] = _SERIALIZER.query("request_type", request_type, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_abort_hierarchical_namespace_migration_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +def build_restore_blob_ranges_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_revoke_user_delegation_keys_request( + resource_group_name: str, account_name: str, subscription_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +class StorageAccountsOperations: # pylint: disable=too-many-public-methods + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`storage_accounts` 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") + + @overload + def check_name_availability( + self, + account_name: _models.StorageAccountCheckNameAvailabilityParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCheckNameAvailabilityParameters + :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.storage.v2022_09_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def check_name_availability( + self, account_name: IO, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: IO + :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.storage.v2022_09_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def check_name_availability( + self, account_name: Union[_models.StorageAccountCheckNameAvailabilityParameters, IO], **kwargs: Any + ) -> _models.CheckNameAvailabilityResult: + """Checks that the storage account name is valid and is not already in use. + + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Is either a model type or a IO type. Required. + :type account_name: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCheckNameAvailabilityParameters 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 + :return: CheckNameAvailabilityResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.CheckNameAvailabilityResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.CheckNameAvailabilityResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(account_name, (IO, bytes)): + _content = account_name + else: + _json = self._serialize.body(account_name, "StorageAccountCheckNameAvailabilityParameters") + + request = build_check_name_availability_request( + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("CheckNameAvailabilityResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/checkNameAvailability"} # type: ignore + + def _create_initial( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> Optional[_models.StorageAccount]: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.StorageAccount]] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountCreateParameters") + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountCreateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCreateParameters + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Required. + :type parameters: IO + :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 StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountCreateParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.StorageAccount]: + """Asynchronously creates a new storage account with the specified parameters. If an account is + already created and a subsequent create request is issued with different properties, the + account properties will be updated. If an account is already created and a subsequent create or + update request is issued with the exact same set of properties, the request will succeed. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the created account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountCreateParameters 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. + :return: An instance of LROPoller that returns either StorageAccount or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("StorageAccount", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast(PollingMethod, ARMPolling(lro_delay, **kwargs)) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + """Deletes a storage account in Microsoft Azure. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + 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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace + def get_properties( + self, + resource_group_name: str, + account_name: str, + expand: Optional[Union[str, _models.StorageAccountExpand]] = None, + **kwargs: Any + ) -> _models.StorageAccount: + """Returns the properties for the specified storage account including but not limited to name, SKU + name, location, and account status. The ListKeys operation should be used to retrieve storage + keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param expand: May be used to expand the properties within account's properties. By default, + data is not included when fetching properties. Currently we only support geoReplicationStats + and blobRestoreStatus. Known values are: "geoReplicationStats" and "blobRestoreStatus". Default + value is None. + :type expand: str or ~azure.mgmt.storage.v2022_09_01.models.StorageAccountExpand + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + + request = build_get_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.get_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: _models.StorageAccountUpdateParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountUpdateParameters + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Required. + :type parameters: IO + :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: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.StorageAccountUpdateParameters, IO], + **kwargs: Any + ) -> _models.StorageAccount: + """The update operation can be used to update the SKU, encryption, access tier, or tags for a + storage account. It can also be used to map the account to a custom domain. Only one custom + domain is supported per storage account; the replacement/change of custom domain is not + supported. In order to replace an old custom domain, the old value must be cleared/unregistered + before a new value can be set. The update of multiple properties is supported. This call does + not change the storage keys for the account. If you want to change the storage account keys, + use the regenerate keys operation. The location and name of the storage account cannot be + changed after creation. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for the updated account. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountUpdateParameters 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 + :return: StorageAccount or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccount + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccount] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "StorageAccountUpdateParameters") + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccount", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}"} # type: ignore + + @distributed_trace + def list(self, **kwargs: Any) -> Iterable["_models.StorageAccount"]: + """Lists all the storage accounts available under the subscription. Note that storage keys are not + returned; use the ListKeys operation for this. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace + def list_by_resource_group(self, resource_group_name: str, **kwargs: Any) -> Iterable["_models.StorageAccount"]: + """Lists all the storage accounts available under the given resource group. Note that storage keys + are not returned; use the ListKeys operation for this. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. 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 StorageAccount or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.StorageAccount] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListResult] + + 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_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) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("StorageAccountListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_resource_group.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts"} # type: ignore + + @distributed_trace + def list_keys( + self, resource_group_name: str, account_name: str, expand: Literal["kerb"] = "kerb", **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Lists the access keys or Kerberos keys (if active directory enabled) for the specified storage + account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param expand: Specifies type of the key to be listed. Possible value is kerb. Known values are + "kerb" and None. Default value is "kerb". + :type expand: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] + + request = build_list_keys_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + expand=expand, + api_version=api_version, + template_url=self.list_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/listKeys"} # type: ignore + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: _models.StorageAccountRegenerateKeyParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountRegenerateKeyParameters + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Required. + :type regenerate_key: IO + :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: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def regenerate_key( + self, + resource_group_name: str, + account_name: str, + regenerate_key: Union[_models.StorageAccountRegenerateKeyParameters, IO], + **kwargs: Any + ) -> _models.StorageAccountListKeysResult: + """Regenerates one of the access keys or Kerberos keys for the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param regenerate_key: Specifies name of the key which should be regenerated -- key1, key2, + kerb1, kerb2. Is either a model type or a IO type. Required. + :type regenerate_key: + ~azure.mgmt.storage.v2022_09_01.models.StorageAccountRegenerateKeyParameters 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 + :return: StorageAccountListKeysResult or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.StorageAccountListKeysResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.StorageAccountListKeysResult] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(regenerate_key, (IO, bytes)): + _content = regenerate_key + else: + _json = self._serialize.body(regenerate_key, "StorageAccountRegenerateKeyParameters") + + request = build_regenerate_key_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("StorageAccountListKeysResult", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + regenerate_key.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/regenerateKey"} # type: ignore + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.AccountSasParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.AccountSasParameters + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Required. + :type parameters: IO + :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: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_account_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.AccountSasParameters, IO], + **kwargs: Any + ) -> _models.ListAccountSasResponse: + """List SAS credentials of a storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list SAS credentials for the storage account. + Is either a model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.AccountSasParameters 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 + :return: ListAccountSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListAccountSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListAccountSasResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "AccountSasParameters") + + request = build_list_account_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.list_account_sas.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListAccountSasResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_account_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListAccountSas"} # type: ignore + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: _models.ServiceSasParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ServiceSasParameters + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Required. + :type parameters: IO + :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: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def list_service_sas( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.ServiceSasParameters, IO], + **kwargs: Any + ) -> _models.ListServiceSasResponse: + """List service SAS credentials of a specific resource. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide to list service SAS credentials. Is either a model + type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.ServiceSasParameters 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 + :return: ListServiceSasResponse or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListServiceSasResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListServiceSasResponse] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "ServiceSasParameters") + + request = build_list_service_sas_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self.list_service_sas.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListServiceSasResponse", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list_service_sas.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/ListServiceSas"} # type: ignore + + def _failover_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any + ) -> None: + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_failover_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + failover_type=failover_type, + api_version=api_version, + template_url=self._failover_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _failover_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + + @distributed_trace + def begin_failover( + self, resource_group_name: str, account_name: str, failover_type: Literal["Planned"] = "Planned", **kwargs: Any + ) -> LROPoller[None]: + """A failover request can be triggered for a storage account in the event a primary endpoint + becomes unavailable for any reason. The failover occurs from the storage account's primary + cluster to the secondary cluster for RA-GRS accounts. The secondary cluster will become primary + after failover and the account is converted to LRS. In the case of a Planned Failover, the + primary and secondary clusters are swapped after failover and the account remains + geo-replicated. Failover should continue to be used in the event of availability issues as + Planned failover is only available while the primary and secondary endpoints are available. The + primary use case of a Planned Failover is disaster recovery testing drills. This type of + failover is invoked by setting FailoverType parameter to 'Planned'. Learn more about the + failover options here- + https://learn.microsoft.com/en-us/azure/storage/common/storage-disaster-recovery-guidance. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param failover_type: The parameter is set to 'Planned' to indicate whether a Planned failover + is requested. Known values are "Planned" and None. Default value is "Planned". + :type failover_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 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._failover_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + failover_type=failover_type, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + 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) + + begin_failover.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/failover"} # type: ignore + + def _hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any + ) -> None: + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_hierarchical_namespace_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + request_type=request_type, + api_version=api_version, + template_url=self._hierarchical_namespace_migration_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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) + + if cls: + return cls(pipeline_response, None, {}) + + _hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + + @distributed_trace + def begin_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, request_type: str, **kwargs: Any + ) -> LROPoller[None]: + """Live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param request_type: Required. Hierarchical namespace migration type can either be a + hierarchical namespace validation request 'HnsOnValidationRequest' or a hydration request + 'HnsOnHydrationRequest'. The validation request will validate the migration whereas the + hydration request will migrate the account. Required. + :type request_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 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + request_type=request_type, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + 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) + + begin_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/hnsonmigration"} # type: ignore + + def _abort_hierarchical_namespace_migration_initial( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_abort_hierarchical_namespace_migration_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self._abort_hierarchical_namespace_migration_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + 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) + + if cls: + return cls(pipeline_response, None, {}) + + _abort_hierarchical_namespace_migration_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + + @distributed_trace + def begin_abort_hierarchical_namespace_migration( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> LROPoller[None]: + """Abort live Migration of storage account to enable Hns. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._abort_hierarchical_namespace_migration_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + api_version=api_version, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements + if cls: + return cls(pipeline_response, None, {}) + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + 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) + + begin_abort_hierarchical_namespace_migration.metadata = {"url": "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/aborthnsonmigration"} # type: ignore + + def _restore_blob_ranges_initial( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> _models.BlobRestoreStatus: + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "BlobRestoreParameters") + + request = build_restore_blob_ranges_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + content_type=content_type, + json=_json, + content=_content, + template_url=self._restore_blob_ranges_initial.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if response.status_code == 200: + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + + if response.status_code == 202: + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _restore_blob_ranges_initial.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: _models.BlobRestoreParameters, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobRestoreParameters + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Required. + :type parameters: IO + :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 BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_restore_blob_ranges( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.BlobRestoreParameters, IO], + **kwargs: Any + ) -> LROPoller[_models.BlobRestoreStatus]: + """Restore blobs in the specified blob ranges. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The parameters to provide for restore blob ranges. Is either a model type or + a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.BlobRestoreParameters 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. + :return: An instance of LROPoller that returns either BlobRestoreStatus or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.storage.v2022_09_01.models.BlobRestoreStatus] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.BlobRestoreStatus] + polling = kwargs.pop("polling", True) # type: Union[bool, PollingMethod] + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token = kwargs.pop("continuation_token", None) # type: Optional[str] + if cont_token is None: + raw_result = self._restore_blob_ranges_initial( # type: ignore + resource_group_name=resource_group_name, + account_name=account_name, + parameters=parameters, + api_version=api_version, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize("BlobRestoreStatus", pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + if polling is True: + polling_method = cast( + PollingMethod, ARMPolling(lro_delay, lro_options={"final-state-via": "location"}, **kwargs) + ) # type: PollingMethod + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + 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) + + begin_restore_blob_ranges.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/restoreBlobRanges"} # type: ignore + + @distributed_trace + def revoke_user_delegation_keys( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> None: + """Revoke user delegation keys. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_revoke_user_delegation_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.revoke_user_delegation_keys.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + revoke_user_delegation_keys.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/revokeUserDelegationKeys"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_operations.py new file mode 100644 index 000000000000..62f74ae1f899 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_operations.py @@ -0,0 +1,788 @@ +# pylint: disable=too-many-lines +# 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, IO, Iterable, Optional, TypeVar, Union, overload +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_create_request( + resource_group_name: str, account_name: str, table_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_update_request( + resource_group_name: str, account_name: str, table_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_request( + resource_group_name: str, account_name: str, table_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_delete_request( + resource_group_name: str, account_name: str, table_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableName": _SERIALIZER.url( + "table_name", table_name, "str", max_length=63, min_length=3, pattern=r"^[A-Za-z][A-Za-z0-9]{2,62}$" + ), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_list_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +class TableOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`table` 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") + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table 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 + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None + + request = build_create_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + create.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[_models.Table] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[IO] = None, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Default value is None. + :type parameters: IO + :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: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, + resource_group_name: str, + account_name: str, + table_name: str, + parameters: Optional[Union[_models.Table, IO]] = None, + **kwargs: Any + ) -> _models.Table: + """Creates a new table with the specified table name, under the specified account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :param parameters: The parameters to provide to create a table. Is either a model type or a IO + type. Default value is None. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.Table 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 + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + if parameters is not None: + _json = self._serialize.body(parameters, "Table") + else: + _json = None + + request = build_update_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + 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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + update.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + @distributed_trace + def get(self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any) -> _models.Table: + """Gets the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: Table or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.Table + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.Table] + + request = build_get_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("Table", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + @distributed_trace + def delete( # pylint: disable=inconsistent-return-statements + self, resource_group_name: str, account_name: str, table_name: str, **kwargs: Any + ) -> None: + """Deletes the table with the specified table name, under the specified account if it exists. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param table_name: A table name must be unique within a storage account and must be between 3 + and 63 characters.The name must comprise of only alphanumeric characters and it cannot begin + with a numeric character. Required. + :type table_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 = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[None] + + request = build_delete_request( + resource_group_name=resource_group_name, + account_name=account_name, + table_name=table_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) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + delete.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables/{tableName}"} # type: ignore + + @distributed_trace + def list(self, resource_group_name: str, account_name: str, **kwargs: Any) -> Iterable["_models.Table"]: + """Gets a list of all the tables under the specified storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. 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 Table or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.Table] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableResource] + + 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_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ListTableResource", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/default/tables"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_services_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_services_operations.py new file mode 100644 index 000000000000..56c996fe3bd0 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_table_services_operations.py @@ -0,0 +1,459 @@ +# pylint: disable=too-many-lines +# 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, IO, Optional, TypeVar, Union, overload + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models +from ..._serialization import Serializer +from .._vendor import _convert_request, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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_set_service_properties_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_get_service_properties_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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", + "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}", + ) # pylint: disable=line-too-long + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url( + "resource_group_name", resource_group_name, "str", max_length=90, min_length=1, pattern=r"^[-\w\._\(\)]+$" + ), + "accountName": _SERIALIZER.url("account_name", account_name, "str", max_length=24, min_length=3), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "tableServiceName": _SERIALIZER.url("table_service_name", table_service_name, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +class TableServicesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`table_services` 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(self, resource_group_name: str, account_name: str, **kwargs: Any) -> _models.ListTableServices: + """List all table services for the storage account. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ListTableServices or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.ListTableServices + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.ListTableServices] + + request = build_list_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.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("ListTableServices", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + list.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices"} # type: ignore + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: _models.TableServiceProperties, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: IO, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Required. + :type parameters: IO + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def set_service_properties( + self, + resource_group_name: str, + account_name: str, + parameters: Union[_models.TableServiceProperties, IO], + **kwargs: Any + ) -> _models.TableServiceProperties: + """Sets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :param parameters: The properties of a storage account’s Table service, only properties for + Storage Analytics and CORS (Cross-Origin Resource Sharing) rules can be specified. Is either a + model type or a IO type. Required. + :type parameters: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties or IO + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: 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: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] + + content_type = content_type or "application/json" + _json = None + _content = None + if isinstance(parameters, (IO, bytes)): + _content = parameters + else: + _json = self._serialize.body(parameters, "TableServiceProperties") + + request = build_set_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + content_type=content_type, + json=_json, + content=_content, + template_url=self.set_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TableServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + set_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore + + @distributed_trace + def get_service_properties( + self, resource_group_name: str, account_name: str, **kwargs: Any + ) -> _models.TableServiceProperties: + """Gets the properties of a storage account’s Table service, including properties for Storage + Analytics and CORS (Cross-Origin Resource Sharing) rules. + + :param resource_group_name: The name of the resource group within the user's subscription. The + name is case insensitive. Required. + :type resource_group_name: str + :param account_name: The name of the storage account within the specified resource group. + Storage account names must be between 3 and 24 characters in length and use numbers and + lower-case letters only. Required. + :type account_name: str + :keyword table_service_name: The name of the Table Service within the specified storage + account. Table Service Name must be 'default'. Default value is "default". Note that overriding + this default value may result in unsupported behavior. + :paramtype table_service_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: TableServiceProperties or the result of cls(response) + :rtype: ~azure.mgmt.storage.v2022_09_01.models.TableServiceProperties + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map = { + 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + table_service_name = kwargs.pop("table_service_name", "default") # type: Literal["default"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.TableServiceProperties] + + request = build_get_service_properties_request( + resource_group_name=resource_group_name, + account_name=account_name, + subscription_id=self._config.subscription_id, + api_version=api_version, + table_service_name=table_service_name, + template_url=self.get_service_properties.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize("TableServiceProperties", pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get_service_properties.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}/tableServices/{tableServiceName}"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_usages_operations.py b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_usages_operations.py new file mode 100644 index 000000000000..4e2eb886283a --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/operations/_usages_operations.py @@ -0,0 +1,171 @@ +# pylint: disable=too-many-lines +# 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, Optional, TypeVar +import urllib.parse + +from azure.core.exceptions import ( + ClientAuthenticationError, + HttpResponseError, + ResourceExistsError, + ResourceNotFoundError, + ResourceNotModifiedError, + map_error, +) +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.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, _format_url_section + +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 +T = TypeVar("T") +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + + +def build_list_by_location_request(location: 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 = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = kwargs.pop( + "template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages" + ) # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, "str", min_length=1), + "location": _SERIALIZER.url("location", location, "str"), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # 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) + + +class UsagesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.mgmt.storage.v2022_09_01.StorageManagementClient`'s + :attr:`usages` 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_by_location(self, location: str, **kwargs: Any) -> Iterable["_models.Usage"]: + """Gets the current usage count and the limit for the resources of the location under the + subscription. + + :param location: The location of the Azure Storage resource. Required. + :type location: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either Usage or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.storage.v2022_09_01.models.Usage] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop("api_version", _params.pop("api-version", "2022-09-01")) # type: Literal["2022-09-01"] + cls = kwargs.pop("cls", None) # type: ClsType[_models.UsageListResult] + + 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_by_location_request( + location=location, + subscription_id=self._config.subscription_id, + api_version=api_version, + template_url=self.list_by_location.metadata["url"], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + 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) # type: ignore + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("UsageListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, stream=False, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + list_by_location.metadata = {"url": "/subscriptions/{subscriptionId}/providers/Microsoft.Storage/locations/{location}/usages"} # type: ignore diff --git a/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/py.typed b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/storage/azure-mgmt-storage/azure/mgmt/storage/v2022_09_01/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/sdk/storage/azure-mgmt-storage/setup.py b/sdk/storage/azure-mgmt-storage/setup.py index 5d08320df5ed..4203ed0bdc8a 100644 --- a/sdk/storage/azure-mgmt-storage/setup.py +++ b/sdk/storage/azure-mgmt-storage/setup.py @@ -55,6 +55,7 @@ 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', 'Programming Language :: Python :: 3.10', + 'Programming Language :: Python :: 3.11', 'License :: OSI Approved :: MIT License', ], zip_safe=False, @@ -69,9 +70,10 @@ 'pytyped': ['py.typed'], }, install_requires=[ - 'msrest>=0.7.1', - 'azure-common~=1.1', - 'azure-mgmt-core>=1.3.2,<2.0.0', + "msrest>=0.7.1", + "azure-common~=1.1", + "azure-mgmt-core>=1.3.2,<2.0.0", + "typing-extensions>=4.3.0; python_version<'3.8.0'", ], python_requires=">=3.7" ) diff --git a/shared_requirements.txt b/shared_requirements.txt index 72e3c8d1006f..ec865303aedc 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -312,6 +312,7 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-iot-deviceupdate isodate<1.0.0,>=0.6.1 #override azure-template azure-core<2.0.0,>=1.10.0 #override azure-purview-catalog azure-core<2.0.0,>=1.23.0 +#override azure-mgmt-storage typing-extensions>=4.3.0; python_version<'3.8.0' #override azure-purview-scanning azure-core<2.0.0,>=1.18.0 #override azure-mgmt-logic typing-extensions>=4.3.0; python_version<'3.8.0' #override azure-purview-account azure-core<2.0.0,>=1.16.0